From 98b97c4e08f26c0154aa32e943f7b3076c62e6ac Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 14:42:55 -0400 Subject: [PATCH] command command --- .../SpiceBot_Core_Commands/Commands.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sopel_modules/SpiceBot_Core_Commands/Commands.py b/sopel_modules/SpiceBot_Core_Commands/Commands.py index 461c62a..f6c7cd8 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Commands.py +++ b/sopel_modules/SpiceBot_Core_Commands/Commands.py @@ -12,6 +12,39 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) +@SpiceBot.prerun.prerun('nickname') +@sopel.module.nickname_commands('commands', 'command') +def nickname_comand_channels(bot, trigger): + + if not len(trigger.sb['args']): + commandused = 'list' + else: + commandused = spicemanip.main(trigger.sb['args'], 1).lower() + + commands_list = [] + for commandstype in SpiceBot.commands.dict['commands'].keys(): + if commandstype not in ['rule']: + for com in SpiceBot.commands.dict['commands'][commandstype].keys(): + if com not in commands_list: + if commandstype in ['nickname']: + commands_list.append(bot.nick + " " + com) + else: + commands_list.append(com) + + if commandused == 'list': + bot.osd(spicemanip.main(commands_list, 'andlist'), trigger.nick, 'NOTICE') + return + + elif commandused == 'total': + bot.osd("I have " + str(len(commands_list)) + " commands available.") + return + + elif commandused == 'random': + bot.osd(["Here's a random command for you:", + spicemanip.main(commands_list, 'random')]) + return + + @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) @SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('(.*)')