diff --git a/sopel_SpiceBot_Runtime_Nickname_Commands/__init__.py b/sopel_SpiceBot_Runtime_Nickname_Commands/__init__.py index 09a3084..1bfbb93 100644 --- a/sopel_SpiceBot_Runtime_Nickname_Commands/__init__.py +++ b/sopel_SpiceBot_Runtime_Nickname_Commands/__init__.py @@ -1,4 +1,6 @@ +import collections +import textwrap from sopel import plugin @@ -16,7 +18,19 @@ def sb_test_commands(bot, trigger): @plugin.nickname_command('command_groups') def sb_test_command_groups(bot, trigger): - sb.osd(str(bot.command_groups.keys()), trigger.sender) + 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()