refactor help mk2

This commit is contained in:
iou1name 2019-10-08 09:14:26 -04:00
parent bf6e5784f2
commit c09b4c04d3

View File

@ -45,14 +45,14 @@ def help(bot, trigger):
else:
if trigger.owner:
cmds = [cmd for _, cmd in bot.commands.items()]
funcs = [func for cmd, func in bot.commands.items()]
elif trigger.admin:
cmds = [cmd for _, cmd in bot.commands.items() if cmd.priv <= 5]
funcs = [func for cmd, func in bot.commands.items() if cmd.priv <= 5]
else:
priv = bot.channels[trigger.channel].privileges[trigger.nick]
cmds = [cmd for _, cmd in bot.commands.items() if cmd.priv <= priv]
funcs = [func for cmd, func in bot.commands.items() if cmd.priv <= priv]
cmds = [cmd.name for cmd in cmds if cmd.canonical]
cmds = sorted(cmds)
cmds = {func.commands[0] for func in funcs}
cmds = sorted(list(cmds))
msg = "Available commands: " + ", ".join(cmds)
bot.msg(msg)