From 264187299dbcbef99d4c2af54b7130f239ab2873 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 25 Jun 2019 11:21:06 -0400 Subject: [PATCH] first _match test --- sopel_modules/SpiceBot/Prerun.py | 7 ++++++- sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py | 2 +- sopel_modules/SpiceBot_Core_Commands/DictComs.py | 2 +- sopel_modules/SpiceBot_Core_Commands/Gif.py | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index f387ae9..3872ee4 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -16,13 +16,18 @@ from .Commands import commands as botcommands from .Database import db as botdb -def prerun(trigger_command_type='module'): +def prerun(t_command_type='module'): def actual_decorator(function): @functools.wraps(function) def internal_prerun(bot, trigger, *args, **kwargs): + if t_command_type.endswith("_match"): + trigger_command_type = t_command_type.replace("_match", '') + else: + trigger_command_type = t_command_type + # Primary command used for trigger, and a list of all words trigger_args, trigger_command = make_trigger_args(trigger.args[1], trigger_command_type) if trigger_command == 'uptime': diff --git a/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py b/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py index 72fcaa8..b6fa9b0 100644 --- a/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py +++ b/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py @@ -13,7 +13,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) -@SpiceBot.prerun('nickname') +@SpiceBot.prerun('nickname_match') @sopel.module.nickname_commands('(.*)') def query_detection_nick(bot, trigger): diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index 2d84f2a..201b094 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -10,7 +10,7 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@SpiceBot.prerun('prefix') +@SpiceBot.prerun('prefix_match') @sopel.module.commands('(.*)') def command_dictcom(bot, trigger): diff --git a/sopel_modules/SpiceBot_Core_Commands/Gif.py b/sopel_modules/SpiceBot_Core_Commands/Gif.py index b349172..d02b179 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Gif.py +++ b/sopel_modules/SpiceBot_Core_Commands/Gif.py @@ -30,7 +30,7 @@ def gif_trigger(bot, trigger): bot.osd(str(gifdict['gifapi'].title() + " Result (" + str(query) + " #" + str(gifdict["returnnum"]) + "): " + str(gifdict["returnurl"]))) -@SpiceBot.prerun('gif_prefix') +@SpiceBot.prerun('gif_prefix_match') @sopel.module.commands('(.*)') def gifapi_triggers(bot, trigger):