From 4b0343e5defcd517c003da41b5a0fc6f649ea347 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 3 Jul 2019 09:12:37 -0400 Subject: [PATCH] wait til the bot is loaded --- sopel_modules/SpiceBot_Core_Commands/AI.py | 2 ++ sopel_modules/SpiceBot_Core_Commands/BotPrivs.py | 2 ++ .../SpiceBot_Core_Commands/CommandsQuery.py | 2 ++ sopel_modules/SpiceBot_Core_Commands/Database.py | 1 + sopel_modules/SpiceBot_Core_Commands/DictComs.py | 1 + sopel_modules/SpiceBot_Core_Commands/Docs.py | 13 ++++++++----- sopel_modules/SpiceBot_Core_Commands/Gif.py | 1 + sopel_modules/SpiceBot_Core_Commands/Messaging.py | 3 +++ sopel_modules/SpiceBot_Core_Commands/Reddit.py | 9 ++++++++- .../SpiceBot_Core_Commands/Runtime_Controls.py | 2 ++ sopel_modules/SpiceBot_Core_Commands/Search.py | 3 +++ sopel_modules/SpiceBot_Core_Commands/Sherlock.py | 1 + sopel_modules/SpiceBot_Core_Commands/Uptime.py | 1 + sopel_modules/SpiceBot_Core_Commands/Users.py | 1 + 14 files changed, 36 insertions(+), 6 deletions(-) diff --git a/sopel_modules/SpiceBot_Core_Commands/AI.py b/sopel_modules/SpiceBot_Core_Commands/AI.py index 98b6fce..3ccbe20 100644 --- a/sopel_modules/SpiceBot_Core_Commands/AI.py +++ b/sopel_modules/SpiceBot_Core_Commands/AI.py @@ -9,6 +9,7 @@ import sopel_modules.SpiceBot as SpiceBot import spicemanip +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('ai') def ai_trigger(bot, trigger, botcom): @@ -18,6 +19,7 @@ def ai_trigger(bot, trigger, botcom): bot.osd(displayval) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @sopel.module.rule('(.*)') def bot_command_rule_ai(bot, trigger): diff --git a/sopel_modules/SpiceBot_Core_Commands/BotPrivs.py b/sopel_modules/SpiceBot_Core_Commands/BotPrivs.py index be1b25f..7633451 100644 --- a/sopel_modules/SpiceBot_Core_Commands/BotPrivs.py +++ b/sopel_modules/SpiceBot_Core_Commands/BotPrivs.py @@ -9,12 +9,14 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('owners', 'owner') def bot_command_owners(bot, trigger, botcom): bot_command_process(bot, trigger) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('admins', 'admin') def bot_command_admins(bot, trigger, botcom): diff --git a/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py b/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py index 2732765..150d5e6 100644 --- a/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py +++ b/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py @@ -12,12 +12,14 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('query') def query_trigger(bot, trigger, botcom): bot.osd("I have been programmed to help find new commands by using `?`.") +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) @SpiceBot.prerun_query('nickname', 'nickname') @sopel.module.nickname_commands('(.*)') diff --git a/sopel_modules/SpiceBot_Core_Commands/Database.py b/sopel_modules/SpiceBot_Core_Commands/Database.py index c4773a5..7b3f019 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Database.py +++ b/sopel_modules/SpiceBot_Core_Commands/Database.py @@ -10,6 +10,7 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @sopel.module.nickname_commands('database') def bot_command_database(bot, trigger): bot.osd("Database is " + SpiceBot.config.db_type) diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index 61a06b0..98e3932 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -15,6 +15,7 @@ from word2number import w2n from random import randint +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('module', 'dictcom') @sopel.module.commands('(.*)') def command_dictcom(bot, trigger, botcom): diff --git a/sopel_modules/SpiceBot_Core_Commands/Docs.py b/sopel_modules/SpiceBot_Core_Commands/Docs.py index 8895123..f1d74b4 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Docs.py +++ b/sopel_modules/SpiceBot_Core_Commands/Docs.py @@ -7,10 +7,13 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @sopel.module.nickname_commands('help', 'docs', 'wiki') def bot_command_docs(bot, trigger): - bot.osd(["IRC Modules Repository", - str(SpiceBot.github_dict["url_main"] + - SpiceBot.github_dict["repo_owner"] + "/" + - SpiceBot.github_dict["repo_name"] + - SpiceBot.github_dict["url_path_wiki"])]) + sb_git_url = str( + SpiceBot.github_dict["url_main"] + + SpiceBot.github_dict["repo_owner"] + "/" + + SpiceBot.github_dict["repo_name"] + + SpiceBot.github_dict["url_path_wiki"] + ) + bot.osd(["IRC Modules Repository", sb_git_url]) diff --git a/sopel_modules/SpiceBot_Core_Commands/Gif.py b/sopel_modules/SpiceBot_Core_Commands/Gif.py index c2406c5..9abecb2 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Gif.py +++ b/sopel_modules/SpiceBot_Core_Commands/Gif.py @@ -11,6 +11,7 @@ import spicemanip # TODO custom gif shortcut commands +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('module') @sopel.module.commands('gif') def gif_trigger(bot, trigger, botcom): diff --git a/sopel_modules/SpiceBot_Core_Commands/Messaging.py b/sopel_modules/SpiceBot_Core_Commands/Messaging.py index ce1b295..f9b962f 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Messaging.py +++ b/sopel_modules/SpiceBot_Core_Commands/Messaging.py @@ -9,18 +9,21 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('action') def bot_command_action(bot, trigger, botcom): bot_command_process(bot, trigger) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('notice') def bot_command_notice(bot, trigger, botcom): bot_command_process(bot, trigger) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('privmsg', 'say', 'msg') def bot_command_privmsg(bot, trigger, botcom): diff --git a/sopel_modules/SpiceBot_Core_Commands/Reddit.py b/sopel_modules/SpiceBot_Core_Commands/Reddit.py index 785e2b5..9e91aec 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Reddit.py +++ b/sopel_modules/SpiceBot_Core_Commands/Reddit.py @@ -7,16 +7,23 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @sopel.module.rule(r"""(?:)u/ ( (?:\\/ | [^/])+ ) """) +def bot_command_reddit_user(bot, trigger): + message = SpiceBot.reddit.prerun(trigger) + bot.osd(message) + + +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @sopel.module.rule(r"""(?:)r/ ( (?:\\/ | [^/])+ ) """) -def bot_command_reddit_syntax(bot, trigger): +def bot_command_reddit_subreddit(bot, trigger): message = SpiceBot.reddit.prerun(trigger) bot.osd(message) diff --git a/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py b/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py index 84b96fe..f7883e4 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py +++ b/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py @@ -9,6 +9,7 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('update') def nickname_comand_update(bot, trigger, botcom): @@ -41,6 +42,7 @@ def nickname_comand_update(bot, trigger, botcom): SpiceBot.spicebot_reload(bot, 'SpiceBot_Update', quitmessage) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('restart') def nickname_comand_restart(bot, trigger, botcom): diff --git a/sopel_modules/SpiceBot_Core_Commands/Search.py b/sopel_modules/SpiceBot_Core_Commands/Search.py index d0375f6..efed214 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Search.py +++ b/sopel_modules/SpiceBot_Core_Commands/Search.py @@ -10,6 +10,7 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('module') @sopel.module.commands('search', 'find', 'google', 'lookup') def search_main(bot, trigger, botcom): @@ -26,6 +27,7 @@ def search_main(bot, trigger, botcom): bot.osd(["[Information search for '" + str(searchterm) + "']", str(searchreturn)]) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('module') @sopel.module.commands("where", "whereis") def search_where(bot, trigger, botcom): @@ -42,6 +44,7 @@ def search_where(bot, trigger, botcom): bot.osd(["[Location search for " + str(searchterm) + "]", str(searchreturn)]) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('module') @sopel.module.commands("what", "whatis") def search_what(bot, trigger, botcom): diff --git a/sopel_modules/SpiceBot_Core_Commands/Sherlock.py b/sopel_modules/SpiceBot_Core_Commands/Sherlock.py index 49b22de..9ce4305 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Sherlock.py +++ b/sopel_modules/SpiceBot_Core_Commands/Sherlock.py @@ -9,6 +9,7 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('module') @sopel.module.commands('sherlock', 'username') def bot_command_sherlock(bot, trigger, botcom): diff --git a/sopel_modules/SpiceBot_Core_Commands/Uptime.py b/sopel_modules/SpiceBot_Core_Commands/Uptime.py index a644e37..968866f 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Uptime.py +++ b/sopel_modules/SpiceBot_Core_Commands/Uptime.py @@ -9,6 +9,7 @@ import time import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('uptime') def bot_command_uptime(bot, trigger, botcom): diff --git a/sopel_modules/SpiceBot_Core_Commands/Users.py b/sopel_modules/SpiceBot_Core_Commands/Users.py index bb36e6c..73ad410 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Users.py +++ b/sopel_modules/SpiceBot_Core_Commands/Users.py @@ -8,6 +8,7 @@ import sopel import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('users', 'user') def nickname_comand_users(bot, trigger, botcom):