diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index b28ed08..c476bcb 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -14,9 +14,6 @@ from sopel_modules.SpiceBot_Events.System import botevents @sopel.module.nickname_commands('(.*)') def bot_command_nick(bot, trigger): - # while not botevents.check([botevents.BOT_LOADED, botevents.BOT_COMMANDSQUERY]): - # pass - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') if not triggercommand: diff --git a/sopel_modules/SpiceBot_Channels/Channels_Command.py b/sopel_modules/SpiceBot_Channels/Channels_Command.py index 92ae05c..0dd6045 100644 --- a/sopel_modules/SpiceBot_Channels/Channels_Command.py +++ b/sopel_modules/SpiceBot_Channels/Channels_Command.py @@ -18,9 +18,6 @@ from .Channels import bot_part_empty @sopel.module.nickname_commands('channels', 'channel') def nickname_comand_channels(bot, trigger): - # while not botevents.check(botevents.BOT_LOADED): - # pass - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') if not len(triggerargs): diff --git a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py index 2e81930..23d4ca5 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py @@ -16,9 +16,6 @@ import spicemanip @sopel.module.nickname_commands('(.*)') def query_detection_nick(bot, trigger): - # while not botevents.check(botevents.BOT_COMMANDSQUERY): - # pass - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') # command issued, check if valid diff --git a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py index a4aec45..7adb427 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py @@ -16,9 +16,6 @@ import spicemanip @sopel.module.rule('^\?(.*)') def query_detection(bot, trigger): - # while not botevents.check(botevents.BOT_COMMANDSQUERY): - # pass - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'query_command') # command issued, check if valid diff --git a/sopel_modules/SpiceBot_Events/Events.py b/sopel_modules/SpiceBot_Events/Events.py index 5933e42..d8a2d60 100644 --- a/sopel_modules/SpiceBot_Events/Events.py +++ b/sopel_modules/SpiceBot_Events/Events.py @@ -15,7 +15,6 @@ import time @sopel.module.rule('.*') def bot_startup_connection(bot, trigger): botevents.trigger(bot, botevents.BOT_WELCOME, "Welcome to the SpiceBot Events System") - while not len(bot.channels.keys()) > 0: pass time.sleep(1) @@ -27,11 +26,13 @@ def bot_startup_connection(bot, trigger): def bot_events_start(bot, trigger): bot_logging(bot, 'SpiceBot_Events', trigger.args[1], True) botevents.recieved(trigger) - botevents.trigger(bot, botevents.BOT_READY, "Ready To Process module setup procedures") - while not botevents.startup_check(): - pass + +@botevents.startup_check_ready() +@sopel.module.event(botevents.BOT_READY) +@sopel.module.rule('.*') +def bot_events_startup_complete(bot, trigger): botevents.trigger(bot, botevents.BOT_LOADED, "All registered modules setup procedures have completed") diff --git a/sopel_modules/SpiceBot_Events/System.py b/sopel_modules/SpiceBot_Events/System.py index 98b73ac..570499e 100644 --- a/sopel_modules/SpiceBot_Events/System.py +++ b/sopel_modules/SpiceBot_Events/System.py @@ -80,14 +80,22 @@ class BotEvents(object): def actual_decorator(function): @functools.wraps(function) def _nop(*args, **kwargs): - # Assign trigger and bot for easy access later - bot, trigger = args[0:2] while not self.check(checklist): pass return function(*args, **kwargs) return _nop return actual_decorator + def startup_check_ready(self): + def actual_decorator(function): + @functools.wraps(function) + def _nop(*args, **kwargs): + while not self.startup_check(): + pass + return function(*args, **kwargs) + return _nop + return actual_decorator + botevents = BotEvents() diff --git a/sopel_modules/SpiceBot_GifSearch/gif.py b/sopel_modules/SpiceBot_GifSearch/gif.py index a33f6f6..e517965 100644 --- a/sopel_modules/SpiceBot_GifSearch/gif.py +++ b/sopel_modules/SpiceBot_GifSearch/gif.py @@ -16,9 +16,6 @@ import spicemanip @module.commands('gif') def gif_trigger(bot, trigger): - # while not botevents.check(botevents.BOT_GIFSEARCH): - # pass - triggerargs, triggercommand = sopel_triggerargs(bot, trigger) if not len(triggerargs): return bot.osd("Please present a query to search.") diff --git a/sopel_modules/SpiceBot_GifSearch/gifapi.py b/sopel_modules/SpiceBot_GifSearch/gifapi.py index c47d7b8..2f6cc7b 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifapi.py +++ b/sopel_modules/SpiceBot_GifSearch/gifapi.py @@ -16,9 +16,6 @@ from sopel_modules.SpiceBot_Events.System import botevents @sopel.module.commands('(.*)') def gifapi_triggers(bot, trigger): - # while not botevents.check(botevents.BOT_GIFSEARCH): - # pass - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'prefix_command') if triggercommand not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): diff --git a/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py b/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py index e694bcc..559058a 100644 --- a/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py +++ b/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py @@ -32,9 +32,6 @@ def bot_events_complete(bot, trigger): def InvalidCommand_triggers(bot, trigger): return - # while not botevents.check([botevents.BOT_LOADED, botevents.BOT_COMMANDSQUERY]): - # pass - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'prefix_command') # patch for people typing "...", maybe other stuff, but this verifies that there is still a command here diff --git a/sopel_modules/SpiceBot_Logs/Logs_Command.py b/sopel_modules/SpiceBot_Logs/Logs_Command.py index fcf83a6..dd4d78e 100644 --- a/sopel_modules/SpiceBot_Logs/Logs_Command.py +++ b/sopel_modules/SpiceBot_Logs/Logs_Command.py @@ -15,9 +15,6 @@ from .Logs import systemd_logs_fetch, stdio_logs_fetch @sopel.module.nickname_commands('logs', 'debug') def bot_command_logs(bot, trigger): - # while not botevents.check(botevents.BOT_LOGS): - # pass - if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): bot.say("I was unable to process this Bot Nick command due to privilege issues.") return