def call_command(bot, event, irc, arguments):
command = ' '.join(arguments).split(' ')
if not command[0].startswith("?"):
del command[0]
name = command[0]
else:
name = command[0][1:]
if not name == '' and not name.find("?") != -1:
privmsg = event.target == bot.config['nickname']
args = command[1:] if len(command) > 1 else ''
host = event.source.host
chan = event.target if not privmsg else False
try:
perms = commands[name]['perms']
min_args = commands[name]['minArgs']
if check_perms(host, chan, owner=perms[2], admin=perms[1],
trusted=perms[0]):
if len(args) < min_args:
irc.reply(event, config.argsMissing)
else:
target = "a private message" if privmsg else event.target
source = event.source
log.info("%s called %s in %s", source, name, target)
commands[name]['func'](bot, event, irc, args)
else:
if not event.source.host.find("/bot/"):
irc.reply(event, config.noPerms)
except KeyError:
irc.notice(event.source.nick, config.invalidCmd.format(name))
except Exception:
irc.reply(event, 'Oops, an error occured!')
print_error(irc, event)
评论列表
文章目录