diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 5dbd85f..794cbdc 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -12,24 +12,24 @@ class BotPrerun(): def __init__(self): self.dict = {} - def args(self, command_type='module_command'): + def args(self, trigger_command_type='module_command'): def actual_decorator(function): @functools.wraps(function) def argsbuilder(bot, trigger, *args, **kwargs): - trigger.sb = self.sopel_triggerargs(bot, trigger, command_type) + trigger.sb = self.sopel_trigger_args(bot, trigger, trigger_command_type) return function(bot, trigger, *args, **kwargs) return argsbuilder return actual_decorator - def sopel_triggerargs(self, bot, trigger, command_type='module_command'): - triggerargs = spicemanip.main(trigger.args[1], 'create') - if command_type in ['nickname', 'nickname_command', 'nickname_commands']: - command = spicemanip.main(triggerargs, 2).lower() - triggerargs = spicemanip.main(triggerargs, '3+', 'list') + def sopel_trigger_args(self, bot, trigger, trigger_command_type='module_command'): + trigger_args = spicemanip.main(trigger.args[1], 'create') + if trigger_command_type in ['nickname', 'nickname_command', 'nickname_commands']: + trigger_command = spicemanip.main(trigger_args, 2).lower() + trigger_args = spicemanip.main(trigger_args, '3+', 'list') else: - command = spicemanip.main(triggerargs, 1).lower()[1:] - triggerargs = spicemanip.main(triggerargs, '2+', 'list') - argsdict = {"com": command, "args": triggerargs, "type": command_type} + trigger_command = spicemanip.main(trigger_args, 1).lower()[1:] + trigger_args = spicemanip.main(trigger_args, '2+', 'list') + argsdict = {"com": trigger_command, "args": trigger_args, "type": trigger_command_type} return argsdict diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index 5286667..b724240 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -38,23 +38,6 @@ github_dict = { """Sopel Wrapping Tools""" -def sopel_triggerargs(bot, trigger, command_type='module_command'): - triggerargs = [] - - if len(trigger.args) > 1: - triggerargs = spicemanip.main(trigger.args[1], 'create') - triggerargs = spicemanip.main(triggerargs, 'create') - - if command_type in ['nickname_command']: - command = spicemanip.main(triggerargs, 2).lower() - triggerargs = spicemanip.main(triggerargs, '3+', 'list') - else: - command = spicemanip.main(triggerargs, 1).lower()[1:] - triggerargs = spicemanip.main(triggerargs, '2+', 'list') - - return triggerargs, command, command_type - - def bot_privs(bot, privtype): if privtype == 'owners': privtype = 'owner' diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index 7c1b616..1f4f6e9 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -10,25 +10,24 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDSQUERY]) +@SpiceBot.prerun.args('nickname_command') @sopel.module.nickname_commands('(.*)') def bot_command_nick(bot, trigger): - triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') - - if not triggercommand: + if not trigger.sb['com']: return - if triggercommand[0] == "?": + if trigger.sb['com'][0] == "?": return - if triggercommand in SpiceBot.commands.dict['commands']["nickname"].keys(): + if trigger.sb['com'] in SpiceBot.commands.dict['commands']["nickname"].keys(): return - triggerargs.insert(0, triggercommand) + trigger.sb['args'].insert(0, trigger.sb['com']) - fulltrigger = spicemanip.main(triggerargs, 0).lower() + fulltrigger = spicemanip.main(trigger.sb['args'], 0).lower() if fulltrigger.lower().startswith("what is"): - searchterm = spicemanip.main(triggerargs, "3+") or None + searchterm = spicemanip.main(trigger.sb['args'], "3+") or None if searchterm: searchreturn = SpiceBot.googlesearch(bot, searchterm) if not searchreturn: @@ -40,7 +39,7 @@ def bot_command_nick(bot, trigger): return elif fulltrigger.lower().startswith("where is"): - searchterm = spicemanip.main(triggerargs, "3+") or None + searchterm = spicemanip.main(trigger.sb['args'], "3+") or None if searchterm: if searchterm.lower() in ['waldo', 'wally']: @@ -68,14 +67,14 @@ def bot_command_nick(bot, trigger): # TODO # elif fulltrigger.lower().startswith(tuple(["have you seen"])): - # posstarget = spicemanip.main(triggerargs, 4) or 0 + # posstarget = spicemanip.main(trigger.sb['args'], 4) or 0 # message = seen_search(bot, botcom, posstarget) # bot.osd(message) # return # TODO elif fulltrigger.lower().startswith(tuple(["make me a", "beam me a"])): - makemea = spicemanip.main(triggerargs, "4+") or None + makemea = spicemanip.main(trigger.sb['args'], "4+") or None if makemea: bot.osd("beams " + trigger.nick + " a " + makemea, trigger.sender, 'action') else: @@ -83,7 +82,7 @@ def bot_command_nick(bot, trigger): return elif fulltrigger.lower().startswith("beam me to"): - location = spicemanip.main(triggerargs, "4+") or None + location = spicemanip.main(trigger.sb['args'], "4+") or None if location: bot.osd("locks onto " + trigger.nick + "s coordinates and transports them to " + location, 'action') else: @@ -131,7 +130,7 @@ def bot_command_nick(bot, trigger): return elif fulltrigger.lower().startswith("can you see"): - target = spicemanip.main(triggerargs, "4+") or None + target = spicemanip.main(trigger.sb['args'], "4+") or None if not target: bot.osd(trigger.nick + ", I can see clearly.") return diff --git a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py index c29a5ba..cf462b1 100644 --- a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py +++ b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py @@ -9,21 +9,22 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.prerun.args('nickname_command') @sopel.module.nickname_commands('owners', 'owner') def bot_command_owners(bot, trigger): bot_command_process(bot, trigger) +@SpiceBot.prerun.args('nickname_command') @sopel.module.nickname_commands('admins') def bot_command_admins(bot, trigger): bot_command_process(bot, trigger) def bot_command_process(bot, trigger): - triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') - if triggercommand == 'owner': - triggercommand = 'owners' + if trigger.sb['com'] == 'owner': + trigger.sb['com'] = 'owners' - privlist = spicemanip.main(SpiceBot.bot_privs(bot, triggercommand), 'andlist') - bot.osd(str(bot.nick) + " " + triggercommand + ": " + privlist) + privlist = spicemanip.main(SpiceBot.bot_privs(bot, trigger.sb['com']), 'andlist') + bot.osd(str(bot.nick) + " " + trigger.sb['com'] + ": " + privlist) diff --git a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py index e4266b2..039113a 100644 --- a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py +++ b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py @@ -10,17 +10,16 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) +@SpiceBot.prerun.args('nickname_command') @sopel.module.nickname_commands('channels', 'channel') def nickname_comand_channels(bot, trigger): - triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') - - if not len(triggerargs): + if not len(trigger.sb['args']): commandused = 'list' else: - commandused = spicemanip.main(triggerargs, 1).lower() + commandused = spicemanip.main(trigger.sb['args'], 1).lower() - triggerargs = spicemanip.main(triggerargs, '2+', 'list') + trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') if commandused == 'list': chanlist = spicemanip.main(bot.channels.keys(), 'andlist') @@ -60,10 +59,10 @@ def nickname_comand_channels(bot, trigger): return elif commandused == 'topic': - if not len(triggerargs): + if not len(trigger.sb['args']): bot.osd("Channel name input missing.") return - channel = spicemanip.main(triggerargs, 1) + channel = spicemanip.main(trigger.sb['args'], 1) if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()): bot.osd("Channel name {} not valid.".format(channel)) return @@ -73,14 +72,14 @@ def nickname_comand_channels(bot, trigger): return if commandused.upper() in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']: - if not len(triggerargs): + if not len(trigger.sb['args']): if trigger.is_privmsg: bot.osd("Channel name required.") return else: channel = trigger.sender else: - channel = spicemanip.main(triggerargs, 1) + channel = spicemanip.main(trigger.sb['args'], 1) if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()): bot.osd("Channel name {} not valid.".format(channel)) return @@ -100,7 +99,7 @@ def nickname_comand_channels(bot, trigger): # Users List if commandused == 'users': - channel = spicemanip.main(triggerargs, 1) + channel = spicemanip.main(trigger.sb['args'], 1) if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()): bot.osd("Channel name {} not valid.".format(channel)) return diff --git a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py index 5318bcd..f6c485e 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py @@ -11,20 +11,19 @@ import spicemanip @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY]) +@SpiceBot.prerun.args('nickname_command') @sopel.module.nickname_commands('(.*)') def query_detection_nick(bot, trigger): - triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') - # command issued, check if valid - if not triggercommand or not len(triggercommand): + if not trigger.sb['com'] or not len(trigger.sb['com']): return - if not triggercommand[0] == "?": + if not trigger.sb['com'][0] == "?": return - triggercommand = triggercommand[1:] + trigger.sb['com'] = trigger.sb['com'][1:] - if not SpiceBot.letters_in_string(triggercommand): + if not SpiceBot.letters_in_string(trigger.sb['com']): return commands_list = dict() @@ -32,46 +31,46 @@ def query_detection_nick(bot, trigger): if com not in commands_list.keys(): commands_list[com] = SpiceBot.commands.dict['commands']['nickname'][com] - if triggercommand.endswith("+"): + if trigger.sb['com'].endswith("+"): - triggercommand = triggercommand[:-1] - if not triggercommand or not len(triggercommand): + trigger.sb['com'] = trigger.sb['com'][:-1] + if not trigger.sb['com'] or not len(trigger.sb['com']): return - if triggercommand.lower() not in list(commands_list.keys()): - dispmsg = ["Cannot find any alias " + bot.nick + " commands: No valid commands match " + str(triggercommand) + "."] - closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') + if trigger.sb['com'].lower() not in list(commands_list.keys()): + dispmsg = ["Cannot find any alias " + bot.nick + " commands: No valid commands match " + str(trigger.sb['com']) + "."] + closestmatches = SpiceBot.similar_list(bot, trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') if len(closestmatches): - dispmsg.append("The following " + bot.nick + " commands match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") + dispmsg.append("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") bot.notice(dispmsg, trigger.nick) return - realcom = triggercommand - if "aliasfor" in commands_list[triggercommand].keys(): - realcom = commands_list[triggercommand]["aliasfor"] + realcom = trigger.sb['com'] + if "aliasfor" in commands_list[trigger.sb['com']].keys(): + realcom = commands_list[trigger.sb['com']]["aliasfor"] validcomlist = commands_list[realcom]["validcoms"] - bot.notice("The following " + bot.nick + " commands match " + str(triggercommand) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick) + bot.notice("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick) return - if triggercommand.endswith("?"): + if trigger.sb['com'].endswith("?"): - triggercommand = triggercommand[:-1] - if not triggercommand or not len(triggercommand): + trigger.sb['com'] = trigger.sb['com'][:-1] + if not trigger.sb['com'] or not len(trigger.sb['com']): return - closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') + closestmatches = SpiceBot.similar_list(bot, trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') if not len(closestmatches): - bot.notice("Cannot find any similar " + bot.nick + " commands for " + str(triggercommand) + ".", trigger.nick) + bot.notice("Cannot find any similar " + bot.nick + " commands for " + str(trigger.sb['com']) + ".", trigger.nick) else: - bot.notice("The following " + bot.nick + " commands may match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick) + bot.notice("The following " + bot.nick + " commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick) return commandlist = [] for command in list(commands_list.keys()): - if command.lower().startswith(str(triggercommand).lower()): + if command.lower().startswith(str(trigger.sb['com']).lower()): commandlist.append(command) if not len(commandlist): - bot.notice("No " + bot.nick + " commands start with " + str(triggercommand) + ".", trigger.nick) + bot.notice("No " + bot.nick + " commands start with " + str(trigger.sb['com']) + ".", trigger.nick) else: - bot.notice("The following " + bot.nick + " commands start with " + str(triggercommand) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick) + bot.notice("The following " + bot.nick + " commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick) diff --git a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py index 08a46aa..10bf80f 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py @@ -11,16 +11,15 @@ import spicemanip @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY]) +@SpiceBot.prerun.args('query_command') @sopel.module.rule('^\?(.*)') def query_detection(bot, trigger): - triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'query_command') - # command issued, check if valid - if not triggercommand or not len(triggercommand): + if not trigger.sb['com'] or not len(trigger.sb['com']): return - if not SpiceBot.letters_in_string(triggercommand): + if not SpiceBot.letters_in_string(trigger.sb['com']): return commands_list = dict() @@ -30,46 +29,46 @@ def query_detection(bot, trigger): if com not in commands_list.keys(): commands_list[com] = SpiceBot.commands.dict['commands'][commandstype][com] - if triggercommand[:-1] == "+": + if trigger.sb['com'][:-1] == "+": - triggercommand = triggercommand[:-1] - if not triggercommand or not len(triggercommand): + trigger.sb['com'] = trigger.sb['com'][:-1] + if not trigger.sb['com'] or not len(trigger.sb['com']): return - if triggercommand.lower() not in list(commands_list.keys()): - dispmsg = ["Cannot find any alias commands: No valid commands match " + str(triggercommand) + "."] - closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') + if trigger.sb['com'].lower() not in list(commands_list.keys()): + dispmsg = ["Cannot find any alias commands: No valid commands match " + str(trigger.sb['com']) + "."] + closestmatches = SpiceBot.similar_list(bot, trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') if len(closestmatches): - dispmsg.append("The following commands match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") + dispmsg.append("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") bot.notice(dispmsg, trigger.nick) return - realcom = triggercommand - if "aliasfor" in commands_list[triggercommand].keys(): - realcom = commands_list[triggercommand]["aliasfor"] + realcom = trigger.sb['com'] + if "aliasfor" in commands_list[trigger.sb['com']].keys(): + realcom = commands_list[trigger.sb['com']]["aliasfor"] validcomlist = commands_list[realcom]["validcoms"] - bot.notice("The following commands match " + str(triggercommand) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick) + bot.notice("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick) return - if triggercommand[:-1] == "?": + if trigger.sb['com'][:-1] == "?": - triggercommand = triggercommand[:-1] - if not triggercommand or not len(triggercommand): + trigger.sb['com'] = trigger.sb['com'][:-1] + if not trigger.sb['com'] or not len(trigger.sb['com']): return - closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') + closestmatches = SpiceBot.similar_list(bot, trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') if not len(closestmatches): - bot.notice("Cannot find any similar commands for " + str(triggercommand) + ".", trigger.nick) + bot.notice("Cannot find any similar commands for " + str(trigger.sb['com']) + ".", trigger.nick) else: - bot.notice("The following commands may match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick) + bot.notice("The following commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick) return commandlist = [] for command in list(commands_list.keys()): - if command.lower().startswith(str(triggercommand).lower()): + if command.lower().startswith(str(trigger.sb['com']).lower()): commandlist.append(command) if not len(commandlist): - bot.notice("No commands start with " + str(triggercommand) + ".", trigger.nick) + bot.notice("No commands start with " + str(trigger.sb['com']) + ".", trigger.nick) else: - bot.notice("The following commands start with " + str(triggercommand) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick) + bot.notice("The following commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick) diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py b/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py index ae8f3d1..941d4fe 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py +++ b/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py @@ -12,19 +12,18 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH]) +@SpiceBot.prerun.args('prefix_command') @sopel.module.commands('(.*)') def gifapi_triggers(bot, trigger): - triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'prefix_command') - - if triggercommand not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): + if trigger.sb['com'] not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): return - if not len(triggerargs): + if not len(trigger.sb['args']): return bot.osd("Please present a query to search.") - query = spicemanip.main(triggerargs, 0) - searchdict = {"query": query, "gifsearch": triggercommand} + query = spicemanip.main(trigger.sb['args'], 0) + searchdict = {"query": query, "gifsearch": trigger.sb['com']} gifdict = getGif(bot, searchdict) diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_Command.py b/sopel_modules/SpiceBot_GifSearch/Gif_Command.py index 10d6c3e..bf306c4 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_Command.py +++ b/sopel_modules/SpiceBot_GifSearch/Gif_Command.py @@ -12,14 +12,14 @@ import spicemanip @SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH]) +@SpiceBot.prerun.args('prefix_command') @module.commands('gif') def gif_trigger(bot, trigger): - triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger) - if not len(triggerargs): + if not len(trigger.sb['args']): return bot.osd("Please present a query to search.") - query = spicemanip.main(triggerargs, 0) + query = spicemanip.main(trigger.sb['args'], 0) searchapis = bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys() searchdict = {"query": query, "gifsearch": searchapis} diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands b/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands index ae8f3d1..941d4fe 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands +++ b/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands @@ -12,19 +12,18 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH]) +@SpiceBot.prerun.args('prefix_command') @sopel.module.commands('(.*)') def gifapi_triggers(bot, trigger): - triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'prefix_command') - - if triggercommand not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): + if trigger.sb['com'] not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): return - if not len(triggerargs): + if not len(trigger.sb['args']): return bot.osd("Please present a query to search.") - query = spicemanip.main(triggerargs, 0) - searchdict = {"query": query, "gifsearch": triggercommand} + query = spicemanip.main(trigger.sb['args'], 0) + searchdict = {"query": query, "gifsearch": trigger.sb['com']} gifdict = getGif(bot, searchdict) diff --git a/sopel_modules/SpiceBot_Logs/Logs_Command.py b/sopel_modules/SpiceBot_Logs/Logs_Command.py index fd2afc2..bdb17e6 100644 --- a/sopel_modules/SpiceBot_Logs/Logs_Command.py +++ b/sopel_modules/SpiceBot_Logs/Logs_Command.py @@ -9,6 +9,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_LOGS]) +@SpiceBot.prerun.args('nickname_command') @sopel.module.nickname_commands('logs', 'debug') def bot_command_logs(bot, trigger): @@ -16,9 +17,7 @@ def bot_command_logs(bot, trigger): bot.say("I was unable to process this Bot Nick command due to privilege issues.") return - triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') - - logtype = spicemanip.main(triggerargs, 1) or None + logtype = spicemanip.main(trigger.sb['args'], 1) or None if not logtype: bot.osd("Current valid log(s) include: " + spicemanip.main(SpiceBot.logs.dict["list"].keys(), 'andlist'), trigger.sender, 'action') return diff --git a/sopel_modules/SpiceBot_Messaging/Messaging.py b/sopel_modules/SpiceBot_Messaging/Messaging.py index 0001948..e0ce5e1 100644 --- a/sopel_modules/SpiceBot_Messaging/Messaging.py +++ b/sopel_modules/SpiceBot_Messaging/Messaging.py @@ -9,16 +9,19 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.prerun.args('nickname_command') @sopel.module.nickname_commands('action') def bot_command_action(bot, trigger): bot_command_process(bot, trigger) +@SpiceBot.prerun.args('nickname_command') @sopel.module.nickname_commands('notice') def bot_command_notice(bot, trigger): bot_command_process(bot, trigger) +@SpiceBot.prerun.args('nickname_command') @sopel.module.nickname_commands('privmsg', 'say', 'msg') def bot_command_privmsg(bot, trigger): bot_command_process(bot, trigger) @@ -30,23 +33,21 @@ def bot_command_process(bot, trigger): bot.say("I was unable to process this Bot Nick command due to privilege issues.") return - triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') + if trigger.sb['com'] in ['say', 'msg']: + trigger.sb['com'] = 'privmsg' - if triggercommand in ['say', 'msg']: - triggercommand = 'privmsg' - - if not len(triggerargs): + if not len(trigger.sb['args']): bot.say("You must specify a channel or nick.") return - target = spicemanip.main(triggerargs, 1) + target = spicemanip.main(trigger.sb['args'], 1) if (target not in ['allchans', 'allnicks'] and not SpiceBot.inlist(target.lower(), SpiceBot.channels.dict['list'].keys()) and not SpiceBot.inlist(target.lower(), bot.users)): bot.osd("Channel/nick name {} not valid.".format(target)) return - triggerargs = spicemanip.main(triggerargs, '2+', 'list') + trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') if target == 'allchans': targetsendlist = bot.channels.keys() @@ -55,9 +56,9 @@ def bot_command_process(bot, trigger): else: targetsendlist = [target] - botmessage = spicemanip.main(triggerargs, 0) + botmessage = spicemanip.main(trigger.sb['args'], 0) if not botmessage: bot.say("You must specify a message to send.") return - bot.osd(botmessage, targetsendlist, triggercommand.upper()) + bot.osd(botmessage, targetsendlist, trigger.sb['com'].upper()) diff --git a/sopel_modules/SpiceBot_Update/Update.py b/sopel_modules/SpiceBot_Update/Update.py index 511602d..d56ba0d 100644 --- a/sopel_modules/SpiceBot_Update/Update.py +++ b/sopel_modules/SpiceBot_Update/Update.py @@ -27,6 +27,7 @@ def setup(bot): bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) +@SpiceBot.prerun.args('nickname_command') @sopel.module.nickname_commands('update') def nickname_comand_update(bot, trigger): @@ -34,18 +35,16 @@ def nickname_comand_update(bot, trigger): bot.say("I was unable to process this Bot Nick command due to privilege issues.") return - triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') - - if not len(triggerargs): + if not len(trigger.sb['args']): commandused = 'nodeps' else: - commandused = spicemanip.main(triggerargs, 1).lower() + commandused = spicemanip.main(trigger.sb['args'], 1).lower() if commandused not in ['deps', 'nodeps']: bot.say("Please specify deps or nodeps") return - triggerargs = spicemanip.main(triggerargs, '2+', 'list') + trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') quitmessage = "Received command from " + trigger.nick + " to update from Github and restart" SpiceBot.logs.log('SpiceBot_Update', quitmessage)