def modload(chan, nick, mod): if mod in module.modinfo: ircsock.reply(chan, nick, '%s is already loaded. (%s)' % (mod, module.modinfo[mod, 'version'])) return try: module.load(mod) except IOError, e: ircsock.msg(chan, '%s: %s' (mod, e)) return
def evalirc(chan, nick, expr): try: result = eval(expr) except: reply(chan, nick, '%s raised exception: %s' % (expr, sys.exc_info())) return if result is None: reply(chan, nick, '%s is None.' % expr) return ircsock.msg(chan, result)
def cmd_lookup(src): user = src[0] user = user[1:] user = user.split('!') user = user[0] target = src[2] src.pop(0) src.pop(0) src.pop(0) msg = ' '.join(src) msg = msg[1:] if msg.startswith(conf.bot['trigger']): trigger = conf.bot['trigger'] msg = msg[1:] cmd = msg.split(' ') cmd = cmd[0] cmd = cmd.lower() if msg: args = msg.split() args.pop(0) args = ' '.join(args) if cmd in event.commands: code = event.commands[cmd, 'code'] try: if args: code(target, user, args) if not args: code(target, user) except TypeError, e: ircsock.reply(target, user, '-%s failed: %s' % (cmd, e)) if (cmd, 'syntax') in event.commands: ircsock.msg(target, 'Syntax: %s%s %s' % (conf.bot['trigger'], cmd.upper(), event.commands[cmd, 'syntax'])) return else: ircsock.reply(target, user, 'See HELP %s for useage.' % cmd) return else: ircsock.reply(target, user, '%s: Command not found.' % cmd.upper())
'acl': 'owner', 'code': _disconnect, 'pkg': __name__ }) def modload(chan, nick, mod): if mod in module.modinfo: ircsock.reply(chan, nick, '%s is already loaded. (%s)' % (mod, module.modinfo[mod, 'version'])) return try: module.load(mod) except IOError, e: ircsock.msg(chan, '%s: %s' (mod, e)) return except: ircsock.msg(chan, '%s: %s' % (mod, sys.exc_info())) return ircsock.reply(chan, nick, '%s loaded.' % mod) event.command_add({ 'cmd': 'modload', 'help': 'Load a module runtime. Module is in relation to the root directory of the bot.', 'syntax': '<module>.py', 'acl': 'owner', 'code': modload, 'pkg': __name__ }) def modunload(chan, nick, mod): if mod not in module.modinfo: ircsock.reply(chan, nick, '\002%s\002 is not loaded.' % mod)