import collections import textwrap from sopel import plugin from sopel_SpiceBot_Core_1 import sb from sopel_SpiceBot_Core_Prerun import prerun @prerun() @plugin.nickname_command('test') def sb_test_commands(bot, trigger): bot.say("%s" % trigger.raw) @plugin.nickname_command('command_groups') def sb_test_command_groups(bot, trigger): msgs = [] name_length = max(6, max(len(k) for k in bot.command_groups.keys())) for category, cmds in collections.OrderedDict(sorted(bot.command_groups.items())).items(): category = category.upper().ljust(name_length) cmds = set(cmds) # remove duplicates cmds = ' '.join(cmds) msg = category + ' ' + cmds indent = ' ' * (name_length + 2) # Honestly not sure why this is a list here msgs.append('\n'.join(textwrap.wrap(msg, subsequent_indent=indent))) sb.osd(msgs, trigger.sender) @prerun() @plugin.nickname_command('commands') def sopel_commands(bot, trigger): bot.say("testing commands") for x in sb.commands.sopel_commands: bot.say(str(x)) for y in x: bot.say(str(y)) @prerun() @plugin.nickname_command('nickname_commands') def sopel_nickname_commands(bot, trigger): bot.say("testing nickname_commands") for x in sb.commands.sopel_nickname_commands: bot.say(str(x)) for y in x: bot.say(str(y)) @prerun() @plugin.nickname_command('action_commands') def sopel_action_commands(bot, trigger): bot.say("testing action_commands") for x in sb.commands.sopel_action_commands: bot.say(str(x)) for y in x: bot.say(str(y))