diff --git a/README.md b/README.md index 47140c4..ea9474b 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,14 @@ SpiceBot aims to run SpiceBot as an IRC service Use at your own risk. Problems are not my faultâ„¢. # Installation +This install assumes you know that you need sopel installed, depending on how bleeding edge you want sopel to be, + +```` +pip3 install sopel>=6.0,<7 +OR +pip3 install git+https://github.com/sopel-irc/sopel@master +```` + ```` git clone https://github.com/SpiceBot/SpiceBot.git cd SpiceBot diff --git a/requirements.txt b/requirements.txt index bb005cf..6aabc4d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -sopel>=6.0,<7 spicemanip>=0.1.6 gitpython fake-useragent diff --git a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py index f6ae1b5..1954150 100644 --- a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py +++ b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py @@ -17,6 +17,10 @@ def setup(bot): pass +def shutdown(bot): + pass + + @sopel.module.nickname_commands('owners', 'owner') def bot_command_owners(bot, trigger): bot_command_process(bot, trigger) diff --git a/sopel_modules/SpiceBot_Botevents/BotEvents.py b/sopel_modules/SpiceBot_Botevents/BotEvents.py index 57db01d..b6f88dd 100644 --- a/sopel_modules/SpiceBot_Botevents/BotEvents.py +++ b/sopel_modules/SpiceBot_Botevents/BotEvents.py @@ -20,6 +20,11 @@ def setup(bot): threading.Thread(target=setup_thread, args=(bot,)).start() +def shutdown(bot): + if "Sopel_BotEvents" in bot.memory: + del bot.memory["Sopel_BotEvents"] + + def setup_thread(bot): if "Sopel_BotEvents" not in bot.memory: bot.memory["Sopel_BotEvents"] = {"loaded": [], "startup": []} diff --git a/sopel_modules/SpiceBot_Channels/Channels.py b/sopel_modules/SpiceBot_Channels/Channels.py index 54dca05..c181b53 100644 --- a/sopel_modules/SpiceBot_Channels/Channels.py +++ b/sopel_modules/SpiceBot_Channels/Channels.py @@ -51,6 +51,11 @@ def setup(bot): bot.memory['SpiceBot_Channels']['ProcessLock'] = False +def shutdown(bot): + if "SpiceBot_Channels" in bot.memory: + del bot.memory["SpiceBot_Channels"] + + @sopel.module.event('001') @sopel.module.rule('.*') def trigger_channel_list_initial(bot, trigger): @@ -132,7 +137,7 @@ def watch_chanlist_complete(bot, trigger): @sopel.module.nickname_commands('channels', 'channel') -def nickname_comand_chanstats(bot, trigger): +def nickname_comand_channels(bot, trigger): triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') diff --git a/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py b/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py index 0d3f6fc..0ed520c 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py +++ b/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py @@ -26,6 +26,11 @@ def setup(bot): threading.Thread(target=setup_thread, args=(bot,)).start() +def shutdown(bot): + if "SpiceBot_CommandsQuery" in bot.memory: + del bot.memory["SpiceBot_CommandsQuery"] + + def setup_thread(bot): if 'SpiceBot_CommandsQuery' not in bot.memory: diff --git a/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py b/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py index 7c07129..ad33a4e 100644 --- a/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py +++ b/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py @@ -21,6 +21,10 @@ def setup(bot): SopelDB._create_table = SopelDBCache._create_table +def shutdown(bot): + pass + + class SopelDBCache: """Dynamic Table Creation""" diff --git a/sopel_modules/SpiceBot_Database_Cache/DatabaseCache.py b/sopel_modules/SpiceBot_Database_Cache/DatabaseCache.py index 754d0ed..1811877 100644 --- a/sopel_modules/SpiceBot_Database_Cache/DatabaseCache.py +++ b/sopel_modules/SpiceBot_Database_Cache/DatabaseCache.py @@ -11,3 +11,8 @@ def setup(bot): bot_logging(bot, 'SpiceBot_DatabaseCache', "Setting up Database Cache") if 'SpiceBot_DatabaseCache' not in bot.memory: bot.memory['SpiceBot_DatabaseCache'] = dict() + + +def shutdown(bot): + if "SpiceBot_DatabaseCache" in bot.memory: + del bot.memory["SpiceBot_DatabaseCache"] diff --git a/sopel_modules/SpiceBot_Database_Tools/DatabaseTools.py b/sopel_modules/SpiceBot_Database_Tools/DatabaseTools.py index 816c56f..53242da 100644 --- a/sopel_modules/SpiceBot_Database_Tools/DatabaseTools.py +++ b/sopel_modules/SpiceBot_Database_Tools/DatabaseTools.py @@ -6,6 +6,18 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi import sopel.module +def configure(config): + pass + + +def setup(bot): + pass + + +def shutdown(bot): + pass + + """Dyanmic Table Creation""" diff --git a/sopel_modules/SpiceBot_Docs/Docs.py b/sopel_modules/SpiceBot_Docs/Docs.py index 16b7116..bdda514 100644 --- a/sopel_modules/SpiceBot_Docs/Docs.py +++ b/sopel_modules/SpiceBot_Docs/Docs.py @@ -17,6 +17,10 @@ def setup(bot): pass +def shutdown(bot): + pass + + @sopel.module.nickname_commands('help', 'docs', 'wiki') def bot_command_owners(bot, trigger): bot.osd(["IRC Modules Repository", str(github_dict["url_main"] + github_dict["repo_owner"] + "/" + github_dict["repo_name"] + github_dict["url_path_wiki"])]) diff --git a/sopel_modules/SpiceBot_FriendlyBot/FriendlyBot.py b/sopel_modules/SpiceBot_FriendlyBot/FriendlyBot.py index 12b9431..c0c8086 100644 --- a/sopel_modules/SpiceBot_FriendlyBot/FriendlyBot.py +++ b/sopel_modules/SpiceBot_FriendlyBot/FriendlyBot.py @@ -15,6 +15,10 @@ def setup(bot): pass +def shutdown(bot): + pass + + @sopel.module.rule(r'(?i)(hi|hello|hey),? $nickname[ \t]*$') def bot_command_hello(bot, trigger): hello = spicemanip.main(['Hi', 'Hey', 'Hello'], "random") diff --git a/sopel_modules/SpiceBot_Gender/Gender.py b/sopel_modules/SpiceBot_Gender/Gender.py index 8069f0d..f74655d 100644 --- a/sopel_modules/SpiceBot_Gender/Gender.py +++ b/sopel_modules/SpiceBot_Gender/Gender.py @@ -13,6 +13,10 @@ def setup(bot): pass +def shutdown(bot): + pass + + @sopel.module.nickname_commands('gender') def bot_command_gender(bot, trigger): bot.osd("If societal genders are binary, my gender is female") diff --git a/sopel_modules/SpiceBot_GifSearch/gifsearch.py b/sopel_modules/SpiceBot_GifSearch/gifsearch.py index 28f9b69..b6cad11 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifsearch.py +++ b/sopel_modules/SpiceBot_GifSearch/gifsearch.py @@ -57,6 +57,11 @@ def setup(bot): threading.Thread(target=setup_thread, args=(bot,)).start() +def shutdown(bot): + if "SpiceBot_GifSearch" in bot.memory: + del bot.memory["SpiceBot_GifSearch"] + + def setup_thread(bot): startup_bot_event(bot, "SpiceBot_GifSearch") diff --git a/sopel_modules/SpiceBot_InsultHandler/InsultHandler.py b/sopel_modules/SpiceBot_InsultHandler/InsultHandler.py index 724aae4..311ed8e 100644 --- a/sopel_modules/SpiceBot_InsultHandler/InsultHandler.py +++ b/sopel_modules/SpiceBot_InsultHandler/InsultHandler.py @@ -13,6 +13,10 @@ def setup(bot): pass +def shutdown(bot): + pass + + @sopel.module.rule(r'(?i)(Fuck|Screw) (you|off),? $nickname[ \t]*$') def bot_command_srewyou(bot, trigger): bot.osd("Watch your mouth, " + trigger.nick + ", or I'll tell your mother!") diff --git a/sopel_modules/SpiceBot_Logs/Logs.py b/sopel_modules/SpiceBot_Logs/Logs.py index b507710..ebbb12c 100644 --- a/sopel_modules/SpiceBot_Logs/Logs.py +++ b/sopel_modules/SpiceBot_Logs/Logs.py @@ -30,6 +30,13 @@ def setup(bot): bot.memory['SpiceBot_Logs_queue'] = [] +def shutdown(bot): + if "SpiceBot_Logs" in bot.memory: + del bot.memory["SpiceBot_Logs"] + if "SpiceBot_Logs_queue" in bot.memory: + del bot.memory["SpiceBot_Logs_queue"] + + @sopel.module.event('001') @sopel.module.rule('.*') def join_log_channel(bot, trigger): diff --git a/sopel_modules/SpiceBot_Messaging/Messaging.py b/sopel_modules/SpiceBot_Messaging/Messaging.py index 099d356..8b24a0b 100644 --- a/sopel_modules/SpiceBot_Messaging/Messaging.py +++ b/sopel_modules/SpiceBot_Messaging/Messaging.py @@ -17,6 +17,10 @@ def setup(bot): pass +def shutdown(bot): + pass + + @sopel.module.nickname_commands('action') def bot_command_action(bot, trigger): bot_command_process(bot, trigger) diff --git a/sopel_modules/SpiceBot_Restart/Restart.py b/sopel_modules/SpiceBot_Restart/Restart.py index 58baea5..e14c412 100644 --- a/sopel_modules/SpiceBot_Restart/Restart.py +++ b/sopel_modules/SpiceBot_Restart/Restart.py @@ -6,16 +6,22 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi import sopel.module from sopel.config.types import StaticSection, ValidatedAttribute -from sopel_modules.SpiceBot_SBTools import service_manip, bot_logging +from sopel_modules.SpiceBot_SBTools import service_manip, bot_logging, spicebot_reload + + +def shutdown(bot): + pass @sopel.module.nickname_commands('restart') -def nickname_comand_chanstats(bot, trigger): +def nickname_comand_restart(bot, trigger): if not trigger.admin: bot.say("You are not authorized to perform this function.") - bot_logging(bot, 'SpiceBot_Restart', "Received command from " + trigger.nick + " to restart") - bot.osd("Received command from " + trigger.nick + " to restart. Be Back Soon!", bot.channels.keys()) + quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!" + bot_logging(bot, 'SpiceBot_Restart', quitmessage) + bot.osd(quitmessage, bot.channels.keys()) - service_manip(bot, bot.nick, 'restart', 'SpiceBot_Restart') + # service_manip(bot, bot.nick, 'restart', 'SpiceBot_Restart') + spicebot_reload(bot, 'SpiceBot_Restart', quitmessage) diff --git a/sopel_modules/SpiceBot_SBTools/__init__.py b/sopel_modules/SpiceBot_SBTools/__init__.py index b664170..2e3003a 100644 --- a/sopel_modules/SpiceBot_SBTools/__init__.py +++ b/sopel_modules/SpiceBot_SBTools/__init__.py @@ -97,8 +97,7 @@ def bot_logging(bot, logtype, logentry): logmessage = "[" + logtype + "] " + logentry + "" - if bot.config.SpiceBot_Logs.logging_channel: - bot.memory['SpiceBot_Logs_queue'].append(logmessage) + bot.memory['SpiceBot_Logs_queue'].append(logmessage) stderr("\n" + logmessage + "\n") @@ -252,6 +251,13 @@ def channel_list_current(bot): """Environment Functions""" +def spicebot_reload(bot, log_from='service_manip', quitmessage='Recieved QUIT'): + # service_manip(bot, bot.nick, 'restart', log_from) + # bot.reload_plugins() + # bot.write(('NOTICE', bot.nick), '001 Foo :Hello') + bot.restart(quitmessage) + + def service_manip(bot, servicename, dowhat, log_from='service_manip'): if str(dowhat) not in ["start", "stop", "restart"]: return diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py index ef27a1a..f86d971 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py @@ -18,6 +18,10 @@ def setup(bot): pass +def shutdown(bot): + pass + + @module.event('001') @module.rule('.*') @module.thread(True) diff --git a/sopel_modules/SpiceBot_Update/Update.py b/sopel_modules/SpiceBot_Update/Update.py index c137b5c..991c54e 100644 --- a/sopel_modules/SpiceBot_Update/Update.py +++ b/sopel_modules/SpiceBot_Update/Update.py @@ -7,10 +7,11 @@ import sopel.module from sopel.config.types import StaticSection, ValidatedAttribute import os +import pip import spicemanip -from sopel_modules.SpiceBot_SBTools import service_manip, sopel_triggerargs, command_permissions_check, bot_logging +from sopel_modules.SpiceBot_SBTools import service_manip, sopel_triggerargs, command_permissions_check, bot_logging, spicebot_reload class SpiceBot_Update_MainSection(StaticSection): @@ -29,8 +30,12 @@ def setup(bot): bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) +def shutdown(bot): + pass + + @sopel.module.nickname_commands('update') -def nickname_comand_chanstats(bot, trigger): +def nickname_comand_update(bot, trigger): 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.") @@ -49,21 +54,23 @@ def nickname_comand_chanstats(bot, trigger): triggerargs = spicemanip.main(triggerargs, '2+', 'list') - bot_logging(bot, 'SpiceBot_Update', "Received command from " + trigger.nick + " to update from Github and restart") - bot.osd("Received command from " + trigger.nick + " to update from Github and restart. Be Back Soon!", bot.channels.keys()) + quitmessage = "Received command from " + trigger.nick + " to update from Github and restart" + bot_logging(bot, 'SpiceBot_Update', quitmessage) + bot.osd(quitmessage, bot.channels.keys()) if commandused == 'nodeps': - spicebot_update(bot, "False") + spicebot_update(bot, False) if commandused == 'deps': - spicebot_update(bot, "True") + spicebot_update(bot, True) - service_manip(bot, bot.nick, 'restart', 'SpiceBot_Update') + # service_manip(bot, bot.nick, 'restart', 'SpiceBot_Update') + spicebot_reload(bot, 'SpiceBot_Update', quitmessage) -def spicebot_update(bot, deps="False"): +def spicebot_update(bot, deps=False): pipcommand = "sudo pip3 install --upgrade" - if deps == "False": + if not deps: pipcommand += " --no-deps" pipcommand += " --force-reinstall" pipcommand += " git+" + str(bot.config.SpiceBot_Update.gitrepo) + "@" + str(bot.config.SpiceBot_Update.gitbranch) @@ -72,6 +79,11 @@ def spicebot_update(bot, deps="False"): for line in os.popen(pipcommand).read().split('\n'): bot_logging(bot, 'SpiceBot_Update', " " + line) + stock_modules_begone(bot) + + +def stock_modules_begone(bot): + # Remove stock modules, if present main_sopel_dir = os.path.dirname(os.path.abspath(sopel.__file__)) modules_dir = os.path.join(main_sopel_dir, 'modules') diff --git a/sopel_modules/SpiceBot_Uptime/Uptime.py b/sopel_modules/SpiceBot_Uptime/Uptime.py index 1e56e13..81ba858 100644 --- a/sopel_modules/SpiceBot_Uptime/Uptime.py +++ b/sopel_modules/SpiceBot_Uptime/Uptime.py @@ -22,6 +22,11 @@ def setup(bot): bot.memory["SpiceBot_Uptime"] = now +def shutdown(bot): + if "SpiceBot_Uptime" in bot.memory: + del bot.memory["SpiceBot_Uptime"] + + @sopel.module.nickname_commands('uptime') def bot_command_srewyou(bot, trigger): timesince = str(humanized_time(time.time() - bot.memory["SpiceBot_Uptime"])) + " ago." diff --git a/sopel_modules/SpiceBot_osd/__init__.py b/sopel_modules/SpiceBot_osd/__init__.py index 92c3810..8c4bbbb 100644 --- a/sopel_modules/SpiceBot_osd/__init__.py +++ b/sopel_modules/SpiceBot_osd/__init__.py @@ -37,23 +37,27 @@ def setup(bot): # Inject OSD bot_logging(bot, 'SpiceBot_OSD', "Implanting OSD function into bot") bot.osd = SopelOSD.osd - bot.SopelWrapper.osd = SopelOSD.SopelWrapper.osd + sopel.bot.SopelWrapper.osd = SopelOSD.SopelWrapper.osd tools.get_available_message_bytes = ToolsOSD.get_available_message_bytes tools.get_sendable_message_list = ToolsOSD.get_sendable_message_list tools.get_message_recipientgroups = ToolsOSD.get_message_recipientgroups # overwrite default bot messaging bot_logging(bot, 'SpiceBot_OSD', "Overwrite Default Sopel messaging commands") - bot.SopelWrapper.say = SopelOSD.SopelWrapper.say - bot.SopelWrapper.action = SopelOSD.SopelWrapper.action - bot.SopelWrapper.notice = SopelOSD.SopelWrapper.notice - bot.SopelWrapper.reply = SopelOSD.SopelWrapper.reply + sopel.bot.SopelWrapper.say = SopelOSD.SopelWrapper.say + sopel.bot.SopelWrapper.action = SopelOSD.SopelWrapper.action + sopel.bot.SopelWrapper.notice = SopelOSD.SopelWrapper.notice + sopel.bot.SopelWrapper.reply = SopelOSD.SopelWrapper.reply # verify config settings for server bot_logging(bot, 'SpiceBot_OSD', "Checking for config settings") bot.config.define_section("MAXTARGCONFIG", MAXTARGCONFIG, validate=False) +def shutdown(bot): + pass + + # RPL_ISUPPORT = '005' @module.event('005') @module.rule('.*')