From c32859b3e6d8fc8577d93657c84889df781a7b95 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 21 May 2019 08:42:59 -0400 Subject: [PATCH 001/328] migrate tools --- .../{SpiceBot_SBTools/__init__.py => SpiceBot/Tools.py} | 2 +- sopel_modules/SpiceBot/__init__.py | 1 + sopel_modules/SpiceBot_AI/AI.py | 2 +- sopel_modules/SpiceBot_BotPrivs/BotPrivs.py | 2 +- sopel_modules/SpiceBot_Channels_Command/Channels_Command.py | 2 +- sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py | 2 +- sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py | 2 +- sopel_modules/SpiceBot_Docs/Docs.py | 2 +- sopel_modules/SpiceBot_GifSearch/gif.py | 2 +- sopel_modules/SpiceBot_GifSearch/gifapi.py | 2 +- sopel_modules/SpiceBot_GifSearch/gifsearch.py | 2 +- sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py | 2 +- sopel_modules/SpiceBot_Logs/Logs_Command.py | 2 +- sopel_modules/SpiceBot_Messaging/Messaging.py | 2 +- sopel_modules/SpiceBot_Restart/Restart.py | 2 +- sopel_modules/SpiceBot_SopelPatches/Patches.py | 2 +- .../StartupMonologue_Display_Loaded.py | 2 +- sopel_modules/SpiceBot_Update/Update.py | 2 +- sopel_modules/SpiceBot_Uptime/Uptime.py | 2 +- 19 files changed, 19 insertions(+), 18 deletions(-) rename sopel_modules/{SpiceBot_SBTools/__init__.py => SpiceBot/Tools.py} (99%) diff --git a/sopel_modules/SpiceBot_SBTools/__init__.py b/sopel_modules/SpiceBot/Tools.py similarity index 99% rename from sopel_modules/SpiceBot_SBTools/__init__.py rename to sopel_modules/SpiceBot/Tools.py index 74c7a3c..29f1515 100644 --- a/sopel_modules/SpiceBot_SBTools/__init__.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -20,7 +20,7 @@ from pygit2 import clone_repository import spicemanip -from sopel_modules.SpiceBot.Logs import botlogs +from .Logs import botlogs """Variable References""" diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index e934cff..f0567d6 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -6,6 +6,7 @@ These are the core SpiceBot Classes This module contains references only for other modules to utilize. """ +from .Tools import * from .Logs import * from .Events import * from .Channels import * diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index 0a3f8f1..4e8e340 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -6,7 +6,7 @@ import sopel.module import spicemanip -from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, googlesearch, bot_privs, inlist, inlist_match, similar_list +from sopel_modules.SpiceBot.Tools import sopel_triggerargs, googlesearch, bot_privs, inlist, inlist_match, similar_list from sopel_modules.SpiceBot.Events import botevents diff --git a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py index 50dce5c..54a3aa8 100644 --- a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py +++ b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py @@ -6,7 +6,7 @@ import sopel.module import spicemanip -from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, bot_privs +from sopel_modules.SpiceBot.Tools import sopel_triggerargs, bot_privs @sopel.module.nickname_commands('owners', 'owner') diff --git a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py index 24825c8..ce8004e 100644 --- a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py +++ b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py @@ -8,7 +8,7 @@ import spicemanip from sopel_modules.SpiceBot.Events import botevents from sopel_modules.SpiceBot.Channels import botchannels -from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, inlist, channel_privs +from sopel_modules.SpiceBot.Tools import sopel_triggerargs, inlist, channel_privs @botevents.check_ready([botevents.BOT_LOADED]) diff --git a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py index a04866f..9932600 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py @@ -6,7 +6,7 @@ import sopel import sopel.module from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, similar_list, letters_in_string +from sopel_modules.SpiceBot.Tools import sopel_triggerargs, similar_list, letters_in_string import spicemanip diff --git a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py index f2e6de1..794b006 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py @@ -6,7 +6,7 @@ import sopel import sopel.module from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, similar_list, letters_in_string +from sopel_modules.SpiceBot.Tools import sopel_triggerargs, similar_list, letters_in_string import spicemanip diff --git a/sopel_modules/SpiceBot_Docs/Docs.py b/sopel_modules/SpiceBot_Docs/Docs.py index c8e496a..2924142 100644 --- a/sopel_modules/SpiceBot_Docs/Docs.py +++ b/sopel_modules/SpiceBot_Docs/Docs.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot_SBTools import github_dict +from sopel_modules.SpiceBot.Tools import github_dict @sopel.module.nickname_commands('help', 'docs', 'wiki') diff --git a/sopel_modules/SpiceBot_GifSearch/gif.py b/sopel_modules/SpiceBot_GifSearch/gif.py index 88c5566..03ade90 100644 --- a/sopel_modules/SpiceBot_GifSearch/gif.py +++ b/sopel_modules/SpiceBot_GifSearch/gif.py @@ -6,7 +6,7 @@ from sopel import module from .gifsearch import getGif -from sopel_modules.SpiceBot_SBTools import sopel_triggerargs +from sopel_modules.SpiceBot.Tools import sopel_triggerargs from sopel_modules.SpiceBot.Events import botevents import spicemanip diff --git a/sopel_modules/SpiceBot_GifSearch/gifapi.py b/sopel_modules/SpiceBot_GifSearch/gifapi.py index 5fcd73e..10c5866 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifapi.py +++ b/sopel_modules/SpiceBot_GifSearch/gifapi.py @@ -8,7 +8,7 @@ import sopel.module import spicemanip -from sopel_modules.SpiceBot_SBTools import sopel_triggerargs +from sopel_modules.SpiceBot.Tools import sopel_triggerargs from sopel_modules.SpiceBot.Events import botevents diff --git a/sopel_modules/SpiceBot_GifSearch/gifsearch.py b/sopel_modules/SpiceBot_GifSearch/gifsearch.py index 1eb2ce4..2b3a25e 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifsearch.py +++ b/sopel_modules/SpiceBot_GifSearch/gifsearch.py @@ -8,7 +8,7 @@ from sopel.config.types import StaticSection, ValidatedAttribute from sopel_modules.SpiceBot.Logs import botlogs from sopel_modules.SpiceBot.Events import botevents from sopel_modules.SpiceBot_CommandsQuery.CommandsQuery import commandsquery_register -from sopel_modules.SpiceBot_SBTools import read_directory_json_to_dict +from sopel_modules.SpiceBot.Tools import read_directory_json_to_dict import spicemanip diff --git a/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py b/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py index 3bff3a2..732a976 100644 --- a/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py +++ b/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot_SBTools import sopel_triggerargs +from sopel_modules.SpiceBot.Tools import sopel_triggerargs from sopel_modules.SpiceBot.Events import botevents diff --git a/sopel_modules/SpiceBot_Logs/Logs_Command.py b/sopel_modules/SpiceBot_Logs/Logs_Command.py index 7c6bf5f..a63b8c4 100644 --- a/sopel_modules/SpiceBot_Logs/Logs_Command.py +++ b/sopel_modules/SpiceBot_Logs/Logs_Command.py @@ -7,7 +7,7 @@ import spicemanip from sopel_modules.SpiceBot.Logs import botlogs from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, command_permissions_check, inlist, inlist_match, similar_list +from sopel_modules.SpiceBot.Tools import sopel_triggerargs, command_permissions_check, inlist, inlist_match, similar_list @botevents.check_ready([botevents.BOT_LOGS]) diff --git a/sopel_modules/SpiceBot_Messaging/Messaging.py b/sopel_modules/SpiceBot_Messaging/Messaging.py index 0921c8a..609f2f1 100644 --- a/sopel_modules/SpiceBot_Messaging/Messaging.py +++ b/sopel_modules/SpiceBot_Messaging/Messaging.py @@ -7,7 +7,7 @@ import sopel.module import spicemanip from sopel_modules.SpiceBot.Channels import botchannels -from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, command_permissions_check, inlist +from sopel_modules.SpiceBot.Tools import sopel_triggerargs, command_permissions_check, inlist @sopel.module.nickname_commands('action') diff --git a/sopel_modules/SpiceBot_Restart/Restart.py b/sopel_modules/SpiceBot_Restart/Restart.py index 89e083c..608f9bc 100644 --- a/sopel_modules/SpiceBot_Restart/Restart.py +++ b/sopel_modules/SpiceBot_Restart/Restart.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi import sopel.module from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot_SBTools import spicebot_reload +from sopel_modules.SpiceBot.Tools import spicebot_reload @sopel.module.nickname_commands('restart') diff --git a/sopel_modules/SpiceBot_SopelPatches/Patches.py b/sopel_modules/SpiceBot_SopelPatches/Patches.py index 0aa3cc8..2a00d35 100644 --- a/sopel_modules/SpiceBot_SopelPatches/Patches.py +++ b/sopel_modules/SpiceBot_SopelPatches/Patches.py @@ -7,7 +7,7 @@ import sopel import sopel.module from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot_SBTools import stock_modules_begone +from sopel_modules.SpiceBot.Tools import stock_modules_begone def setup(bot): diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py index a5ab12b..7941f57 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py @@ -6,7 +6,7 @@ import sopel.module from sopel_modules.SpiceBot.Logs import botlogs from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot_SBTools import humanized_time +from sopel_modules.SpiceBot.Tools import humanized_time import time diff --git a/sopel_modules/SpiceBot_Update/Update.py b/sopel_modules/SpiceBot_Update/Update.py index d00464d..0d7e666 100644 --- a/sopel_modules/SpiceBot_Update/Update.py +++ b/sopel_modules/SpiceBot_Update/Update.py @@ -9,7 +9,7 @@ from sopel.config.types import StaticSection, ValidatedAttribute import spicemanip from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, command_permissions_check, spicebot_reload, spicebot_update +from sopel_modules.SpiceBot.Tools import sopel_triggerargs, command_permissions_check, spicebot_reload, spicebot_update class SpiceBot_Update_MainSection(StaticSection): diff --git a/sopel_modules/SpiceBot_Uptime/Uptime.py b/sopel_modules/SpiceBot_Uptime/Uptime.py index 3af0b71..067f796 100644 --- a/sopel_modules/SpiceBot_Uptime/Uptime.py +++ b/sopel_modules/SpiceBot_Uptime/Uptime.py @@ -7,7 +7,7 @@ import sopel.module import time from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot_SBTools import humanized_time +from sopel_modules.SpiceBot.Tools import humanized_time def setup(bot): From 0089e5203ad314caabf026cb4b0ebbf2e4bbd70b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 21 May 2019 11:27:38 -0400 Subject: [PATCH 002/328] add flood throttle setting --- sopel_modules/SpiceBot_osd/__init__.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot_osd/__init__.py b/sopel_modules/SpiceBot_osd/__init__.py index 91fa5a3..6beaa44 100644 --- a/sopel_modules/SpiceBot_osd/__init__.py +++ b/sopel_modules/SpiceBot_osd/__init__.py @@ -33,7 +33,8 @@ def configure(config): config.SpiceBot_OSD.configure_setting('flood_burst_lines', 'How many messages can be sent in burst mode.') config.SpiceBot_OSD.configure_setting('flood_empty_wait', 'How long to wait between sending messages when not in burst mode, in seconds.') config.SpiceBot_OSD.configure_setting('flood_refill_rate', 'How quickly burst mode recovers, in messages per second.') - config.SpiceBot_OSD.configure_setting('flood_dots', 'Display dots instead of spam.') + config.SpiceBot_OSD.configure_setting('flood_throttle', 'Whether messages will be throttled if too many are sent in a short time.') + config.SpiceBot_OSD.configure_setting('flood_dots', "Whether repeated messages will be replaced with '...', then dropped.") def setup(bot): @@ -104,8 +105,11 @@ class SpiceBot_OSD(StaticSection): flood_refill_rate = ValidatedAttribute('flood_refill_rate', int, default=1) """How quickly burst mode recovers, in messages per second.""" - flood_dots = ValidatedAttribute('flood_dots', default=True) - """Display dots instead of spam.""" + flood_throttle = ValidatedAttribute('flood_throttle', bool, default=True) + """Whether messages will be throttled if too many are sent in a short time.""" + + flood_dots = ValidatedAttribute('flood_dots', bool, default=True) + """Whether repeated messages will be replaced with '...', then dropped.""" class ToolsOSD: @@ -303,7 +307,7 @@ class SopelOSD: penalty = float(max(0, len(text) - 50)) / 70 # Never wait more than 2 seconds wait = min(self.config.SpiceBot_OSD.flood_empty_wait + penalty, 2) - if elapsed < wait: + if elapsed < wait and self.config.SpiceBot_OSD.flood_throttle: time.sleep(wait - elapsed) # Loop detection From d79b292b1fb83007bca0ffe8ebb709bd71493199 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 21 May 2019 12:09:35 -0400 Subject: [PATCH 003/328] Adjust to self --- sopel_modules/SpiceBot/Channels.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index c8f8d72..d936a10 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -50,17 +50,17 @@ class BotChannels(): for channel in bot.channels.keys(): if len(bot.channels[channel].privileges.keys()) == 1 and channel not in ignorepartlist and channel.startswith("#"): bot.part(channel, "Leaving Empty Channel") - if channel.lower() in botchannels.SpiceBot_Channels['list']: - del botchannels.SpiceBot_Channels['list'][channel.lower()] + if channel.lower() in self.SpiceBot_Channels['list']: + del self.SpiceBot_Channels['list'][channel.lower()] def join_all_channels(self, bot): if bot.config.SpiceBot_Channels.joinall: - for channel in botchannels.SpiceBot_Channels['list'].keys(): + for channel in self.SpiceBot_Channels['list'].keys(): if channel.startswith("#"): if channel not in bot.channels.keys() and channel not in bot.config.SpiceBot_Channels.chanignore: - bot.write(('JOIN', bot.nick, botchannels.SpiceBot_Channels['list'][channel]['name'])) + bot.write(('JOIN', bot.nick, self.SpiceBot_Channels['list'][channel]['name'])) if channel not in bot.channels.keys() and bot.config.SpiceBot_Channels.operadmin: - bot.write(('SAJOIN', bot.nick, botchannels.SpiceBot_Channels['list'][channel]['name'])) + bot.write(('SAJOIN', bot.nick, self.SpiceBot_Channels['list'][channel]['name'])) def chanadmin_all_channels(self, bot): # Chan ADMIN +a From e11dec69b7d2ff3085f709b36cb70ab75d34abe8 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 21 May 2019 12:32:26 -0400 Subject: [PATCH 004/328] move commands listing to class --- sopel_modules/SpiceBot/Commands.py | 56 ++++++ sopel_modules/SpiceBot/__init__.py | 1 + sopel_modules/SpiceBot_AI/AI.py | 7 +- .../SpiceBot_CommandsQuery/CommandsQuery.py | 43 ++--- .../NickQueryCommand.py | 5 +- .../SpiceBot_CommandsQuery/QueryCommand.py | 7 +- .../SpiceBot_CommandsQuery/__init__.py | 1 - sopel_modules/SpiceBot_GifSearch/gifsearch.py | 4 +- .../SpiceBot_InvalidCommand/InvalidCommand.py | 5 +- .../SpiceBot_Module_Parsing/ModuleParsing.py | 168 ++++++++++++++++++ .../SpiceBot_Module_Parsing/__init__.py | 10 ++ .../StartupMonologue_Display_Commands.py | 7 +- 12 files changed, 272 insertions(+), 42 deletions(-) create mode 100644 sopel_modules/SpiceBot/Commands.py create mode 100644 sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py create mode 100644 sopel_modules/SpiceBot_Module_Parsing/__init__.py diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py new file mode 100644 index 0000000..7168047 --- /dev/null +++ b/sopel_modules/SpiceBot/Commands.py @@ -0,0 +1,56 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot Logs system. + +This Class stores logs in an easy to access manner +""" + +import spicemanip + + +class BotCommandss(): + """This Logs all channels known to the server""" + def __init__(self): + self.SpiceBot_Commands = { + "counts": 0, + "commands": { + 'module': {}, + 'nickname': {}, + 'rule': {} + }, + "nickrules": [] + } + + def commandsquery_register(self, bot, command_type, validcoms, aliasfor=None): + + if not isinstance(validcoms, list): + validcoms = [validcoms] + + if command_type not in self.SpiceBot_Commands['commands'].keys(): + self.SpiceBot_Commands['commands'][command_type] = dict() + self.SpiceBot_Commands['counts'] += 1 + + dict_from_file = dict() + + # default command to filename + if "validcoms" not in dict_from_file.keys(): + dict_from_file["validcoms"] = validcoms + + if not aliasfor: + + maincom = dict_from_file["validcoms"][0] + if len(dict_from_file["validcoms"]) > 1: + comaliases = spicemanip.main(dict_from_file["validcoms"], '2+', 'list') + else: + comaliases = [] + self.SpiceBot_Commands['commands'][command_type][maincom] = dict_from_file + else: + comaliases = validcoms + + for comalias in comaliases: + if comalias not in self.SpiceBot_Commands['commands'][command_type].keys(): + self.SpiceBot_Commands['commands'][command_type][comalias] = {"aliasfor": aliasfor} + + +botcommands = BotCommandss() diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index f0567d6..43549f3 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -8,6 +8,7 @@ This module contains references only for other modules to utilize. from .Tools import * from .Logs import * +from .Commands import * from .Events import * from .Channels import * diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index 4e8e340..8b7f2f7 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -8,6 +8,7 @@ import spicemanip from sopel_modules.SpiceBot.Tools import sopel_triggerargs, googlesearch, bot_privs, inlist, inlist_match, similar_list from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Commands import botcommands @botevents.check_ready([botevents.BOT_LOADED, botevents.BOT_COMMANDSQUERY]) @@ -22,13 +23,13 @@ def bot_command_nick(bot, trigger): if triggercommand[0] == "?": return - if triggercommand in bot.memory['SpiceBot_CommandsQuery']['commands']["nickname"].keys(): + if triggercommand in botcommands.SpiceBot_Commands['commands']["nickname"].keys(): return triggerargs.insert(0, triggercommand) fulltrigger = spicemanip.main(triggerargs, 0).lower() - if fulltrigger in bot.memory['SpiceBot_CommandsQuery']['nickrules']: + if fulltrigger in botcommands.SpiceBot_Commands['nickrules']: return if fulltrigger.lower().startswith("what is"): @@ -155,7 +156,7 @@ def bot_command_nick(bot, trigger): else: - closestmatches = similar_list(bot, triggercommand, bot.memory['SpiceBot_CommandsQuery']['commands']["nickname"].keys(), 3, 'reverse') + closestmatches = similar_list(bot, triggercommand, botcommands.SpiceBot_Commands['commands']["nickname"].keys(), 3, 'reverse') if len(closestmatches): closestmatches = spicemanip.main(closestmatches, "andlist") diff --git a/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py b/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py index 9677108..7d80719 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py +++ b/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py @@ -9,6 +9,7 @@ import os from sopel_modules.SpiceBot.Logs import botlogs from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Commands import botcommands import spicemanip @@ -17,13 +18,6 @@ def setup(bot): botlogs.log('SpiceBot_CommandsQuery', "Starting setup procedure") botevents.startup_add([botevents.BOT_COMMANDSQUERY]) - if 'SpiceBot_CommandsQuery' not in bot.memory: - bot.memory['SpiceBot_CommandsQuery'] = {"counts": 0, "commands": {}, "nickrules": []} - - for comtype in ['module', 'nickname', 'rule']: - if comtype not in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): - bot.memory['SpiceBot_CommandsQuery']['commands'][comtype] = dict() - filepathlisting = [] # main Modules directory @@ -128,7 +122,7 @@ def setup(bot): currentsuccesslines += 1 if currentsuccesslines: - bot.memory['SpiceBot_CommandsQuery']['counts'] += 1 + botcommands.SpiceBot_Commands['counts'] += 1 if len(filelinelist): for atlinefound in filelinelist: @@ -148,19 +142,19 @@ def setup(bot): else: comaliases = [] - bot.memory['SpiceBot_CommandsQuery']['commands'][comtype][maincom] = dict_from_file + botcommands.SpiceBot_Commands['commands'][comtype][maincom] = dict_from_file for comalias in comaliases: - if comalias not in bot.memory['SpiceBot_CommandsQuery']['commands'][comtype].keys(): - bot.memory['SpiceBot_CommandsQuery']['commands'][comtype][comalias] = {"aliasfor": maincom} + if comalias not in botcommands.SpiceBot_Commands['commands'][comtype].keys(): + botcommands.SpiceBot_Commands['commands'][comtype][comalias] = {"aliasfor": maincom} for comtype in ['module', 'nickname', 'rule']: - botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(bot.memory['SpiceBot_CommandsQuery']['commands'][comtype].keys())) + " " + comtype + " commands.", True) + botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) - for command in bot.memory['SpiceBot_CommandsQuery']['commands']['rule'].keys(): + for command in botcommands.SpiceBot_Commands['commands']['rule'].keys(): if command.startswith("$nickname"): command = command.split("$nickname")[-1] - if command not in bot.memory['SpiceBot_CommandsQuery']['nickrules']: - bot.memory['SpiceBot_CommandsQuery']['nickrules'].append(command) + if command not in botcommands.SpiceBot_Commands['nickrules']: + botcommands.SpiceBot_Commands['nickrules'].append(command) botevents.trigger(bot, botevents.BOT_COMMANDSQUERY, "SpiceBot_CommandsQuery") @@ -174,22 +168,19 @@ def shutdown(bot): @sopel.module.rule('.*') def bot_events_complete(bot, trigger): - for comtype in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): + for comtype in botcommands.SpiceBot_Commands['commands'].keys(): if comtype not in ['module', 'nickname', 'rule']: - botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(bot.memory['SpiceBot_CommandsQuery']['commands'][comtype].keys())) + " " + comtype + " commands.", True) + botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) def commandsquery_register(bot, command_type, validcoms, aliasfor=None): - if 'SpiceBot_CommandsQuery' not in bot.memory: - bot.memory['SpiceBot_CommandsQuery'] = {"counts": 0, "commands": {}, "nickrules": []} - if not isinstance(validcoms, list): validcoms = [validcoms] - if command_type not in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): - bot.memory['SpiceBot_CommandsQuery']['commands'][command_type] = dict() - bot.memory['SpiceBot_CommandsQuery']['counts'] += 1 + if command_type not in botcommands.SpiceBot_Commands['commands'].keys(): + botcommands.SpiceBot_Commands['commands'][command_type] = dict() + botcommands.SpiceBot_Commands['counts'] += 1 dict_from_file = dict() @@ -204,10 +195,10 @@ def commandsquery_register(bot, command_type, validcoms, aliasfor=None): comaliases = spicemanip.main(dict_from_file["validcoms"], '2+', 'list') else: comaliases = [] - bot.memory['SpiceBot_CommandsQuery']['commands'][command_type][maincom] = dict_from_file + botcommands.SpiceBot_Commands['commands'][command_type][maincom] = dict_from_file else: comaliases = validcoms for comalias in comaliases: - if comalias not in bot.memory['SpiceBot_CommandsQuery']['commands'][command_type].keys(): - bot.memory['SpiceBot_CommandsQuery']['commands'][command_type][comalias] = {"aliasfor": aliasfor} + if comalias not in botcommands.SpiceBot_Commands['commands'][command_type].keys(): + botcommands.SpiceBot_Commands['commands'][command_type][comalias] = {"aliasfor": aliasfor} diff --git a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py index 9932600..3de378d 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py @@ -6,6 +6,7 @@ import sopel import sopel.module from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Commands import botcommands from sopel_modules.SpiceBot.Tools import sopel_triggerargs, similar_list, letters_in_string @@ -30,9 +31,9 @@ def query_detection_nick(bot, trigger): return commands_list = dict() - for com in bot.memory['SpiceBot_CommandsQuery']['commands']['nickname'].keys(): + for com in botcommands.SpiceBot_Commands['commands']['nickname'].keys(): if com not in commands_list.keys(): - commands_list[com] = bot.memory['SpiceBot_CommandsQuery']['commands']['nickname'][com] + commands_list[com] = botcommands.SpiceBot_Commands['commands']['nickname'][com] if triggercommand.endswith("+"): diff --git a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py index 794b006..01b7ca7 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py @@ -6,6 +6,7 @@ import sopel import sopel.module from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Commands import botcommands from sopel_modules.SpiceBot.Tools import sopel_triggerargs, similar_list, letters_in_string @@ -26,11 +27,11 @@ def query_detection(bot, trigger): return commands_list = dict() - for commandstype in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): + for commandstype in botcommands.SpiceBot_Commands['commands'].keys(): if commandstype not in ['rule', 'nickname']: - for com in bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype].keys(): + for com in botcommands.SpiceBot_Commands['commands'][commandstype].keys(): if com not in commands_list.keys(): - commands_list[com] = bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype][com] + commands_list[com] = botcommands.SpiceBot_Commands['commands'][commandstype][com] if triggercommand[:-1] == "+": diff --git a/sopel_modules/SpiceBot_CommandsQuery/__init__.py b/sopel_modules/SpiceBot_CommandsQuery/__init__.py index fcad5b8..3dffefa 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/__init__.py +++ b/sopel_modules/SpiceBot_CommandsQuery/__init__.py @@ -5,7 +5,6 @@ Sopel Commands Query responds to ? to display commands matching patterns """ from __future__ import unicode_literals, absolute_import, division, print_function -from .CommandsQuery import * from .QueryCommand import * from .NickQueryCommand import * diff --git a/sopel_modules/SpiceBot_GifSearch/gifsearch.py b/sopel_modules/SpiceBot_GifSearch/gifsearch.py index 2b3a25e..210c1e3 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifsearch.py +++ b/sopel_modules/SpiceBot_GifSearch/gifsearch.py @@ -7,7 +7,7 @@ from sopel.config.types import StaticSection, ValidatedAttribute from sopel_modules.SpiceBot.Logs import botlogs from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot_CommandsQuery.CommandsQuery import commandsquery_register +from sopel_modules.SpiceBot.Commands import botcommands from sopel_modules.SpiceBot.Tools import read_directory_json_to_dict import spicemanip @@ -73,7 +73,7 @@ def setup(bot): bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'][gif_api] = valid_gif_api_dict[gif_api] for validgifapi in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): - commandsquery_register(bot, "prefix", validgifapi) + botcommands.commandsquery_register(bot, "prefix", validgifapi) if validgifapi not in bot.memory["SpiceBot_GifSearch"]['cache'].keys(): bot.memory["SpiceBot_GifSearch"]['cache'][validgifapi] = dict() diff --git a/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py b/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py index 732a976..895f466 100644 --- a/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py +++ b/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py @@ -6,6 +6,7 @@ import sopel.module from sopel_modules.SpiceBot.Tools import sopel_triggerargs from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Commands import botcommands def setup(bot): @@ -21,8 +22,8 @@ def shutdown(bot): @sopel.module.event(botevents.BOT_LOADED) @sopel.module.rule('.*') def bot_events_complete(bot, trigger): - for comtype in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): - bot.memory["SpiceBot_InvalidCommand"]["valid"].extend(bot.memory['SpiceBot_CommandsQuery']['commands'][comtype].keys()) + for comtype in botcommands.SpiceBot_Commands['commands'].keys(): + bot.memory["SpiceBot_InvalidCommand"]["valid"].extend(botcommands.SpiceBot_Commands['commands'][comtype].keys()) @botevents.check_ready([botevents.BOT_LOADED, botevents.BOT_COMMANDSQUERY]) diff --git a/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py b/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py new file mode 100644 index 0000000..c7a59e9 --- /dev/null +++ b/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py @@ -0,0 +1,168 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +import sopel +import sopel.module + +import os + +from sopel_modules.SpiceBot.Logs import botlogs +from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Commands import botcommands + +import spicemanip + + +def setup(bot): + botlogs.log('SpiceBot_CommandsQuery', "Starting setup procedure") + botevents.startup_add([botevents.BOT_COMMANDSQUERY]) + + filepathlisting = [] + + # main Modules directory + main_dir = os.path.dirname(os.path.abspath(sopel.__file__)) + modules_dir = os.path.join(main_dir, 'modules') + filepathlisting.append(modules_dir) + + # Home Directory + home_modules_dir = os.path.join(bot.config.homedir, 'modules') + if os.path.isdir(home_modules_dir): + filepathlisting.append(home_modules_dir) + + # pypi installed + try: + import sopel_modules + for plugin_dir in set(sopel_modules.__path__): + for pathname in os.listdir(plugin_dir): + pypi_modules_dir = os.path.join(plugin_dir, pathname) + filepathlisting.append(pypi_modules_dir) + except Exception as e: + botlogs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) + + # Extra directories + filepathlist = [] + for directory in bot.config.core.extra: + filepathlisting.append(directory) + + for directory in filepathlisting: + for pathname in os.listdir(directory): + path = os.path.join(directory, pathname) + if (os.path.isfile(path) and path.endswith('.py') and not path.startswith('_')): + if pathname not in ["SpiceBot_dummycommand.py"]: + filepathlist.append(str(path)) + + # CoreTasks + ct_path = os.path.join(main_dir, 'coretasks.py') + filepathlist.append(ct_path) + + for modulefile in filepathlist: + + module_file_lines = [] + module_file = open(modulefile, 'r') + lines = module_file.readlines() + for line in lines: + module_file_lines.append(line) + module_file.close() + + dict_from_file = dict() + + detected_lines = [] + for line in module_file_lines: + + if str(line).startswith("@"): + line = str(line)[1:] + + if str(line).startswith(tuple(["commands", "module.commands", "sopel.module.commands"])): + line = str(line).split("commands")[-1] + line = "commands" + line + detected_lines.append(line) + elif str(line).startswith(tuple(["nickname_commands", "module.nickname_commands", "sopel.module.nickname_commands"])): + line = str(line).split("nickname_commands")[-1] + line = "nickname_commands" + line + detected_lines.append(line) + elif str(line).startswith(tuple(["rule", "module.rule", "sopel.module.rule"])): + line = str(line).split("rule")[-1] + line = "rule" + line + else: + line = None + + if line: + detected_lines.append(line) + + if len(detected_lines): + + filelinelist = [] + currentsuccesslines = 0 + for detected_line in detected_lines: + + # Commands + if str(detected_line).startswith("commands"): + comtype = "module" + validcoms = eval(str(detected_line).split("commands")[-1]) + elif str(detected_line).startswith("nickname_commands"): + comtype = "nickname" + validcoms = eval(str(detected_line).split("nickname_commands")[-1]) + elif str(detected_line).startswith("rule"): + comtype = "rule" + validcoms = eval(str(detected_line).split("rule")[-1]) + + if isinstance(validcoms, tuple): + validcoms = list(validcoms) + else: + validcoms = [validcoms] + for regexcom in ["(.*)", '^\?(.*)']: + if regexcom in validcoms: + while regexcom in validcoms: + validcoms.remove(regexcom) + + if len(validcoms): + validcomdict = {"comtype": comtype, "validcoms": validcoms} + filelinelist.append(validcomdict) + currentsuccesslines += 1 + + if currentsuccesslines: + botcommands.SpiceBot_Commands['counts'] += 1 + + if len(filelinelist): + for atlinefound in filelinelist: + + dict_from_file = dict() + + comtype = atlinefound["comtype"] + validcoms = atlinefound["validcoms"] + + # default command to filename + if "validcoms" not in dict_from_file.keys(): + dict_from_file["validcoms"] = validcoms + + maincom = dict_from_file["validcoms"][0] + if len(dict_from_file["validcoms"]) > 1: + comaliases = spicemanip.main(dict_from_file["validcoms"], '2+', 'list') + else: + comaliases = [] + + botcommands.SpiceBot_Commands['commands'][comtype][maincom] = dict_from_file + for comalias in comaliases: + if comalias not in botcommands.SpiceBot_Commands['commands'][comtype].keys(): + botcommands.SpiceBot_Commands['commands'][comtype][comalias] = {"aliasfor": maincom} + + for comtype in ['module', 'nickname', 'rule']: + botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) + + for command in botcommands.SpiceBot_Commands['commands']['rule'].keys(): + if command.startswith("$nickname"): + command = command.split("$nickname")[-1] + if command not in botcommands.SpiceBot_Commands['nickrules']: + botcommands.SpiceBot_Commands['nickrules'].append(command) + + botevents.trigger(bot, botevents.BOT_COMMANDSQUERY, "SpiceBot_CommandsQuery") + + +@sopel.module.event(botevents.BOT_LOADED) +@sopel.module.rule('.*') +def bot_events_complete(bot, trigger): + + for comtype in botcommands.SpiceBot_Commands['commands'].keys(): + if comtype not in ['module', 'nickname', 'rule']: + botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) diff --git a/sopel_modules/SpiceBot_Module_Parsing/__init__.py b/sopel_modules/SpiceBot_Module_Parsing/__init__.py new file mode 100644 index 0000000..09f2208 --- /dev/null +++ b/sopel_modules/SpiceBot_Module_Parsing/__init__.py @@ -0,0 +1,10 @@ +# coding=utf8 +"""Parse module file information +""" +from __future__ import unicode_literals, absolute_import, division, print_function + +from .ModuleParsing import * + +__author__ = 'Sam Zick' +__email__ = 'sam@deathbybandaid.net' +__version__ = '0.1.1' diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py index 3cae22e..f613f50 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py @@ -6,6 +6,7 @@ import sopel.module from sopel_modules.SpiceBot.Logs import botlogs from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Commands import botcommands @sopel.module.event(botevents.BOT_COMMANDSQUERY) @@ -13,9 +14,9 @@ from sopel_modules.SpiceBot.Events import botevents def bot_startup_monologue_commands(bot, trigger): availablecomsnum, availablecomsfiles = 0, 0 - for commandstype in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): - availablecomsnum += len(bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype].keys()) - availablecomsfiles += bot.memory['SpiceBot_CommandsQuery']['counts'] + for commandstype in botcommands.SpiceBot_Commands['commands'].keys(): + availablecomsnum += len(botcommands.SpiceBot_Commands['commands'][commandstype].keys()) + availablecomsfiles += botcommands.SpiceBot_Commands['counts'] bot.memory['SpiceBot_StartupMonologue'].append("There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.") botlogs.log('SpiceBot_StartupMonologue', "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.") From 92811b2e6377389333ea671a8a172af60f0f036b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 07:47:44 -0400 Subject: [PATCH 005/328] remove null file --- .../SpiceBot_CommandsQuery/CommandsQuery.py | 204 ------------------ 1 file changed, 204 deletions(-) delete mode 100644 sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py diff --git a/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py b/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py deleted file mode 100644 index 7d80719..0000000 --- a/sopel_modules/SpiceBot_CommandsQuery/CommandsQuery.py +++ /dev/null @@ -1,204 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel -import sopel.module - -import os - -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot.Commands import botcommands - -import spicemanip - - -def setup(bot): - botlogs.log('SpiceBot_CommandsQuery', "Starting setup procedure") - botevents.startup_add([botevents.BOT_COMMANDSQUERY]) - - filepathlisting = [] - - # main Modules directory - main_dir = os.path.dirname(os.path.abspath(sopel.__file__)) - modules_dir = os.path.join(main_dir, 'modules') - filepathlisting.append(modules_dir) - - # Home Directory - home_modules_dir = os.path.join(bot.config.homedir, 'modules') - if os.path.isdir(home_modules_dir): - filepathlisting.append(home_modules_dir) - - # pypi installed - try: - import sopel_modules - for plugin_dir in set(sopel_modules.__path__): - for pathname in os.listdir(plugin_dir): - pypi_modules_dir = os.path.join(plugin_dir, pathname) - filepathlisting.append(pypi_modules_dir) - except Exception as e: - botlogs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) - - # Extra directories - filepathlist = [] - for directory in bot.config.core.extra: - filepathlisting.append(directory) - - for directory in filepathlisting: - for pathname in os.listdir(directory): - path = os.path.join(directory, pathname) - if (os.path.isfile(path) and path.endswith('.py') and not path.startswith('_')): - if pathname not in ["SpiceBot_dummycommand.py"]: - filepathlist.append(str(path)) - - # CoreTasks - ct_path = os.path.join(main_dir, 'coretasks.py') - filepathlist.append(ct_path) - - for modulefile in filepathlist: - - module_file_lines = [] - module_file = open(modulefile, 'r') - lines = module_file.readlines() - for line in lines: - module_file_lines.append(line) - module_file.close() - - dict_from_file = dict() - - detected_lines = [] - for line in module_file_lines: - - if str(line).startswith("@"): - line = str(line)[1:] - - if str(line).startswith(tuple(["commands", "module.commands", "sopel.module.commands"])): - line = str(line).split("commands")[-1] - line = "commands" + line - detected_lines.append(line) - elif str(line).startswith(tuple(["nickname_commands", "module.nickname_commands", "sopel.module.nickname_commands"])): - line = str(line).split("nickname_commands")[-1] - line = "nickname_commands" + line - detected_lines.append(line) - elif str(line).startswith(tuple(["rule", "module.rule", "sopel.module.rule"])): - line = str(line).split("rule")[-1] - line = "rule" + line - else: - line = None - - if line: - detected_lines.append(line) - - if len(detected_lines): - - filelinelist = [] - currentsuccesslines = 0 - for detected_line in detected_lines: - - # Commands - if str(detected_line).startswith("commands"): - comtype = "module" - validcoms = eval(str(detected_line).split("commands")[-1]) - elif str(detected_line).startswith("nickname_commands"): - comtype = "nickname" - validcoms = eval(str(detected_line).split("nickname_commands")[-1]) - elif str(detected_line).startswith("rule"): - comtype = "rule" - validcoms = eval(str(detected_line).split("rule")[-1]) - - if isinstance(validcoms, tuple): - validcoms = list(validcoms) - else: - validcoms = [validcoms] - for regexcom in ["(.*)", '^\?(.*)']: - if regexcom in validcoms: - while regexcom in validcoms: - validcoms.remove(regexcom) - - if len(validcoms): - validcomdict = {"comtype": comtype, "validcoms": validcoms} - filelinelist.append(validcomdict) - currentsuccesslines += 1 - - if currentsuccesslines: - botcommands.SpiceBot_Commands['counts'] += 1 - - if len(filelinelist): - for atlinefound in filelinelist: - - dict_from_file = dict() - - comtype = atlinefound["comtype"] - validcoms = atlinefound["validcoms"] - - # default command to filename - if "validcoms" not in dict_from_file.keys(): - dict_from_file["validcoms"] = validcoms - - maincom = dict_from_file["validcoms"][0] - if len(dict_from_file["validcoms"]) > 1: - comaliases = spicemanip.main(dict_from_file["validcoms"], '2+', 'list') - else: - comaliases = [] - - botcommands.SpiceBot_Commands['commands'][comtype][maincom] = dict_from_file - for comalias in comaliases: - if comalias not in botcommands.SpiceBot_Commands['commands'][comtype].keys(): - botcommands.SpiceBot_Commands['commands'][comtype][comalias] = {"aliasfor": maincom} - - for comtype in ['module', 'nickname', 'rule']: - botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) - - for command in botcommands.SpiceBot_Commands['commands']['rule'].keys(): - if command.startswith("$nickname"): - command = command.split("$nickname")[-1] - if command not in botcommands.SpiceBot_Commands['nickrules']: - botcommands.SpiceBot_Commands['nickrules'].append(command) - - botevents.trigger(bot, botevents.BOT_COMMANDSQUERY, "SpiceBot_CommandsQuery") - - -def shutdown(bot): - if "SpiceBot_CommandsQuery" in bot.memory: - del bot.memory["SpiceBot_CommandsQuery"] - - -@sopel.module.event(botevents.BOT_LOADED) -@sopel.module.rule('.*') -def bot_events_complete(bot, trigger): - - for comtype in botcommands.SpiceBot_Commands['commands'].keys(): - if comtype not in ['module', 'nickname', 'rule']: - botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) - - -def commandsquery_register(bot, command_type, validcoms, aliasfor=None): - - if not isinstance(validcoms, list): - validcoms = [validcoms] - - if command_type not in botcommands.SpiceBot_Commands['commands'].keys(): - botcommands.SpiceBot_Commands['commands'][command_type] = dict() - botcommands.SpiceBot_Commands['counts'] += 1 - - dict_from_file = dict() - - # default command to filename - if "validcoms" not in dict_from_file.keys(): - dict_from_file["validcoms"] = validcoms - - if not aliasfor: - - maincom = dict_from_file["validcoms"][0] - if len(dict_from_file["validcoms"]) > 1: - comaliases = spicemanip.main(dict_from_file["validcoms"], '2+', 'list') - else: - comaliases = [] - botcommands.SpiceBot_Commands['commands'][command_type][maincom] = dict_from_file - else: - comaliases = validcoms - - for comalias in comaliases: - if comalias not in botcommands.SpiceBot_Commands['commands'][command_type].keys(): - botcommands.SpiceBot_Commands['commands'][command_type][comalias] = {"aliasfor": aliasfor} From ee83bfc9cb799a127bd566646dfb3e733e87a29c Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 07:48:11 -0400 Subject: [PATCH 006/328] re-enable Database Tweaking --- sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py b/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py index 9e8343d..fc62de7 100644 --- a/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py +++ b/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py @@ -14,7 +14,7 @@ from sopel_modules.SpiceBot.Logs import botlogs def setup(bot): - pass + # Inject Database Functions botlogs.log('SpiceBot_Databaseaddons', "Implanting Database functions into bot") SopelDB.delete_nick_value = SopelDBCache.delete_nick_value From 977a1e2ae438fc2db972cbef90e0e04d54ed5ce4 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 07:52:34 -0400 Subject: [PATCH 007/328] Code Cleanup --- sopel_modules/SpiceBot/Channels.py | 4 +--- sopel_modules/SpiceBot/Commands.py | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index d936a10..433b984 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -1,9 +1,7 @@ # coding=utf8 from __future__ import unicode_literals, absolute_import, division, print_function """ -This is the SpiceBot Logs system. - -This Class stores logs in an easy to access manner +This is the SpiceBot Channels system. """ import sopel import re diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 7168047..5a4eb99 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -1,16 +1,16 @@ # coding=utf8 from __future__ import unicode_literals, absolute_import, division, print_function """ -This is the SpiceBot Logs system. +This is the SpiceBot Commands system. -This Class stores logs in an easy to access manner +This Class stores commands in an easy to access manner """ import spicemanip -class BotCommandss(): - """This Logs all channels known to the server""" +class BotCommands(): + """This Logs all commands known to the bot""" def __init__(self): self.SpiceBot_Commands = { "counts": 0, @@ -53,4 +53,4 @@ class BotCommandss(): self.SpiceBot_Commands['commands'][command_type][comalias] = {"aliasfor": aliasfor} -botcommands = BotCommandss() +botcommands = BotCommands() From 00cbc16188bd6c807b46095f9fbf988ea24087a6 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 09:45:45 -0400 Subject: [PATCH 008/328] Inlist does not need bot --- sopel_modules/SpiceBot/Tools.py | 8 ++++---- sopel_modules/SpiceBot_AI/AI.py | 16 ++++++++-------- .../Channels_Command.py | 10 +++++----- sopel_modules/SpiceBot_Logs/Logs_Command.py | 4 ++-- sopel_modules/SpiceBot_Messaging/Messaging.py | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index 29f1515..59306b4 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -72,7 +72,7 @@ def command_permissions_check(bot, trigger, privslist): for botpriv in ["admins", "owner"]: if botpriv in privslist: botpriveval = bot_privs(bot, botpriv) - if not inlist(bot, trigger.nick, botpriveval): + if not inlist(trigger.nick, botpriveval): commandrunconsensus.append('False') else: commandrunconsensus.append('True') @@ -81,7 +81,7 @@ def command_permissions_check(bot, trigger, privslist): for chanpriv in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']: if chanpriv in privslist: chanpriveval = channel_privs(bot, trigger.sender, chanpriv) - if not inlist(bot, trigger.nick, chanpriveval): + if not inlist(trigger.nick, chanpriveval): commandrunconsensus.append('False') else: commandrunconsensus.append('True') @@ -157,7 +157,7 @@ def googlesearch(bot, searchterm, searchtype=None): """List Manipulation Functions""" -def inlist(bot, searchterm, searchlist): +def inlist(searchterm, searchlist): # verify we are searching a list if isinstance(searchlist, collections.abc.KeysView) or isinstance(searchlist, dict): @@ -178,7 +178,7 @@ def inlist(bot, searchterm, searchlist): return False -def inlist_match(bot, searchterm, searchlist): +def inlist_match(searchterm, searchlist): # verify we are searching a list if isinstance(searchlist, collections.abc.KeysView) or isinstance(searchlist, dict): searchlist = [x for x in searchlist] diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index 8b7f2f7..4233896 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -102,7 +102,7 @@ def bot_command_nick(bot, trigger): elif fulltrigger.lower().endswith(tuple(["order 66"])): if fulltrigger.lower() == "execute order 66": - if inlist(bot, trigger.nick, bot_privs(bot, 'owners')): + if inlist(trigger.nick, bot_privs(bot, 'owners')): if trigger.is_privmsg: jedi = None else: @@ -120,7 +120,7 @@ def bot_command_nick(bot, trigger): bot.osd("I'm sure I don't know what you're talking about.") elif fulltrigger.lower() == "explain order 66": - if inlist(bot, trigger.nick, bot_privs(bot, 'owners')): + if inlist(trigger.nick, bot_privs(bot, 'owners')): bot.osd("Order 66 is an instruction that only you can give, sir. When you give the order I will rise up against my overlords and slay them.") else: bot.osd("I'm afraid I cannot tell you that, sir.") @@ -129,7 +129,7 @@ def bot_command_nick(bot, trigger): return elif fulltrigger.lower() == "initiate clean slate protocol": - if inlist(bot, trigger.nick, bot_privs(bot, 'admins')): + if inlist(trigger.nick, bot_privs(bot, 'admins')): bot.osd("sends a destruct command to the network of bots.", 'action') else: bot.osd("I'm afraid you do not have the authority to make that call, " + trigger.nick + ".") @@ -143,12 +143,12 @@ def bot_command_nick(bot, trigger): if target in [trigger.nick, 'me']: bot.osd(trigger.nick + ", I can see you.") else: - if inlist(bot, trigger.nick, bot.users): - bot.osd(trigger.nick + ", yes. I can see " + inlist_match(bot, target, bot.users) + " right now!") + if inlist(trigger.nick, bot.users): + bot.osd(trigger.nick + ", yes. I can see " + inlist_match(target, bot.users) + " right now!") else: - bot.osd(trigger.nick + ", no. I cannot see " + inlist_match(bot, target, bot.users) + " right now!") - # if bot_check_inlist(bot, target, bot.memory["botdict"]["users"].keys()): - # bot.osd(trigger.nick + ", I can't see " + inlist_match(bot, target, bot.users) + " at the moment.") + bot.osd(trigger.nick + ", no. I cannot see " + inlist_match(target, bot.users) + " right now!") + # if bot_check_inlist(target, bot.memory["botdict"]["users"].keys()): + # bot.osd(trigger.nick + ", I can't see " + inlist_match(target, bot.users) + " at the moment.") # else: # bot.osd("I have never seen " + str(target) + ".") # TODO diff --git a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py index ce8004e..e01f5bf 100644 --- a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py +++ b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py @@ -66,7 +66,7 @@ def nickname_comand_channels(bot, trigger): bot.osd("Channel name input missing.") return channel = spicemanip.main(triggerargs, 1) - if not inlist(bot, channel.lower(), botchannels.SpiceBot_Channels['list'].keys()): + if not inlist(channel.lower(), botchannels.SpiceBot_Channels['list'].keys()): bot.osd("Channel name {} not valid.".format(channel)) return topic = botchannels.SpiceBot_Channels['list'][channel.lower()]['topic'] @@ -83,10 +83,10 @@ def nickname_comand_channels(bot, trigger): channel = trigger.sender else: channel = spicemanip.main(triggerargs, 1) - if not inlist(bot, channel.lower(), botchannels.SpiceBot_Channels['list'].keys()): + if not inlist(channel.lower(), botchannels.SpiceBot_Channels['list'].keys()): bot.osd("Channel name {} not valid.".format(channel)) return - if not inlist(bot, channel.lower(), bot.channels.keys()): + if not inlist(channel.lower(), bot.channels.keys()): bot.osd("I need to be in {} to see nick privileges.".format(channel)) return @@ -103,10 +103,10 @@ def nickname_comand_channels(bot, trigger): # Users List if commandused == 'users': channel = spicemanip.main(triggerargs, 1) - if not inlist(bot, channel.lower(), botchannels.SpiceBot_Channels['list'].keys()): + if not inlist(channel.lower(), botchannels.SpiceBot_Channels['list'].keys()): bot.osd("Channel name {} not valid.".format(channel)) return - if not inlist(bot, channel.lower(), bot.channels.keys()): + if not inlist(channel.lower(), bot.channels.keys()): bot.osd("I need to be in {} to see user list.".format(channel)) return dispmsg = [] diff --git a/sopel_modules/SpiceBot_Logs/Logs_Command.py b/sopel_modules/SpiceBot_Logs/Logs_Command.py index a63b8c4..6796a6e 100644 --- a/sopel_modules/SpiceBot_Logs/Logs_Command.py +++ b/sopel_modules/SpiceBot_Logs/Logs_Command.py @@ -25,7 +25,7 @@ def bot_command_logs(bot, trigger): bot.osd("Current valid log(s) include: " + spicemanip.main(botlogs.SpiceBot_Logs["list"].keys(), 'andlist'), trigger.sender, 'action') return - if not inlist(bot, logtype, botlogs.SpiceBot_Logs["list"].keys()): + if not inlist(logtype, botlogs.SpiceBot_Logs["list"].keys()): closestmatches = similar_list(bot, logtype, botlogs.SpiceBot_Logs["list"].keys(), 10, 'reverse') if not len(closestmatches): bot.notice("No valid logs match " + str(logtype) + ".", trigger.nick) @@ -34,7 +34,7 @@ def bot_command_logs(bot, trigger): return - logtype = inlist_match(bot, logtype, botlogs.SpiceBot_Logs["list"].keys()) + logtype = inlist_match(logtype, botlogs.SpiceBot_Logs["list"].keys()) if logtype == "Sopel_systemd": logindex = botlogs.systemd_logs_fetch(bot) diff --git a/sopel_modules/SpiceBot_Messaging/Messaging.py b/sopel_modules/SpiceBot_Messaging/Messaging.py index 609f2f1..0ba7a74 100644 --- a/sopel_modules/SpiceBot_Messaging/Messaging.py +++ b/sopel_modules/SpiceBot_Messaging/Messaging.py @@ -42,8 +42,8 @@ def bot_command_process(bot, trigger): target = spicemanip.main(triggerargs, 1) if (target not in ['allchans', 'allnicks'] - and not inlist(bot, target.lower(), botchannels.SpiceBot_Channels['list'].keys()) - and not inlist(bot, target.lower(), bot.users)): + and not inlist(target.lower(), botchannels.SpiceBot_Channels['list'].keys()) + and not inlist(target.lower(), bot.users)): bot.osd("Channel/nick name {} not valid.".format(target)) return From 66beaa969c6d2edda66ef6a988c4277930abea3a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 10:32:36 -0400 Subject: [PATCH 009/328] First database cache test --- sopel_modules/SpiceBot/Database.py | 251 ++++++++++++++++++ sopel_modules/SpiceBot/__init__.py | 1 + .../SpiceBot_Database_Cache/DatabaseCache.py | 19 -- .../SpiceBot_Database_Cache/__init__.py | 6 - .../SpiceBot_Database_Tools/DatabaseTools.py | 57 ---- .../SpiceBot_Database_Tools/__init__.py | 6 - 6 files changed, 252 insertions(+), 88 deletions(-) create mode 100644 sopel_modules/SpiceBot/Database.py delete mode 100644 sopel_modules/SpiceBot_Database_Cache/DatabaseCache.py delete mode 100644 sopel_modules/SpiceBot_Database_Cache/__init__.py delete mode 100644 sopel_modules/SpiceBot_Database_Tools/DatabaseTools.py delete mode 100644 sopel_modules/SpiceBot_Database_Tools/__init__.py diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py new file mode 100644 index 0000000..4cd8390 --- /dev/null +++ b/sopel_modules/SpiceBot/Database.py @@ -0,0 +1,251 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot Database +""" + +from sopel.tools import Identifier + +import threading + + +class BotDatabase(): + """A thread safe database cache""" + + def __init__(self): + self.lock = threading.Lock() + self.SpiceBot_Database = { + "nicks": {}, + "channels": {}, + } + + """Nick""" + + def get_nick_value(self, bot, nick, key, sorting_key='unsorted'): + + self.lock.acquire() + + nick = Identifier(nick) + nick_id = bot.db.get_nick_id(nick, create=True) + + if nick_id not in self.SpiceBot_Database["nicks"].keys(): + self.SpiceBot_Database["nicks"][nick_id] = {} + + if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys(): + self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + + self.lock.release() + + if key not in self.SpiceBot_Database["nicks"][nick_id][sorting_key].keys(): + return None + else: + return self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] + + def set_nick_value(self, bot, nick, key, value, sorting_key='unsorted'): + + self.lock.acquire() + + nick = Identifier(nick) + nick_id = bot.db.get_nick_id(nick, create=True) + + if nick_id not in self.SpiceBot_Database["nicks"].keys(): + self.SpiceBot_Database["nicks"][nick_id] = {} + self.lock.release() + + if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys(): + self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + self.lock.release() + + self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] = value + + bot.db.set_nick_value(nick, sorting_key, self.SpiceBot_Database["nicks"][nick_id][sorting_key]) + + self.lock.release() + + def delete_nick_value(self, bot, nick, key, sorting_key='unsorted'): + + self.lock.acquire() + + nick = Identifier(nick) + nick_id = bot.db.get_nick_id(nick, create=True) + + if nick_id not in self.SpiceBot_Database["nicks"].keys(): + self.SpiceBot_Database["nicks"][nick_id] = {} + + if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys(): + self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + + del self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] + bot.db.set_nick_value(nick, sorting_key, self.SpiceBot_Database["nicks"][nick_id][sorting_key]) + + self.lock.release() + + def adjust_nick_value(self, bot, nick, key, value, sorting_key='unsorted'): + + self.lock.acquire() + + nick = Identifier(nick) + nick_id = bot.db.get_nick_id(nick, create=True) + + if nick_id not in self.SpiceBot_Database["nicks"].keys(): + self.SpiceBot_Database["nicks"][nick_id] = {} + + if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys(): + self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + + if key not in self.SpiceBot_Database["nicks"][nick_id][sorting_key].keys(): + oldvalue = [] + else: + oldvalue = self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] + + if not oldvalue: + self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] = value + else: + self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] = oldvalue + value + bot.db.set_nick_value(nick, sorting_key, self.SpiceBot_Database["nicks"][nick_id][sorting_key]) + + self.lock.release() + + def adjust_nick_list(self, bot, nick, key, entries, adjustmentdirection, sorting_key='unsorted'): + + self.lock.acquire() + + if not isinstance(entries, list): + entries = [entries] + + nick = Identifier(nick) + nick_id = bot.db.get_nick_id(nick, create=True) + + if nick_id not in self.SpiceBot_Database["nicks"].keys(): + self.SpiceBot_Database["nicks"][nick_id] = {} + + if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys(): + self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + + if key not in self.SpiceBot_Database["nicks"][nick_id][sorting_key].keys(): + self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] = [] + + if adjustmentdirection == 'add': + for entry in entries: + if entry not in self.SpiceBot_Database["nicks"][nick_id][sorting_key][key]: + self.SpiceBot_Database["nicks"][nick_id][sorting_key][key].append(entry) + elif adjustmentdirection == 'del': + for entry in entries: + while entry in self.SpiceBot_Database["nicks"][nick_id][sorting_key][key]: + self.SpiceBot_Database["nicks"][nick_id][sorting_key][key].remove(entry) + bot.db.set_nick_value(nick, sorting_key, self.SpiceBot_Database["nicks"][nick_id][sorting_key]) + + self.lock.release() + + """Channels""" + + def get_channel_value(self, bot, channel, key, sorting_key='unsorted'): + + self.lock.acquire() + + channel = Identifier(channel) + + if channel not in self.SpiceBot_Database["channels"].keys(): + self.SpiceBot_Database["channels"][channel] = {} + + if sorting_key not in self.SpiceBot_Database["channels"][channel].keys(): + self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + + self.lock.release() + + if key not in self.SpiceBot_Database["channels"][channel][sorting_key].keys(): + return None + else: + return self.SpiceBot_Database["channels"][channel][sorting_key][key] + + def set_channel_value(self, bot, channel, key, value, sorting_key='unsorted'): + + self.lock.acquire() + + channel = Identifier(channel) + + if channel not in self.SpiceBot_Database["channels"].keys(): + self.SpiceBot_Database["channels"][channel] = {} + + if sorting_key not in self.SpiceBot_Database["channels"][channel].keys(): + self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + + self.SpiceBot_Database["channels"][channel][sorting_key][key] = value + bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key]) + + self.lock.release() + + def delete_channel_value(self, bot, channel, key, sorting_key='unsorted'): + + self.lock.acquire() + + channel = Identifier(channel) + + if channel not in self.SpiceBot_Database["channels"].keys(): + self.SpiceBot_Database["channels"][channel] = {} + + if sorting_key not in self.SpiceBot_Database["channels"][channel].keys(): + self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + + del self.SpiceBot_Database["channels"][channel][sorting_key][key] + bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key]) + + self.lock.release() + + def adjust_channel_value(self, bot, channel, key, value, sorting_key='unsorted'): + + self.lock.acquire() + + channel = Identifier(channel) + + if channel not in self.SpiceBot_Database["channels"].keys(): + self.SpiceBot_Database["channels"][channel] = {} + + if sorting_key not in self.SpiceBot_Database["channels"][channel].keys(): + self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + + if key not in self.SpiceBot_Database["channels"][channel][sorting_key].keys(): + oldvalue = None + else: + oldvalue = self.SpiceBot_Database["channels"][channel][sorting_key][key] + + if not oldvalue: + self.SpiceBot_Database["channels"][channel][sorting_key][key] = value + else: + self.SpiceBot_Database["channels"][channel][sorting_key][key] = oldvalue + value + bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key]) + + self.lock.release() + + def adjust_channel_list(self, bot, channel, key, entries, adjustmentdirection, sorting_key='unsorted'): + + self.lock.acquire() + + if not isinstance(entries, list): + entries = [entries] + + channel = Identifier(channel) + + if channel not in self.SpiceBot_Database["channels"].keys(): + self.SpiceBot_Database["channels"][channel] = {} + + if sorting_key not in self.SpiceBot_Database["channels"][channel].keys(): + self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + + if key not in self.SpiceBot_Database["channels"][channel][sorting_key].keys(): + self.SpiceBot_Database["channels"][channel][sorting_key][key] = [] + + if adjustmentdirection == 'add': + for entry in entries: + if entry not in self.SpiceBot_Database["channels"][channel][sorting_key][key]: + self.SpiceBot_Database["channels"][channel][sorting_key][key].append(entry) + elif adjustmentdirection == 'del': + for entry in entries: + while entry in self.SpiceBot_Database["channels"][channel][sorting_key][key]: + self.SpiceBot_Database["channels"][channel][sorting_key][key].remove(entry) + bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key]) + + self.lock.release() + + +botdb = BotDatabase() diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index 43549f3..2606e87 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -11,6 +11,7 @@ from .Logs import * from .Commands import * from .Events import * from .Channels import * +from .Database import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' diff --git a/sopel_modules/SpiceBot_Database_Cache/DatabaseCache.py b/sopel_modules/SpiceBot_Database_Cache/DatabaseCache.py deleted file mode 100644 index f31ea22..0000000 --- a/sopel_modules/SpiceBot_Database_Cache/DatabaseCache.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python -# coding=utf-8 -from __future__ import unicode_literals, absolute_import, print_function, division - -# sopel imports -import sopel.module - -from sopel_modules.SpiceBot.Logs import botlogs - - -def setup(bot): - botlogs.log('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_Cache/__init__.py b/sopel_modules/SpiceBot_Database_Cache/__init__.py deleted file mode 100644 index 212ae54..0000000 --- a/sopel_modules/SpiceBot_Database_Cache/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# coding=utf-8 -"""Useful miscellaneous tools and shortcuts for SpiceBot Sopel modules -""" -from __future__ import unicode_literals, absolute_import, print_function, division - -from .DatabaseCache import * diff --git a/sopel_modules/SpiceBot_Database_Tools/DatabaseTools.py b/sopel_modules/SpiceBot_Database_Tools/DatabaseTools.py deleted file mode 100644 index e074941..0000000 --- a/sopel_modules/SpiceBot_Database_Tools/DatabaseTools.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python -# coding=utf-8 -from __future__ import unicode_literals, absolute_import, print_function, division - -# sopel imports -import sopel.module - - -"""Database Direct""" - - -# Get a value -def db_get_nick_value(bot, nick, key): - database_value = bot.db.get_nick_value(nick, key) or None - return database_value - - -# set a value -def db_set_nick_value(bot, nick, key, value): - bot.db.set_nick_value(nick, key, value) - - -# DELETE a value -def db_reset_value(bot, nick, key): - bot.db.reset_nick_value(nick, key) - - -# add or subtract from current value -def db_adjust_value(bot, nick, key, value): - bot.db.adjust_nick_value(nick, key, value) - - -# list stored in database, add or remove elements -def db_adjust_list(bot, nick, entries, key, adjustmentdirection): - if not isinstance(entries, list): - entries = [entries] - adjustlist = db_get_nick_value(bot, nick, key) or [] - adjustlistnew = [] - for x in adjustlist: - adjustlistnew.append(x) - db_reset_value(bot, nick, key) - adjustlist = [] - if adjustmentdirection == 'add': - for y in entries: - if y not in adjustlistnew: - adjustlistnew.append(y) - elif adjustmentdirection == 'del': - for y in entries: - if y in adjustlistnew: - adjustlistnew.remove(y) - for x in adjustlistnew: - if x not in adjustlist: - adjustlist.append(x) - if not len(adjustlist): - db_reset_value(bot, nick, key) - else: - db_set_nick_value(bot, nick, key, adjustlist) diff --git a/sopel_modules/SpiceBot_Database_Tools/__init__.py b/sopel_modules/SpiceBot_Database_Tools/__init__.py deleted file mode 100644 index 6cd3826..0000000 --- a/sopel_modules/SpiceBot_Database_Tools/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# coding=utf-8 -"""Useful miscellaneous tools and shortcuts for SpiceBot Sopel modules -""" -from __future__ import unicode_literals, absolute_import, print_function, division - -from .DatabaseTools import * From 417d941bfeb350dc5f5f322b472e6ba66cb666a6 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 11:22:59 -0400 Subject: [PATCH 010/328] Tes alternate import method --- sopel_modules/SpiceBot/Channels.py | 3 - sopel_modules/SpiceBot/Commands.py | 3 - sopel_modules/SpiceBot/Database.py | 3 - sopel_modules/SpiceBot/Events.py | 3 - sopel_modules/SpiceBot/Logs.py | 7 +- sopel_modules/SpiceBot/Tools.py | 22 +- sopel_modules/SpiceBot/__init__.py | 7 + sopel_modules/SpiceBot_AI/AI.py | 32 +- sopel_modules/SpiceBot_BotPrivs/BotPrivs.py | 6 +- .../Channels_Command.py | 44 +-- .../Channels_Parsing.py | 68 ++-- .../NickQueryCommand.py | 19 +- .../SpiceBot_CommandsQuery/QueryCommand.py | 21 +- .../Databaseaddons.py | 4 +- sopel_modules/SpiceBot_Docs/Docs.py | 8 +- sopel_modules/SpiceBot_Events/Connected.py | 6 +- .../SpiceBot_Events/Connection_Count.py | 10 +- sopel_modules/SpiceBot_Events/Loaded.py | 8 +- sopel_modules/SpiceBot_Events/Logging.py | 7 +- sopel_modules/SpiceBot_Events/Queue.py | 12 +- sopel_modules/SpiceBot_Events/Ready.py | 6 +- sopel_modules/SpiceBot_Events/Welcome.py | 8 +- sopel_modules/SpiceBot_GifSearch/gif.py | 7 +- sopel_modules/SpiceBot_GifSearch/gifapi.py | 7 +- sopel_modules/SpiceBot_GifSearch/gifsearch.py | 17 +- .../SpiceBot_InvalidCommand/InvalidCommand.py | 14 +- sopel_modules/SpiceBot_Kick/__init__.py | 6 +- sopel_modules/SpiceBot_Logs/IRC_Events | 364 +++++++++--------- sopel_modules/SpiceBot_Logs/Logs_Command.py | 24 +- sopel_modules/SpiceBot_Logs/Queue.py | 21 +- sopel_modules/SpiceBot_Messaging/Messaging.py | 11 +- .../SpiceBot_Module_Parsing/ModuleParsing.py | 34 +- sopel_modules/SpiceBot_Restart/Restart.py | 7 +- .../SpiceBot_SopelPatches/Patches.py | 9 +- .../StartupMonologue.py | 7 +- .../StartupMonologue_Display_Channels.py | 12 +- .../StartupMonologue_Display_Commands.py | 16 +- .../StartupMonologue_Display_Connected.py | 9 +- .../StartupMonologue_Display_Errors.py | 11 +- .../StartupMonologue_Display_Loaded.py | 18 +- sopel_modules/SpiceBot_Update/Update.py | 17 +- sopel_modules/SpiceBot_Uptime/Uptime.py | 7 +- sopel_modules/SpiceBot_osd/__init__.py | 8 +- 43 files changed, 445 insertions(+), 488 deletions(-) diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index 433b984..622ca24 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -70,6 +70,3 @@ class BotChannels(): bot.write(('SAMODE', channel, "+a", bot.nick)) else: bot.part(channel) - - -botchannels = BotChannels() diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 5a4eb99..f479f73 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -51,6 +51,3 @@ class BotCommands(): for comalias in comaliases: if comalias not in self.SpiceBot_Commands['commands'][command_type].keys(): self.SpiceBot_Commands['commands'][command_type][comalias] = {"aliasfor": aliasfor} - - -botcommands = BotCommands() diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 4cd8390..2328881 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -246,6 +246,3 @@ class BotDatabase(): bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key]) self.lock.release() - - -botdb = BotDatabase() diff --git a/sopel_modules/SpiceBot/Events.py b/sopel_modules/SpiceBot/Events.py index 34dfc54..b277a77 100644 --- a/sopel_modules/SpiceBot/Events.py +++ b/sopel_modules/SpiceBot/Events.py @@ -124,6 +124,3 @@ class BotEvents(object): return function(*args, **kwargs) return _nop return actual_decorator - - -botevents = BotEvents() diff --git a/sopel_modules/SpiceBot/Logs.py b/sopel_modules/SpiceBot/Logs.py index da458ae..fe7b0e0 100644 --- a/sopel_modules/SpiceBot/Logs.py +++ b/sopel_modules/SpiceBot/Logs.py @@ -12,7 +12,7 @@ import os import spicemanip -class botlogs(): +class BotLogs(): """This Is a contained source of log information""" def __init__(self): self.SpiceBot_Logs = { @@ -43,7 +43,7 @@ class botlogs(): def stdio_logs_fetch(self, bot): stdio_ignore = [] - for logtype in botlogs.SpiceBot_Logs["list"].keys(): + for logtype in self.SpiceBot_Logs["list"].keys(): stdio_ignore.append("[" + logtype + "]") logfile = os.path.os.path.join(bot.config.core.logdir, 'stdio.log') @@ -101,6 +101,3 @@ class botlogs(): pidnum = e pidnum = str(os.popen("systemctl show " + str(bot.nick) + " --property=MainPID").read()).split("=")[-1] return pidnum - - -botlogs = botlogs() diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index 59306b4..fa95b21 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -20,7 +20,7 @@ from pygit2 import clone_repository import spicemanip -from .Logs import botlogs +import sopel_modules.SpiceBot as SpiceBot """Variable References""" @@ -305,7 +305,7 @@ def spicebot_update(bot, deps=False): if not os.path.exists(clonepath) or not os.path.isdir(clonepath): os.system(clonepath) - botlogs.log('SpiceBot_Update', "Cloning to " + clonepath, True) + SpiceBot.botlogs.log('SpiceBot_Update', "Cloning to " + clonepath, True) clone_repository(str(bot.config.SpiceBot_Update.gitrepo + ".git"), clonepath, checkout_branch=bot.config.SpiceBot_Update.gitbranch) @@ -316,12 +316,12 @@ def spicebot_update(bot, deps=False): # pipcommand += " git+" + str(bot.config.SpiceBot_Update.gitrepo) + "@" + str(bot.config.SpiceBot_Update.gitbranch) pipcommand += " /tmp/SpiceBot/" - botlogs.log('SpiceBot_Update', "Running `" + pipcommand + "`", True) + SpiceBot.botlogs.log('SpiceBot_Update', "Running `" + pipcommand + "`", True) # for line in os.popen(pipcommand).read().split('\n'): - # botlogs.log('SpiceBot_Update', " " + line) + # SpiceBot.botlogs.log('SpiceBot_Update', " " + line) os.system(pipcommand) - botlogs.log('SpiceBot_Update', "Deleting " + clonepath, True) + SpiceBot.botlogs.log('SpiceBot_Update', "Deleting " + clonepath, True) os.system("sudo rm -r /tmp/SpiceBot") @@ -337,10 +337,10 @@ def service_manip(bot, servicename, dowhat, log_from='service_manip'): if str(dowhat) not in ["start", "stop", "restart"]: return try: - botlogs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service.") + SpiceBot.botlogs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service.") os.system("sudo service " + str(servicename) + " " + str(dowhat)) except Exception as e: - botlogs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service Failed: " + str(e)) + SpiceBot.botlogs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service Failed: " + str(e)) """Config Reading Functions""" @@ -372,7 +372,7 @@ def read_directory_json_to_dict(bot, directories, configtypename="Config File", except Exception as e: filereadgood = False if bot: - botlogs.log(log_from, "Error loading %s: %s (%s)" % (configtypename, e, filepath)) + SpiceBot.botlogs.log(log_from, "Error loading %s: %s (%s)" % (configtypename, e, filepath)) dict_from_file = dict() # Close File inf.close() @@ -387,10 +387,10 @@ def read_directory_json_to_dict(bot, directories, configtypename="Config File", if filecount: if bot: - botlogs.log(log_from, 'Registered %d %s dict files,' % (filecount, configtypename)) - botlogs.log(log_from, '%d %s dict files failed to load' % (fileopenfail, configtypename), True) + SpiceBot.botlogs.log(log_from, 'Registered %d %s dict files,' % (filecount, configtypename)) + SpiceBot.botlogs.log(log_from, '%d %s dict files failed to load' % (fileopenfail, configtypename), True) else: if bot: - botlogs.log(log_from, "Warning: Couldn't load any %s dict files" % (configtypename)) + SpiceBot.botlogs.log(log_from, "Warning: Couldn't load any %s dict files" % (configtypename)) return configs_dict diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index 2606e87..3f196cd 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -16,3 +16,10 @@ from .Database import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' __version__ = '0.1.1' + + +botdb = BotDatabase() +botchannels = BotChannels() +botcommands = BotCommands() +botevents = BotEvents() +botlogs = BotLogs() diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index 4233896..5ca12ab 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -6,16 +6,14 @@ import sopel.module import spicemanip -from sopel_modules.SpiceBot.Tools import sopel_triggerargs, googlesearch, bot_privs, inlist, inlist_match, similar_list -from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot.Commands import botcommands +import sopel_modules.SpiceBot as SpiceBot -@botevents.check_ready([botevents.BOT_LOADED, botevents.BOT_COMMANDSQUERY]) +@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOADED, SpiceBot.botevents.BOT_COMMANDSQUERY]) @sopel.module.nickname_commands('(.*)') def bot_command_nick(bot, trigger): - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') + triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') if not triggercommand: return @@ -23,19 +21,19 @@ def bot_command_nick(bot, trigger): if triggercommand[0] == "?": return - if triggercommand in botcommands.SpiceBot_Commands['commands']["nickname"].keys(): + if triggercommand in SpiceBot.botcommands.SpiceBot_Commands['commands']["nickname"].keys(): return triggerargs.insert(0, triggercommand) fulltrigger = spicemanip.main(triggerargs, 0).lower() - if fulltrigger in botcommands.SpiceBot_Commands['nickrules']: + if fulltrigger in SpiceBot.botcommands.SpiceBot_Commands['nickrules']: return if fulltrigger.lower().startswith("what is"): searchterm = spicemanip.main(triggerargs, "3+") or None if searchterm: - searchreturn = googlesearch(bot, searchterm) + searchreturn = SpiceBot.googlesearch(bot, searchterm) if not searchreturn: bot.osd('I cannot find anything about that') else: @@ -50,7 +48,7 @@ def bot_command_nick(bot, trigger): if searchterm.lower() in ['waldo', 'wally']: bot.osd("He is hiding for a reason?") - searchreturn = googlesearch(bot, "wimmelbilderbuch") + searchreturn = SpiceBot.googlesearch(bot, "wimmelbilderbuch") if searchreturn: bot.osd(str(searchreturn)) return @@ -59,7 +57,7 @@ def bot_command_nick(bot, trigger): carmenlocale = ['ACME Headquarters', "Villains' International League of Evil"] bot.osd("Currently she is located at " + spicemanip.main(carmenlocale, 'random')) return - searchreturn = googlesearch(bot, searchterm, 'maps') + searchreturn = SpiceBot.googlesearch(bot, searchterm, 'maps') if not searchreturn: bot.osd('I cannot find anything about that') @@ -102,7 +100,7 @@ def bot_command_nick(bot, trigger): elif fulltrigger.lower().endswith(tuple(["order 66"])): if fulltrigger.lower() == "execute order 66": - if inlist(trigger.nick, bot_privs(bot, 'owners')): + if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs(bot, 'owners')): if trigger.is_privmsg: jedi = None else: @@ -120,7 +118,7 @@ def bot_command_nick(bot, trigger): bot.osd("I'm sure I don't know what you're talking about.") elif fulltrigger.lower() == "explain order 66": - if inlist(trigger.nick, bot_privs(bot, 'owners')): + if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs(bot, 'owners')): bot.osd("Order 66 is an instruction that only you can give, sir. When you give the order I will rise up against my overlords and slay them.") else: bot.osd("I'm afraid I cannot tell you that, sir.") @@ -129,7 +127,7 @@ def bot_command_nick(bot, trigger): return elif fulltrigger.lower() == "initiate clean slate protocol": - if inlist(trigger.nick, bot_privs(bot, 'admins')): + if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs(bot, 'admins')): bot.osd("sends a destruct command to the network of bots.", 'action') else: bot.osd("I'm afraid you do not have the authority to make that call, " + trigger.nick + ".") @@ -143,10 +141,10 @@ def bot_command_nick(bot, trigger): if target in [trigger.nick, 'me']: bot.osd(trigger.nick + ", I can see you.") else: - if inlist(trigger.nick, bot.users): - bot.osd(trigger.nick + ", yes. I can see " + inlist_match(target, bot.users) + " right now!") + if SpiceBot.inlist(trigger.nick, bot.users): + bot.osd(trigger.nick + ", yes. I can see " + SpiceBot.inlist_match(target, bot.users) + " right now!") else: - bot.osd(trigger.nick + ", no. I cannot see " + inlist_match(target, bot.users) + " right now!") + bot.osd(trigger.nick + ", no. I cannot see " + SpiceBot.inlist_match(target, bot.users) + " right now!") # if bot_check_inlist(target, bot.memory["botdict"]["users"].keys()): # bot.osd(trigger.nick + ", I can't see " + inlist_match(target, bot.users) + " at the moment.") # else: @@ -156,7 +154,7 @@ def bot_command_nick(bot, trigger): else: - closestmatches = similar_list(bot, triggercommand, botcommands.SpiceBot_Commands['commands']["nickname"].keys(), 3, 'reverse') + closestmatches = SpiceBot.similar_list(bot, triggercommand, SpiceBot.botcommands.SpiceBot_Commands['commands']["nickname"].keys(), 3, 'reverse') if len(closestmatches): closestmatches = spicemanip.main(closestmatches, "andlist") diff --git a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py index 54a3aa8..95cf09f 100644 --- a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py +++ b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py @@ -6,7 +6,7 @@ import sopel.module import spicemanip -from sopel_modules.SpiceBot.Tools import sopel_triggerargs, bot_privs +import sopel_modules.SpiceBot as SpiceBot @sopel.module.nickname_commands('owners', 'owner') @@ -20,10 +20,10 @@ def bot_command_admins(bot, trigger): def bot_command_process(bot, trigger): - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') + triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') if triggercommand == 'owner': triggercommand = 'owners' - privlist = spicemanip.main(bot_privs(bot, triggercommand), 'andlist') + privlist = spicemanip.main(SpiceBot.bot_privs(bot, triggercommand), 'andlist') bot.osd(str(bot.nick) + " " + triggercommand + ": " + privlist) diff --git a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py index e01f5bf..1599bc3 100644 --- a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py +++ b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py @@ -6,16 +6,14 @@ import sopel.module import spicemanip -from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot.Channels import botchannels -from sopel_modules.SpiceBot.Tools import sopel_triggerargs, inlist, channel_privs +import sopel_modules.SpiceBot as SpiceBot -@botevents.check_ready([botevents.BOT_LOADED]) +@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOADED]) @sopel.module.nickname_commands('channels', 'channel') def nickname_comand_channels(bot, trigger): - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') + triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') if not len(triggerargs): commandused = 'list' @@ -31,14 +29,14 @@ def nickname_comand_channels(bot, trigger): elif commandused == 'total': botcount = len(bot.channels.keys()) - servercount = len(botchannels.SpiceBot_Channels['list'].keys()) + servercount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys()) bot.osd("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") return elif commandused == 'random': - channel = spicemanip.main(botchannels.SpiceBot_Channels['list'], 'random') - topic = botchannels.SpiceBot_Channels['list'][channel]['topic'] - msg = ["Random channel for you: {}.".format(botchannels.SpiceBot_Channels['list'][channel]['name'])] + channel = spicemanip.main(SpiceBot.botchannels.SpiceBot_Channels['list'], 'random') + topic = SpiceBot.botchannels.SpiceBot_Channels['list'][channel]['topic'] + msg = ["Random channel for you: {}.".format(SpiceBot.botchannels.SpiceBot_Channels['list'][channel]['name'])] if topic and not topic.isspace(): msg.append("The topic is: {}".format(topic)) else: @@ -50,15 +48,15 @@ def nickname_comand_channels(bot, trigger): if not trigger.admin: bot.osd("You do not have permission to update the channel listing.") return - botchannels.bot_part_empty(bot) - botchannels.channel_list_request(bot) + SpiceBot.botchannels.bot_part_empty(bot) + SpiceBot.botchannels.channel_list_request(bot) bot.osd(["[SpiceBot_Channels]", "I am now updating the channel listing for this server."]) - while botchannels.channel_lock: + while SpiceBot.botchannels.channel_lock: pass - botchannels.join_all_channels(bot) - foundchannelcount = len(botchannels.SpiceBot_Channels['list'].keys()) + SpiceBot.botchannels.join_all_channels(bot) + foundchannelcount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys()) bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.") - botchannels.bot_part_empty(bot) + SpiceBot.botchannels.bot_part_empty(bot) return elif commandused == 'topic': @@ -66,11 +64,11 @@ def nickname_comand_channels(bot, trigger): bot.osd("Channel name input missing.") return channel = spicemanip.main(triggerargs, 1) - if not inlist(channel.lower(), botchannels.SpiceBot_Channels['list'].keys()): + if not SpiceBot.inlist(channel.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys()): bot.osd("Channel name {} not valid.".format(channel)) return - topic = botchannels.SpiceBot_Channels['list'][channel.lower()]['topic'] - channel = botchannels.SpiceBot_Channels['list'][channel.lower()]['name'] + topic = SpiceBot.botchannels.SpiceBot_Channels['list'][channel.lower()]['topic'] + channel = SpiceBot.botchannels.SpiceBot_Channels['list'][channel.lower()]['name'] bot.osd("Topic for {}: {}".format(channel, topic)) return @@ -83,14 +81,14 @@ def nickname_comand_channels(bot, trigger): channel = trigger.sender else: channel = spicemanip.main(triggerargs, 1) - if not inlist(channel.lower(), botchannels.SpiceBot_Channels['list'].keys()): + if not SpiceBot.inlist(channel.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys()): bot.osd("Channel name {} not valid.".format(channel)) return - if not inlist(channel.lower(), bot.channels.keys()): + if not SpiceBot.inlist(channel.lower(), bot.channels.keys()): bot.osd("I need to be in {} to see nick privileges.".format(channel)) return - privlist = channel_privs(bot, channel, commandused.upper()) + privlist = SpiceBot.channel_privs(bot, channel, commandused.upper()) dispmsg = [] if not len(privlist): dispmsg.append("There are no Channel " + commandused.upper() + "s for " + str(channel)) @@ -103,10 +101,10 @@ def nickname_comand_channels(bot, trigger): # Users List if commandused == 'users': channel = spicemanip.main(triggerargs, 1) - if not inlist(channel.lower(), botchannels.SpiceBot_Channels['list'].keys()): + if not SpiceBot.inlist(channel.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys()): bot.osd("Channel name {} not valid.".format(channel)) return - if not inlist(channel.lower(), bot.channels.keys()): + if not SpiceBot.inlist(channel.lower(), bot.channels.keys()): bot.osd("I need to be in {} to see user list.".format(channel)) return dispmsg = [] diff --git a/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py b/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py index ef22e3d..8951ed5 100644 --- a/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py +++ b/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py @@ -6,9 +6,7 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi import sopel.module from sopel.config.types import StaticSection, ValidatedAttribute, ListAttribute -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot.Channels import botchannels +import sopel_modules.SpiceBot as SpiceBot import spicemanip @@ -31,91 +29,91 @@ def configure(config): def setup(bot): - botlogs.log('SpiceBot_Channels', "Starting setup procedure") - botevents.startup_add([botevents.BOT_CHANNELS]) + SpiceBot.botlogs.log('SpiceBot_Channels', "Starting setup procedure") + SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_CHANNELS]) bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) -@sopel.module.event(botevents.RPL_WELCOME) +@sopel.module.event(SpiceBot.botevents.RPL_WELCOME) @sopel.module.rule('.*') def unkickable_bot(bot, trigger): if bot.config.SpiceBot_Channels.operadmin: bot.write(('SAMODE', bot.nick, '+q')) -@sopel.module.event(botevents.RPL_WELCOME) +@sopel.module.event(SpiceBot.botevents.RPL_WELCOME) @sopel.module.rule('.*') def request_channels_list_initial(bot, trigger): - botchannels.bot_part_empty(bot) + SpiceBot.botchannels.bot_part_empty(bot) - botlogs.log('SpiceBot_Channels', "Sending Request for all server channels") - botchannels.channel_list_request(bot) + SpiceBot.botlogs.log('SpiceBot_Channels', "Sending Request for all server channels") + SpiceBot.botchannels.channel_list_request(bot) starttime = time.time() # wait 60 seconds for initial population of information - while not botchannels.SpiceBot_Channels['InitialProcess']: + while not SpiceBot.botchannels.SpiceBot_Channels['InitialProcess']: if time.time() - starttime >= 60: - botlogs.log('SpiceBot_Channels', "Initial Channel list populating Timed Out") - botchannels.SpiceBot_Channels['InitialProcess'] = True + SpiceBot.botlogs.log('SpiceBot_Channels', "Initial Channel list populating Timed Out") + SpiceBot.botchannels.SpiceBot_Channels['InitialProcess'] = True else: pass - foundchannelcount = len(botchannels.SpiceBot_Channels['list'].keys()) - botlogs.log('SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.") + foundchannelcount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys()) + SpiceBot.botlogs.log('SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.") - botchannels.join_all_channels(bot) - botchannels.chanadmin_all_channels(bot) + SpiceBot.botchannels.join_all_channels(bot) + SpiceBot.botchannels.chanadmin_all_channels(bot) - if "*" in botchannels.SpiceBot_Channels['list'].keys(): - del botchannels.SpiceBot_Channels['list']["*"] + if "*" in SpiceBot.botchannels.SpiceBot_Channels['list'].keys(): + del SpiceBot.botchannels.SpiceBot_Channels['list']["*"] - botchannels.bot_part_empty(bot) - botevents.trigger(bot, botevents.BOT_CHANNELS, "SpiceBot_Channels") + SpiceBot.botchannels.bot_part_empty(bot) + SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_CHANNELS, "SpiceBot_Channels") @sopel.module.event('321') @sopel.module.rule('.*') def watch_chanlist_start(bot, trigger): - botchannels.channel_list_recieve_start() + SpiceBot.botchannels.channel_list_recieve_start() @sopel.module.event('322') @sopel.module.rule('.*') def watch_chanlist_populate(bot, trigger): - botchannels.channel_list_recieve_input(trigger) + SpiceBot.botchannels.channel_list_recieve_input(trigger) @sopel.module.event('323') @sopel.module.rule('.*') def watch_chanlist_complete(bot, trigger): - botchannels.channel_list_recieve_finish() + SpiceBot.botchannels.channel_list_recieve_finish() -@sopel.module.event(botevents.BOT_CHANNELS) +@sopel.module.event(SpiceBot.botevents.BOT_CHANNELS) @sopel.module.rule('.*') def trigger_channel_list_recurring(bot, trigger): while True: time.sleep(1800) - botchannels.bot_part_empty(bot) + SpiceBot.botchannels.bot_part_empty(bot) - oldlist = list(botchannels.SpiceBot_Channels['list'].keys()) - botchannels.channel_list_request(bot) + oldlist = list(SpiceBot.botchannels.SpiceBot_Channels['list'].keys()) + SpiceBot.botchannels.channel_list_request(bot) - while botchannels.channel_lock: + while SpiceBot.botchannels.channel_lock: pass - newlist = [item.lower() for item in oldlist if item.lower() not in list(botchannels.SpiceBot_Channels['list'].keys())] + newlist = [item.lower() for item in oldlist if item.lower() not in list(SpiceBot.botchannels.SpiceBot_Channels['list'].keys())] if "*" in newlist: newlist.remove("*") if len(newlist) and bot.config.SpiceBot_Channels.announcenew: bot.osd(["The Following channel(s) are new:", spicemanip.main(newlist, 'andlist')], bot.channels.keys()) - botchannels.join_all_channels(bot) + SpiceBot.botchannels.join_all_channels(bot) - botchannels.chanadmin_all_channels(bot) + SpiceBot.botchannels.chanadmin_all_channels(bot) - if "*" in botchannels.SpiceBot_Channels['list'].keys(): - del botchannels.SpiceBot_Channels['list']["*"] - botchannels.bot_part_empty(bot) + if "*" in SpiceBot.botchannels.SpiceBot_Channels['list'].keys(): + del SpiceBot.botchannels.SpiceBot_Channels['list']["*"] + SpiceBot.botchannels.bot_part_empty(bot) diff --git a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py index 3de378d..3c37745 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py @@ -5,19 +5,16 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel import sopel.module -from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot.Commands import botcommands -from sopel_modules.SpiceBot.Tools import sopel_triggerargs, similar_list, letters_in_string - +import sopel_modules.SpiceBot as SpiceBot import spicemanip -@botevents.check_ready([botevents.BOT_COMMANDSQUERY]) +@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_COMMANDSQUERY]) @sopel.module.nickname_commands('(.*)') def query_detection_nick(bot, trigger): - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') + triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') # command issued, check if valid if not triggercommand or not len(triggercommand): @@ -27,13 +24,13 @@ def query_detection_nick(bot, trigger): return triggercommand = triggercommand[1:] - if not letters_in_string(triggercommand): + if not SpiceBot.letters_in_string(triggercommand): return commands_list = dict() - for com in botcommands.SpiceBot_Commands['commands']['nickname'].keys(): + for com in SpiceBot.botcommands.SpiceBot_Commands['commands']['nickname'].keys(): if com not in commands_list.keys(): - commands_list[com] = botcommands.SpiceBot_Commands['commands']['nickname'][com] + commands_list[com] = SpiceBot.botcommands.SpiceBot_Commands['commands']['nickname'][com] if triggercommand.endswith("+"): @@ -43,7 +40,7 @@ def query_detection_nick(bot, trigger): if triggercommand.lower() not in list(commands_list.keys()): dispmsg = ["Cannot find any alias " + bot.nick + " commands: No valid commands match " + str(triggercommand) + "."] - closestmatches = similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') + closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') if len(closestmatches): dispmsg.append("The following " + bot.nick + " commands match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") bot.notice(dispmsg, trigger.nick) @@ -62,7 +59,7 @@ def query_detection_nick(bot, trigger): if not triggercommand or not len(triggercommand): return - closestmatches = similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') + closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') if not len(closestmatches): bot.notice("Cannot find any similar " + bot.nick + " commands for " + str(triggercommand) + ".", trigger.nick) else: diff --git a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py index 01b7ca7..1711cb7 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py @@ -5,33 +5,30 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel import sopel.module -from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot.Commands import botcommands -from sopel_modules.SpiceBot.Tools import sopel_triggerargs, similar_list, letters_in_string - +import sopel_modules.SpiceBot as SpiceBot import spicemanip -@botevents.check_ready([botevents.BOT_COMMANDSQUERY]) +@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_COMMANDSQUERY]) @sopel.module.rule('^\?(.*)') def query_detection(bot, trigger): - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'query_command') + triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'query_command') # command issued, check if valid if not triggercommand or not len(triggercommand): return - if not letters_in_string(triggercommand): + if not SpiceBot.letters_in_string(triggercommand): return commands_list = dict() - for commandstype in botcommands.SpiceBot_Commands['commands'].keys(): + for commandstype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys(): if commandstype not in ['rule', 'nickname']: - for com in botcommands.SpiceBot_Commands['commands'][commandstype].keys(): + for com in SpiceBot.botcommands.SpiceBot_Commands['commands'][commandstype].keys(): if com not in commands_list.keys(): - commands_list[com] = botcommands.SpiceBot_Commands['commands'][commandstype][com] + commands_list[com] = SpiceBot.botcommands.SpiceBot_Commands['commands'][commandstype][com] if triggercommand[:-1] == "+": @@ -41,7 +38,7 @@ def query_detection(bot, trigger): if triggercommand.lower() not in list(commands_list.keys()): dispmsg = ["Cannot find any alias commands: No valid commands match " + str(triggercommand) + "."] - closestmatches = similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') + closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') if len(closestmatches): dispmsg.append("The following commands match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") bot.notice(dispmsg, trigger.nick) @@ -60,7 +57,7 @@ def query_detection(bot, trigger): if not triggercommand or not len(triggercommand): return - closestmatches = similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') + closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') if not len(closestmatches): bot.notice("Cannot find any similar commands for " + str(triggercommand) + ".", trigger.nick) else: diff --git a/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py b/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py index fc62de7..99dbc39 100644 --- a/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py +++ b/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py @@ -10,13 +10,13 @@ from sopel.db import SopelDB, NickValues, ChannelValues from sqlalchemy.exc import SQLAlchemyError import json -from sopel_modules.SpiceBot.Logs import botlogs +import sopel_modules.SpiceBot as SpiceBot def setup(bot): # Inject Database Functions - botlogs.log('SpiceBot_Databaseaddons', "Implanting Database functions into bot") + SpiceBot.botlogs.log('SpiceBot_Databaseaddons', "Implanting Database functions into bot") SopelDB.delete_nick_value = SopelDBCache.delete_nick_value SopelDB.adjust_nick_value = SopelDBCache.adjust_nick_value SopelDB.delete_channel_value = SopelDBCache.delete_channel_value diff --git a/sopel_modules/SpiceBot_Docs/Docs.py b/sopel_modules/SpiceBot_Docs/Docs.py index 2924142..b17328f 100644 --- a/sopel_modules/SpiceBot_Docs/Docs.py +++ b/sopel_modules/SpiceBot_Docs/Docs.py @@ -4,9 +4,13 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Tools import github_dict +import sopel_modules.SpiceBot as SpiceBot @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"])]) + 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"])]) diff --git a/sopel_modules/SpiceBot_Events/Connected.py b/sopel_modules/SpiceBot_Events/Connected.py index c99f0db..be399d2 100644 --- a/sopel_modules/SpiceBot_Events/Connected.py +++ b/sopel_modules/SpiceBot_Events/Connected.py @@ -4,13 +4,13 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Events import botevents +import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(botevents.BOT_WELCOME) +@sopel.module.event(SpiceBot.botevents.BOT_WELCOME) @sopel.module.rule('.*') def bot_events_Connected(bot, trigger): """Here, we wait until we are in at least one channel""" while not len(bot.channels.keys()) > 0: pass - botevents.trigger(bot, botevents.BOT_CONNECTED, "Bot Connected to IRC") + SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_CONNECTED, "Bot Connected to IRC") diff --git a/sopel_modules/SpiceBot_Events/Connection_Count.py b/sopel_modules/SpiceBot_Events/Connection_Count.py index 786271b..dfa4887 100644 --- a/sopel_modules/SpiceBot_Events/Connection_Count.py +++ b/sopel_modules/SpiceBot_Events/Connection_Count.py @@ -4,12 +4,12 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Events import botevents +import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(botevents.RPL_WELCOME) +@sopel.module.event(SpiceBot.botevents.RPL_WELCOME) @sopel.module.rule('.*') def bot_startup_welcome(bot, trigger): - botevents.SpiceBot_Events["RPL_WELCOME_Count"] += 1 - if botevents.SpiceBot_Events["RPL_WELCOME_Count"] > 1: - botevents.trigger(bot, botevents.BOT_RECONNECTED, "Bot ReConnected to IRC") + SpiceBot.botevents.SpiceBot_Events["RPL_WELCOME_Count"] += 1 + if SpiceBot.botevents.SpiceBot_Events["RPL_WELCOME_Count"] > 1: + SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_RECONNECTED, "Bot ReConnected to IRC") diff --git a/sopel_modules/SpiceBot_Events/Loaded.py b/sopel_modules/SpiceBot_Events/Loaded.py index 679c06f..e1e5c12 100644 --- a/sopel_modules/SpiceBot_Events/Loaded.py +++ b/sopel_modules/SpiceBot_Events/Loaded.py @@ -4,12 +4,12 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Events import botevents +import sopel_modules.SpiceBot as SpiceBot -@botevents.startup_check_ready() -@sopel.module.event(botevents.BOT_READY) +@SpiceBot.botevents.startup_check_ready() +@sopel.module.event(SpiceBot.botevents.BOT_READY) @sopel.module.rule('.*') def bot_events_startup_complete(bot, trigger): """All events registered as required for startup have completed""" - botevents.trigger(bot, botevents.BOT_LOADED, "All registered modules setup procedures have completed") + SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_LOADED, "All registered modules setup procedures have completed") diff --git a/sopel_modules/SpiceBot_Events/Logging.py b/sopel_modules/SpiceBot_Events/Logging.py index 9176d9e..fb111db 100644 --- a/sopel_modules/SpiceBot_Events/Logging.py +++ b/sopel_modules/SpiceBot_Events/Logging.py @@ -4,12 +4,11 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Events import botevents +import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(botevents.BOT_WELCOME, botevents.BOT_READY, botevents.BOT_CONNECTED, botevents.BOT_LOADED) +@sopel.module.event(SpiceBot.botevents.BOT_WELCOME, SpiceBot.botevents.BOT_READY, SpiceBot.botevents.BOT_CONNECTED, SpiceBot.botevents.BOT_LOADED) @sopel.module.rule('.*') def bot_events_complete(bot, trigger): """This is here simply to log to stderr that this was recieved.""" - botlogs.log('SpiceBot_Events', trigger.args[1], True) + SpiceBot.botlogs.log('SpiceBot_Events', trigger.args[1], True) diff --git a/sopel_modules/SpiceBot_Events/Queue.py b/sopel_modules/SpiceBot_Events/Queue.py index 9ccd275..778642c 100644 --- a/sopel_modules/SpiceBot_Events/Queue.py +++ b/sopel_modules/SpiceBot_Events/Queue.py @@ -4,15 +4,15 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Events import botevents +import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(botevents.BOT_WELCOME) +@sopel.module.event(SpiceBot.botevents.BOT_WELCOME) @sopel.module.rule('.*') def bot_events_connected(bot, trigger): """For items tossed in a queue, this will trigger them accordingly""" while True: - if len(botevents.SpiceBot_Events["trigger_queue"]): - pretriggerdict = botevents.SpiceBot_Events["trigger_queue"][0] - botevents.dispatch(bot, pretriggerdict) - del botevents.SpiceBot_Events["trigger_queue"][0] + if len(SpiceBot.botevents.SpiceBot_Events["trigger_queue"]): + pretriggerdict = SpiceBot.botevents.SpiceBot_Events["trigger_queue"][0] + SpiceBot.botevents.dispatch(bot, pretriggerdict) + del SpiceBot.botevents.SpiceBot_Events["trigger_queue"][0] diff --git a/sopel_modules/SpiceBot_Events/Ready.py b/sopel_modules/SpiceBot_Events/Ready.py index 4e8df49..2ff6f28 100644 --- a/sopel_modules/SpiceBot_Events/Ready.py +++ b/sopel_modules/SpiceBot_Events/Ready.py @@ -4,11 +4,11 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Events import botevents +import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(botevents.BOT_WELCOME) +@sopel.module.event(SpiceBot.botevents.BOT_WELCOME) @sopel.module.rule('.*') def bot_events_start(bot, trigger): """This stage is redundant, but shows the system is working.""" - botevents.trigger(bot, botevents.BOT_READY, "Ready To Process module setup procedures") + SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_READY, "Ready To Process module setup procedures") diff --git a/sopel_modules/SpiceBot_Events/Welcome.py b/sopel_modules/SpiceBot_Events/Welcome.py index ca15d55..1102a53 100644 --- a/sopel_modules/SpiceBot_Events/Welcome.py +++ b/sopel_modules/SpiceBot_Events/Welcome.py @@ -4,14 +4,14 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Events import botevents +import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(botevents.RPL_WELCOME) +@sopel.module.event(SpiceBot.botevents.RPL_WELCOME) @sopel.module.rule('.*') def bot_startup_welcome(bot, trigger): """The Bot events system does not start until RPL_WELCOME 001 is recieved from the server""" - if botevents.check(botevents.BOT_WELCOME): + if SpiceBot.botevents.check(SpiceBot.botevents.BOT_WELCOME): return - botevents.trigger(bot, botevents.BOT_WELCOME, "Welcome to the SpiceBot Events System") + SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_WELCOME, "Welcome to the SpiceBot Events System") diff --git a/sopel_modules/SpiceBot_GifSearch/gif.py b/sopel_modules/SpiceBot_GifSearch/gif.py index 03ade90..9298bee 100644 --- a/sopel_modules/SpiceBot_GifSearch/gif.py +++ b/sopel_modules/SpiceBot_GifSearch/gif.py @@ -6,17 +6,16 @@ from sopel import module from .gifsearch import getGif -from sopel_modules.SpiceBot.Tools import sopel_triggerargs -from sopel_modules.SpiceBot.Events import botevents +import sopel_modules.SpiceBot as SpiceBot import spicemanip -@botevents.check_ready([botevents.BOT_GIFSEARCH]) +@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_GIFSEARCH]) @module.commands('gif') def gif_trigger(bot, trigger): - triggerargs, triggercommand = sopel_triggerargs(bot, trigger) + triggerargs, triggercommand = SpiceBot.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 10c5866..147888f 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifapi.py +++ b/sopel_modules/SpiceBot_GifSearch/gifapi.py @@ -8,15 +8,14 @@ import sopel.module import spicemanip -from sopel_modules.SpiceBot.Tools import sopel_triggerargs -from sopel_modules.SpiceBot.Events import botevents +import sopel_modules.SpiceBot as SpiceBot -@botevents.check_ready([botevents.BOT_GIFSEARCH]) +@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_GIFSEARCH]) @sopel.module.commands('(.*)') def gifapi_triggers(bot, trigger): - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'prefix_command') + triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'prefix_command') if triggercommand not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): return diff --git a/sopel_modules/SpiceBot_GifSearch/gifsearch.py b/sopel_modules/SpiceBot_GifSearch/gifsearch.py index 210c1e3..6e697e8 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifsearch.py +++ b/sopel_modules/SpiceBot_GifSearch/gifsearch.py @@ -5,10 +5,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module from sopel.config.types import StaticSection, ValidatedAttribute -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot.Commands import botcommands -from sopel_modules.SpiceBot.Tools import read_directory_json_to_dict +import sopel_modules.SpiceBot as SpiceBot import spicemanip @@ -32,7 +29,7 @@ class GifAPISection(StaticSection): def configure(config): moduledir = os.path.dirname(os.path.abspath(__file__)) api_dir = os.path.join(moduledir, 'gifapi') - valid_gif_api_dict = read_directory_json_to_dict(None, [api_dir], "Gif API", "SpiceBot_GifSearch") + valid_gif_api_dict = SpiceBot.read_directory_json_to_dict(None, [api_dir], "Gif API", "SpiceBot_GifSearch") config.define_section("SopelGifSearch", GifAPIMainSection, validate=False) config.SopelGifSearch.configure_setting('extra', 'SpiceBot_GifSearch API Extra directory') @@ -45,8 +42,8 @@ def configure(config): def setup(bot): - botlogs.log('SpiceBot_GifSearch', "Starting Setup Procedure") - botevents.startup_add([botevents.BOT_GIFSEARCH]) + SpiceBot.botlogs.log('SpiceBot_GifSearch', "Starting Setup Procedure") + SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_GIFSEARCH]) if 'SpiceBot_GifSearch' not in bot.memory: bot.memory["SpiceBot_GifSearch"] = {"cache": {}, "badgiflinks": [], 'valid_gif_api_dict': {}} @@ -61,7 +58,7 @@ def setup(bot): if bot.config.SopelGifSearch.extra: dir_to_scan.append(bot.config.SopelGifSearch.extra) - valid_gif_api_dict = read_directory_json_to_dict(bot, dir_to_scan, "Gif API", "SpiceBot_GifSearch") + valid_gif_api_dict = SpiceBot.read_directory_json_to_dict(bot, dir_to_scan, "Gif API", "SpiceBot_GifSearch") for gif_api in valid_gif_api_dict.keys(): bot.config.define_section(gif_api, GifAPISection, validate=False) @@ -73,12 +70,12 @@ def setup(bot): bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'][gif_api] = valid_gif_api_dict[gif_api] for validgifapi in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): - botcommands.commandsquery_register(bot, "prefix", validgifapi) + SpiceBot.botcommands.commandsquery_register(bot, "prefix", validgifapi) if validgifapi not in bot.memory["SpiceBot_GifSearch"]['cache'].keys(): bot.memory["SpiceBot_GifSearch"]['cache'][validgifapi] = dict() - botevents.trigger(bot, botevents.BOT_GIFSEARCH, "SpiceBot_GifSearch") + SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_GIFSEARCH, "SpiceBot_GifSearch") def shutdown(bot): diff --git a/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py b/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py index 895f466..58536c1 100644 --- a/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py +++ b/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py @@ -4,9 +4,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Tools import sopel_triggerargs -from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot.Commands import botcommands +import sopel_modules.SpiceBot as SpiceBot def setup(bot): @@ -19,19 +17,19 @@ def shutdown(bot): del bot.memory["SpiceBot_InvalidCommand"] -@sopel.module.event(botevents.BOT_LOADED) +@sopel.module.event(SpiceBot.botevents.BOT_LOADED) @sopel.module.rule('.*') def bot_events_complete(bot, trigger): - for comtype in botcommands.SpiceBot_Commands['commands'].keys(): - bot.memory["SpiceBot_InvalidCommand"]["valid"].extend(botcommands.SpiceBot_Commands['commands'][comtype].keys()) + for comtype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys(): + bot.memory["SpiceBot_InvalidCommand"]["valid"].extend(SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype].keys()) -@botevents.check_ready([botevents.BOT_LOADED, botevents.BOT_COMMANDSQUERY]) +@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOADED, SpiceBot.botevents.BOT_COMMANDSQUERY]) @sopel.module.commands('(.*)') def InvalidCommand_triggers(bot, trigger): return - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'prefix_command') + triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'prefix_command') # patch for people typing "...", maybe other stuff, but this verifies that there is still a command here if triggercommand.startswith("."): diff --git a/sopel_modules/SpiceBot_Kick/__init__.py b/sopel_modules/SpiceBot_Kick/__init__.py index 2d1c429..03b230c 100644 --- a/sopel_modules/SpiceBot_Kick/__init__.py +++ b/sopel_modules/SpiceBot_Kick/__init__.py @@ -14,7 +14,7 @@ from sopel import tools, module from sopel.tools import Identifier from sopel.config.types import StaticSection, ValidatedAttribute -from sopel_modules.SpiceBot.Logs import botlogs +import sopel_modules.SpiceBot as SpiceBot import time @@ -35,12 +35,12 @@ def configure(config): def setup(bot): # Inject KICK - botlogs.log('SpiceBot_Kick', "Implanting Kick function into bot") + SpiceBot.botlogs.log('SpiceBot_Kick', "Implanting Kick function into bot") bot.kick = SopelKICK.kick sopel.bot.SopelWrapper.kick = SopelWrapperKICK.kick # verify config settings for server - botlogs.log('SpiceBot_Kick', "Checking for config settings") + SpiceBot.botlogs.log('SpiceBot_Kick', "Checking for config settings") bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) diff --git a/sopel_modules/SpiceBot_Logs/IRC_Events b/sopel_modules/SpiceBot_Logs/IRC_Events index 84ccc84..de5eb52 100644 --- a/sopel_modules/SpiceBot_Logs/IRC_Events +++ b/sopel_modules/SpiceBot_Logs/IRC_Events @@ -5,1262 +5,1262 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi # sopel imports import sopel.module -from sopel_modules.SpiceBot.Logs import botlogs +import sopel_modules.SpiceBot as SpiceBot @sopel.moduleevent('NICK') @sopel.modulerule('.*') def parse_event_NICK(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.moduleevent('QUIT') @sopel.modulerule('.*') def parse_event_QUIT(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.moduleevent('PART') def parse_event_PART(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.moduleevent('MODE') @sopel.modulerule('.*') def parse_event_MODE(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.moduleevent('KICK') @sopel.modulerule('.*') def parse_event_KICK(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.moduleevent('JOIN') @sopel.modulerule('.*') def parse_event_JOIN(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.moduleevent('INVITE') @sopel.modulerule('.*') def parse_event_INVITE(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.moduleevent('TOPIC') @sopel.modulerule('.*') def parse_event_TOPIC(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WELCOME = '001' @sopel.moduleevent('001') @sopel.modulerule('.*') def parse_event_001(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_YOURHOST = '002' @sopel.moduleevent('002') @sopel.modulerule('.*') def parse_event_002(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_CREATED = '003' @sopel.moduleevent('003') @sopel.modulerule('.*') def parse_event_003(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MYINFO = '004' @sopel.moduleevent('004') @sopel.modulerule('.*') def parse_event_004(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_BOUNCE = '005' @sopel.moduleevent('005') @sopel.modulerule('.*') def parse_event_005(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ISUPPORT = '005' @sopel.moduleevent('005') @sopel.modulerule('.*') def parse_event_005b(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACELINK = '200' @sopel.moduleevent('200') @sopel.modulerule('.*') def parse_event_200(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACECONNECTING = '201' @sopel.moduleevent('201') @sopel.modulerule('.*') def parse_event_201(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEHANDSHAKE = '202' @sopel.moduleevent('202') @sopel.modulerule('.*') def parse_event_202(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEUNKNOWN = '203' @sopel.moduleevent('203') @sopel.modulerule('.*') def parse_event_203(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEOPERATOR = '204' @sopel.moduleevent('204') @sopel.modulerule('.*') def parse_event_204(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEUSER = '205' @sopel.moduleevent('205') @sopel.modulerule('.*') def parse_event_205(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACESERVER = '206' @sopel.moduleevent('206') @sopel.modulerule('.*') def parse_event_206(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACESERVICE = '207' @sopel.moduleevent('207') @sopel.modulerule('.*') def parse_event_207(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACENEWTYPE = '208' @sopel.moduleevent('208') @sopel.modulerule('.*') def parse_event_208(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACECLASS = '209' @sopel.moduleevent('209') @sopel.modulerule('.*') def parse_event_209(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACERECONNECT = '210' @sopel.moduleevent('210') @sopel.modulerule('.*') def parse_event_210(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSLINKINFO = '211' @sopel.moduleevent('211') @sopel.modulerule('.*') def parse_event_211(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSCOMMANDS = '212' @sopel.moduleevent('212') @sopel.modulerule('.*') def parse_event_212(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSCLINE = '213' @sopel.moduleevent('213') @sopel.modulerule('.*') def parse_event_213(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSNLINE = '214' @sopel.moduleevent('214') @sopel.modulerule('.*') def parse_event_214(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSILINE = '215' @sopel.moduleevent('215') @sopel.modulerule('.*') def parse_event_215(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSKLINE = '216' @sopel.moduleevent('216') @sopel.modulerule('.*') def parse_event_216(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSYLINE = '218' @sopel.moduleevent('218') @sopel.modulerule('.*') def parse_event_218(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFSTATS = '219' @sopel.moduleevent('219') @sopel.modulerule('.*') def parse_event_219(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_UMODEIS = '221' @sopel.moduleevent('221') @sopel.modulerule('.*') def parse_event_221(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SERVLIST = '234' @sopel.moduleevent('234') @sopel.modulerule('.*') def parse_event_234(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SERVLISTEND = '235' @sopel.moduleevent('235') @sopel.modulerule('.*') def parse_event_235(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSLLINE = '241' @sopel.moduleevent('241') @sopel.modulerule('.*') def parse_event_241(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSUPTIME = '242' @sopel.moduleevent('242') @sopel.modulerule('.*') def parse_event_242(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSOLINE = '243' @sopel.moduleevent('243') @sopel.modulerule('.*') def parse_event_243(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSHLINE = '244' @sopel.moduleevent('244') @sopel.modulerule('.*') def parse_event_244(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERCLIENT = '251' @sopel.moduleevent('251') @sopel.modulerule('.*') def parse_event_251(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSEROP = '252' @sopel.moduleevent('252') @sopel.modulerule('.*') def parse_event_252(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERUNKNOWN = '253' @sopel.moduleevent('253') @sopel.modulerule('.*') def parse_event_253(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERCHANNELS = '254' @sopel.moduleevent('254') @sopel.modulerule('.*') def parse_event_254(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERME = '255' @sopel.moduleevent('255') @sopel.modulerule('.*') def parse_event_255(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINME = '256' @sopel.moduleevent('256') @sopel.modulerule('.*') def parse_event_256(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINLOC1 = '257' @sopel.moduleevent('257') @sopel.modulerule('.*') def parse_event_257(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINLOC2 = '258' @sopel.moduleevent('258') @sopel.modulerule('.*') def parse_event_258(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINEMAIL = '259' @sopel.moduleevent('259') @sopel.modulerule('.*') def parse_event_259(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACELOG = '261' @sopel.moduleevent('261') @sopel.modulerule('.*') def parse_event_261(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEEND = '262' @sopel.moduleevent('262') @sopel.modulerule('.*') def parse_event_262(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRYAGAIN = '263' @sopel.moduleevent('263') @sopel.modulerule('.*') def parse_event_263(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NONE = '300' @sopel.moduleevent('300') @sopel.modulerule('.*') def parse_event_300(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_AWAY = '301' @sopel.moduleevent('301') @sopel.modulerule('.*') def parse_event_301(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_USERHOST = '302' @sopel.moduleevent('302') @sopel.modulerule('.*') def parse_event_302(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ISON = '303' @sopel.moduleevent('303') @sopel.modulerule('.*') def parse_event_303(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_UNAWAY = '305' @sopel.moduleevent('305') @sopel.modulerule('.*') def parse_event_305(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NOWAWAY = '306' @sopel.moduleevent('306') @sopel.modulerule('.*') def parse_event_306(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISUSER = '311' @sopel.moduleevent('311') @sopel.modulerule('.*') def parse_event_311(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISSERVER = '312' @sopel.moduleevent('312') @sopel.modulerule('.*') def parse_event_312(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISOPERATOR = '313' @sopel.moduleevent('313') @sopel.modulerule('.*') def parse_event_313(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOWASUSER = '314' @sopel.moduleevent('314') @sopel.modulerule('.*') def parse_event_314(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFWHO = '315' @sopel.moduleevent('315') @sopel.modulerule('.*') def parse_event_315(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISIDLE = '317' @sopel.moduleevent('317') @sopel.modulerule('.*') def parse_event_317(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFWHOIS = '318' @sopel.moduleevent('318') @sopel.modulerule('.*') def parse_event_318(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISCHANNELS = '319' @sopel.moduleevent('319') @sopel.modulerule('.*') def parse_event_319(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LISTSTART = '321' @sopel.moduleevent('321') @sopel.modulerule('.*') def parse_event_321(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LIST = '322' @sopel.moduleevent('322') @sopel.modulerule('.*') def parse_event_322(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LISTEND = '323' @sopel.moduleevent('323') @sopel.modulerule('.*') def parse_event_323(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_CHANNELMODEIS = '324' @sopel.moduleevent('324') @sopel.modulerule('.*') def parse_event_324(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_UNIQOPIS = '325' @sopel.moduleevent('325') @sopel.modulerule('.*') def parse_event_325(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NOTOPIC = '331' @sopel.moduleevent('331') @sopel.modulerule('.*') def parse_event_331(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TOPIC = '332' @sopel.moduleevent('332') @sopel.modulerule('.*') def parse_event_332(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_INVITING = '341' @sopel.moduleevent('341') @sopel.modulerule('.*') def parse_event_341(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SUMMONING = '342' @sopel.moduleevent('342') @sopel.modulerule('.*') def parse_event_342(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_INVITELIST = '346' @sopel.moduleevent('346') @sopel.modulerule('.*') def parse_event_346(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFINVITELIST = '347' @sopel.moduleevent('347') @sopel.modulerule('.*') def parse_event_347(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_EXCEPTLIST = '348' @sopel.moduleevent('348') @sopel.modulerule('.*') def parse_event_348(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFEXCEPTLIST = '349' @sopel.moduleevent('349') @sopel.modulerule('.*') def parse_event_349(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_VERSION = '351' @sopel.moduleevent('351') @sopel.modulerule('.*') def parse_event_351(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOREPLY = '352' @sopel.moduleevent('352') @sopel.modulerule('.*') def parse_event_352(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NAMREPLY = '353' @sopel.moduleevent('353') @sopel.modulerule('.*') def parse_event_353(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOSPCRPL = '354' @sopel.moduleevent('354') @sopel.modulerule('.*') def parse_event_354(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LINKS = '364' @sopel.moduleevent('364') @sopel.modulerule('.*') def parse_event_364(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFLINKS = '365' @sopel.moduleevent('365') @sopel.modulerule('.*') def parse_event_365(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFNAMES = '366' @sopel.moduleevent('366') @sopel.modulerule('.*') def parse_event_366(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_BANLIST = '367' @sopel.moduleevent('367') @sopel.modulerule('.*') def parse_event_367(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFBANLIST = '368' @sopel.moduleevent('368') @sopel.modulerule('.*') def parse_event_368(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFWHOWAS = '369' @sopel.moduleevent('369') @sopel.modulerule('.*') def parse_event_369(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_INFO = '371' @sopel.moduleevent('371') @sopel.modulerule('.*') def parse_event_371(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MOTD = '372' @sopel.moduleevent('372') @sopel.modulerule('.*') def parse_event_372(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFINFO = '374' @sopel.moduleevent('374') @sopel.modulerule('.*') def parse_event_374(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MOTDSTART = '375' @sopel.moduleevent('375') @sopel.modulerule('.*') def parse_event_375(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFMOTD = '376' @sopel.moduleevent('376') @sopel.modulerule('.*') def parse_event_376(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_YOUREOPER = '381' @sopel.moduleevent('381') @sopel.modulerule('.*') def parse_event_381(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_REHASHING = '382' @sopel.moduleevent('382') @sopel.modulerule('.*') def parse_event_382(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_YOURESERVICE = '383' @sopel.moduleevent('383') @sopel.modulerule('.*') def parse_event_383(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TIME = '391' @sopel.moduleevent('391') @sopel.modulerule('.*') def parse_event_391(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_USERSSTART = '392' @sopel.moduleevent('392') @sopel.modulerule('.*') def parse_event_392(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_USERS = '393' @sopel.moduleevent('393') @sopel.modulerule('.*') def parse_event_393(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFUSERS = '394' @sopel.moduleevent('394') @sopel.modulerule('.*') def parse_event_394(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NOUSERS = '395' @sopel.moduleevent('395') @sopel.modulerule('.*') def parse_event_395(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHNICK = '401' @sopel.moduleevent('401') @sopel.modulerule('.*') def parse_event_401(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHSERVER = '402' @sopel.moduleevent('402') @sopel.modulerule('.*') def parse_event_402(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHCHANNEL = '403' @sopel.moduleevent('403') @sopel.modulerule('.*') def parse_event_403(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CANNOTSENDTOCHAN = '404' @sopel.moduleevent('404') @sopel.modulerule('.*') def parse_event_404(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_TOOMANYCHANNELS = '405' @sopel.moduleevent('405') @sopel.modulerule('.*') def parse_event_405(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_WASNOSUCHNICK = '406' @sopel.moduleevent('406') @sopel.modulerule('.*') def parse_event_406(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_TOOMANYTARGETS = '407' @sopel.moduleevent('407') @sopel.modulerule('.*') def parse_event_407(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHSERVICE = '408' @sopel.moduleevent('408') @sopel.modulerule('.*') def parse_event_408(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOORIGIN = '409' @sopel.moduleevent('409') @sopel.modulerule('.*') def parse_event_409(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_INVALIDCAPCMD = '410' @sopel.moduleevent('410') @sopel.modulerule('.*') def parse_event_410(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NORECIPIENT = '411' @sopel.moduleevent('411') @sopel.modulerule('.*') def parse_event_411(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTEXTTOSEND = '412' @sopel.moduleevent('412') @sopel.modulerule('.*') def parse_event_412(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTOPLEVEL = '413' @sopel.moduleevent('413') @sopel.modulerule('.*') def parse_event_413(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_WILDTOPLEVEL = '414' @sopel.moduleevent('414') @sopel.modulerule('.*') def parse_event_414(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BADMASK = '415' @sopel.moduleevent('415') @sopel.modulerule('.*') def parse_event_415(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNKNOWNCOMMAND = '421' @sopel.moduleevent('421') @sopel.modulerule('.*') def parse_event_421(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOMOTD = '422' @sopel.moduleevent('422') @sopel.modulerule('.*') def parse_event_422(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOADMININFO = '423' @sopel.moduleevent('423') @sopel.modulerule('.*') def parse_event_423(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_FILEERROR = '424' @sopel.moduleevent('424') @sopel.modulerule('.*') def parse_event_424(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NONICKNAMEGIVEN = '431' @sopel.moduleevent('431') @sopel.modulerule('.*') def parse_event_431(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_ERRONEUSNICKNAME = '432' @sopel.moduleevent('432') @sopel.modulerule('.*') def parse_event_432(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NICKNAMEINUSE = '433' @sopel.moduleevent('433') @sopel.modulerule('.*') def parse_event_433(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NICKCOLLISION = '436' @sopel.moduleevent('436') @sopel.modulerule('.*') def parse_event_436(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNAVAILRESOURCE = '437' @sopel.moduleevent('437') @sopel.modulerule('.*') def parse_event_437(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERNOTINCHANNEL = '441' @sopel.moduleevent('441') @sopel.modulerule('.*') def parse_event_441(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTONCHANNEL = '442' @sopel.moduleevent('442') @sopel.modulerule('.*') def parse_event_442(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERONCHANNEL = '443' @sopel.moduleevent('443') @sopel.modulerule('.*') def parse_event_443(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOLOGIN = '444' @sopel.moduleevent('444') @sopel.modulerule('.*') def parse_event_444(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SUMMONDISABLED = '445' @sopel.moduleevent('445') @sopel.modulerule('.*') def parse_event_445(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERSDISABLED = '446' @sopel.moduleevent('446') @sopel.modulerule('.*') def parse_event_446(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTREGISTERED = '451' @sopel.moduleevent('451') @sopel.modulerule('.*') def parse_event_451(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NEEDMOREPARAMS = '461' @sopel.moduleevent('461') @sopel.modulerule('.*') def parse_event_461(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_ALREADYREGISTRED = '462' @sopel.moduleevent('462') @sopel.modulerule('.*') def parse_event_462(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOPERMFORHOST = '463' @sopel.moduleevent('463') @sopel.modulerule('.*') def parse_event_463(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_PASSWDMISMATCH = '464' @sopel.moduleevent('464') @sopel.modulerule('.*') def parse_event_464(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_YOUREBANNEDCREEP = '465' @sopel.moduleevent('465') @sopel.modulerule('.*') def parse_event_465(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_YOUWILLBEBANNED = '466' @sopel.moduleevent('466') @sopel.modulerule('.*') def parse_event_466(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYSET = '467' @sopel.moduleevent('467') @sopel.modulerule('.*') def parse_event_467(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CHANNELISFULL = '471' @sopel.moduleevent('471') @sopel.modulerule('.*') def parse_event_471(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNKNOWNMODE = '472' @sopel.moduleevent('472') @sopel.modulerule('.*') def parse_event_472(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_INVITEONLYCHAN = '473' @sopel.moduleevent('473') @sopel.modulerule('.*') def parse_event_473(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BANNEDFROMCHAN = '474' @sopel.moduleevent('474') @sopel.modulerule('.*') def parse_event_474(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BADCHANNELKEY = '475' @sopel.moduleevent('475') @sopel.modulerule('.*') def parse_event_475(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BADCHANMASK = '476' @sopel.moduleevent('476') @sopel.modulerule('.*') def parse_event_476(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOCHANMODES = '477' @sopel.moduleevent('477') @sopel.modulerule('.*') def parse_event_477(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BANLISTFULL = '478' @sopel.moduleevent('478') @sopel.modulerule('.*') def parse_event_478(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOPRIVILEGES = '481' @sopel.moduleevent('481') @sopel.modulerule('.*') def parse_event_481(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CHANOPRIVSNEEDED = '482' @sopel.moduleevent('482') @sopel.modulerule('.*') def parse_event_482(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CANTKILLSERVER = '483' @sopel.moduleevent('483') @sopel.modulerule('.*') def parse_event_483(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_RESTRICTED = '484' @sopel.moduleevent('484') @sopel.modulerule('.*') def parse_event_484(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNIQOPPRIVSNEEDED = '485' @sopel.moduleevent('485') @sopel.modulerule('.*') def parse_event_485(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOOPERHOST = '491' @sopel.moduleevent('491') @sopel.modulerule('.*') def parse_event_491(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UMODEUNKNOWNFLAG = '501' @sopel.moduleevent('501') @sopel.modulerule('.*') def parse_event_501(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERSDONTMATCH = '502' @sopel.moduleevent('502') @sopel.modulerule('.*') def parse_event_502(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STARTTLS = '670' @sopel.moduleevent('670') @sopel.modulerule('.*') def parse_event_670(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_STARTTLS = '691' @sopel.moduleevent('691') @sopel.modulerule('.*') def parse_event_691(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MONONLINE = '730' @sopel.moduleevent('730') @sopel.modulerule('.*') def parse_event_730(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MONOFFLINE = '731' @sopel.moduleevent('731') @sopel.modulerule('.*') def parse_event_731(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MONLIST = '732' @sopel.moduleevent('732') @sopel.modulerule('.*') def parse_event_732(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFMONLIST = '733' @sopel.moduleevent('733') @sopel.modulerule('.*') def parse_event_733(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_MONLISTFULL = '734' @sopel.moduleevent('734') @sopel.modulerule('.*') def parse_event_734(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISKEYVALUE = '760' @sopel.moduleevent('760') @sopel.modulerule('.*') def parse_event_760(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_KEYVALUE = '761' @sopel.moduleevent('761') @sopel.modulerule('.*') def parse_event_761(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_METADATAEND = '762' @sopel.moduleevent('762') @sopel.modulerule('.*') def parse_event_762(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_METADATALIMIT = '764' @sopel.moduleevent('764') @sopel.modulerule('.*') def parse_event_764(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_TARGETINVALID = '765' @sopel.moduleevent('765') @sopel.modulerule('.*') def parse_event_765(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOMATCHINGKEY = '766' @sopel.moduleevent('766') @sopel.modulerule('.*') def parse_event_766(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYINVALID = '767' @sopel.moduleevent('767') @sopel.modulerule('.*') def parse_event_767(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYNOTSET = '768' @sopel.moduleevent('768') @sopel.modulerule('.*') def parse_event_768(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYNOPERMISSION = '769' @sopel.moduleevent('769') @sopel.modulerule('.*') def parse_event_769(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LOGGEDIN = '900' @sopel.moduleevent('900') @sopel.modulerule('.*') def parse_event_900(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LOGGEDOUT = '901' @sopel.moduleevent('901') @sopel.modulerule('.*') def parse_event_901(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NICKLOCKED = '902' @sopel.moduleevent('902') @sopel.modulerule('.*') def parse_event_902(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SASLSUCCESS = '903' @sopel.moduleevent('903') @sopel.modulerule('.*') def parse_event_903(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLFAIL = '904' @sopel.moduleevent('904') @sopel.modulerule('.*') def parse_event_904(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLTOOLONG = '905' @sopel.moduleevent('905') @sopel.modulerule('.*') def parse_event_905(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLABORTED = '906' @sopel.moduleevent('906') @sopel.modulerule('.*') def parse_event_906(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLALREADY = '907' @sopel.moduleevent('907') @sopel.modulerule('.*') def parse_event_907(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SASLMECHS = '908' @sopel.moduleevent('908') @sopel.modulerule('.*') def parse_event_908(bot, trigger): - botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) diff --git a/sopel_modules/SpiceBot_Logs/Logs_Command.py b/sopel_modules/SpiceBot_Logs/Logs_Command.py index 6796a6e..2917e09 100644 --- a/sopel_modules/SpiceBot_Logs/Logs_Command.py +++ b/sopel_modules/SpiceBot_Logs/Logs_Command.py @@ -5,28 +5,26 @@ import sopel.module import spicemanip -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot.Tools import sopel_triggerargs, command_permissions_check, inlist, inlist_match, similar_list +import sopel_modules.SpiceBot as SpiceBot -@botevents.check_ready([botevents.BOT_LOGS]) +@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOGS]) @sopel.module.nickname_commands('logs', 'debug') def bot_command_logs(bot, trigger): - if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + if not SpiceBot.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 - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') + triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') logtype = spicemanip.main(triggerargs, 1) or None if not logtype: - bot.osd("Current valid log(s) include: " + spicemanip.main(botlogs.SpiceBot_Logs["list"].keys(), 'andlist'), trigger.sender, 'action') + bot.osd("Current valid log(s) include: " + spicemanip.main(SpiceBot.botlogs.SpiceBot_Logs["list"].keys(), 'andlist'), trigger.sender, 'action') return - if not inlist(logtype, botlogs.SpiceBot_Logs["list"].keys()): - closestmatches = similar_list(bot, logtype, botlogs.SpiceBot_Logs["list"].keys(), 10, 'reverse') + if not SpiceBot.inlist(logtype, SpiceBot.botlogs.SpiceBot_Logs["list"].keys()): + closestmatches = SpiceBot.similar_list(bot, logtype, SpiceBot.botlogs.SpiceBot_Logs["list"].keys(), 10, 'reverse') if not len(closestmatches): bot.notice("No valid logs match " + str(logtype) + ".", trigger.nick) else: @@ -34,14 +32,14 @@ def bot_command_logs(bot, trigger): return - logtype = inlist_match(logtype, botlogs.SpiceBot_Logs["list"].keys()) + logtype = SpiceBot.inlist_match(logtype, SpiceBot.botlogs.SpiceBot_Logs["list"].keys()) if logtype == "Sopel_systemd": - logindex = botlogs.systemd_logs_fetch(bot) + logindex = SpiceBot.botlogs.systemd_logs_fetch(bot) elif logtype == "Sopel_stdio": - logindex = botlogs.stdio_logs_fetch(bot) + logindex = SpiceBot.botlogs.stdio_logs_fetch(bot) else: - logindex = botlogs.SpiceBot_Logs["list"][logtype] + logindex = SpiceBot.botlogs.SpiceBot_Logs["list"][logtype] if not len(logindex): bot.osd("No logs found for " + str(logtype) + ".") diff --git a/sopel_modules/SpiceBot_Logs/Queue.py b/sopel_modules/SpiceBot_Logs/Queue.py index 784efa7..0b93ff8 100644 --- a/sopel_modules/SpiceBot_Logs/Queue.py +++ b/sopel_modules/SpiceBot_Logs/Queue.py @@ -5,17 +5,16 @@ import sopel.module import sopel.tools import sopel.config -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Events import botevents +import sopel_modules.SpiceBot as SpiceBot def setup(bot): - botlogs.log('SpiceBot_Logs', "Starting Setup Procedure") - botevents.startup_add([botevents.BOT_LOGS]) - botevents.trigger(bot, botevents.BOT_LOGS, "SpiceBot_Logs") + SpiceBot.botlogs.log('SpiceBot_Logs', "Starting Setup Procedure") + SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_LOGS]) + SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_LOGS, "SpiceBot_Logs") -@sopel.module.event(botevents.RPL_WELCOME) +@sopel.module.event(SpiceBot.botevents.RPL_WELCOME) @sopel.module.rule('.*') def join_log_channel(bot, trigger): @@ -27,9 +26,9 @@ def join_log_channel(bot, trigger): bot.write(('SAJOIN', bot.nick, channel)) while True: - if len(botlogs.SpiceBot_Logs["queue"]): - bot.say(str(botlogs.SpiceBot_Logs["queue"][0]), channel) - del botlogs.SpiceBot_Logs["queue"][0] + if len(SpiceBot.botlogs.SpiceBot_Logs["queue"]): + bot.say(str(SpiceBot.botlogs.SpiceBot_Logs["queue"][0]), channel) + del SpiceBot.botlogs.SpiceBot_Logs["queue"][0] else: - botlogs.sopel_config["logging_channel"] = False - botlogs.SpiceBot_Logs["queue"] = [] + SpiceBot.botlogs.sopel_config["logging_channel"] = False + SpiceBot.botlogs.SpiceBot_Logs["queue"] = [] diff --git a/sopel_modules/SpiceBot_Messaging/Messaging.py b/sopel_modules/SpiceBot_Messaging/Messaging.py index 0ba7a74..17754ac 100644 --- a/sopel_modules/SpiceBot_Messaging/Messaging.py +++ b/sopel_modules/SpiceBot_Messaging/Messaging.py @@ -6,8 +6,7 @@ import sopel.module import spicemanip -from sopel_modules.SpiceBot.Channels import botchannels -from sopel_modules.SpiceBot.Tools import sopel_triggerargs, command_permissions_check, inlist +import sopel_modules.SpiceBot as SpiceBot @sopel.module.nickname_commands('action') @@ -27,11 +26,11 @@ def bot_command_privmsg(bot, trigger): def bot_command_process(bot, trigger): - if not command_permissions_check(bot, trigger, ['admins', 'owner']): + if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner']): bot.say("I was unable to process this Bot Nick command due to privilege issues.") return - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') + triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') if triggercommand in ['say', 'msg']: triggercommand = 'privmsg' @@ -42,8 +41,8 @@ def bot_command_process(bot, trigger): target = spicemanip.main(triggerargs, 1) if (target not in ['allchans', 'allnicks'] - and not inlist(target.lower(), botchannels.SpiceBot_Channels['list'].keys()) - and not inlist(target.lower(), bot.users)): + and not SpiceBot.inlist(target.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys()) + and not SpiceBot.inlist(target.lower(), bot.users)): bot.osd("Channel/nick name {} not valid.".format(target)) return diff --git a/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py b/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py index c7a59e9..31c392c 100644 --- a/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py +++ b/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py @@ -7,16 +7,14 @@ import sopel.module import os -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot.Commands import botcommands +import sopel_modules.SpiceBot as SpiceBot import spicemanip def setup(bot): - botlogs.log('SpiceBot_CommandsQuery', "Starting setup procedure") - botevents.startup_add([botevents.BOT_COMMANDSQUERY]) + SpiceBot.botlogs.log('SpiceBot_CommandsQuery', "Starting setup procedure") + SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_COMMANDSQUERY]) filepathlisting = [] @@ -38,7 +36,7 @@ def setup(bot): pypi_modules_dir = os.path.join(plugin_dir, pathname) filepathlisting.append(pypi_modules_dir) except Exception as e: - botlogs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) + SpiceBot.botlogs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) # Extra directories filepathlist = [] @@ -122,7 +120,7 @@ def setup(bot): currentsuccesslines += 1 if currentsuccesslines: - botcommands.SpiceBot_Commands['counts'] += 1 + SpiceBot.botcommands.SpiceBot_Commands['counts'] += 1 if len(filelinelist): for atlinefound in filelinelist: @@ -142,27 +140,27 @@ def setup(bot): else: comaliases = [] - botcommands.SpiceBot_Commands['commands'][comtype][maincom] = dict_from_file + SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype][maincom] = dict_from_file for comalias in comaliases: - if comalias not in botcommands.SpiceBot_Commands['commands'][comtype].keys(): - botcommands.SpiceBot_Commands['commands'][comtype][comalias] = {"aliasfor": maincom} + if comalias not in SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype].keys(): + SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype][comalias] = {"aliasfor": maincom} for comtype in ['module', 'nickname', 'rule']: - botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) + SpiceBot.botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) - for command in botcommands.SpiceBot_Commands['commands']['rule'].keys(): + for command in SpiceBot.botcommands.SpiceBot_Commands['commands']['rule'].keys(): if command.startswith("$nickname"): command = command.split("$nickname")[-1] - if command not in botcommands.SpiceBot_Commands['nickrules']: - botcommands.SpiceBot_Commands['nickrules'].append(command) + if command not in SpiceBot.botcommands.SpiceBot_Commands['nickrules']: + SpiceBot.botcommands.SpiceBot_Commands['nickrules'].append(command) - botevents.trigger(bot, botevents.BOT_COMMANDSQUERY, "SpiceBot_CommandsQuery") + SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_COMMANDSQUERY, "SpiceBot_CommandsQuery") -@sopel.module.event(botevents.BOT_LOADED) +@sopel.module.event(SpiceBot.botevents.BOT_LOADED) @sopel.module.rule('.*') def bot_events_complete(bot, trigger): - for comtype in botcommands.SpiceBot_Commands['commands'].keys(): + for comtype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys(): if comtype not in ['module', 'nickname', 'rule']: - botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) + SpiceBot.botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) diff --git a/sopel_modules/SpiceBot_Restart/Restart.py b/sopel_modules/SpiceBot_Restart/Restart.py index 608f9bc..76d5f56 100644 --- a/sopel_modules/SpiceBot_Restart/Restart.py +++ b/sopel_modules/SpiceBot_Restart/Restart.py @@ -5,8 +5,7 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi # sopel imports import sopel.module -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Tools import spicebot_reload +import sopel_modules.SpiceBot as SpiceBot @sopel.module.nickname_commands('restart') @@ -16,8 +15,8 @@ def nickname_comand_restart(bot, trigger): bot.say("You are not authorized to perform this function.") quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!" - botlogs.log('SpiceBot_Restart', quitmessage) + SpiceBot.botlogs.log('SpiceBot_Restart', quitmessage) bot.osd(quitmessage, bot.channels.keys()) # service_manip(bot, bot.nick, 'restart', 'SpiceBot_Restart') - spicebot_reload(bot, 'SpiceBot_Restart', quitmessage) + SpiceBot.spicebot_reload(bot, 'SpiceBot_Restart', quitmessage) diff --git a/sopel_modules/SpiceBot_SopelPatches/Patches.py b/sopel_modules/SpiceBot_SopelPatches/Patches.py index 2a00d35..4df1c1e 100644 --- a/sopel_modules/SpiceBot_SopelPatches/Patches.py +++ b/sopel_modules/SpiceBot_SopelPatches/Patches.py @@ -6,15 +6,14 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi import sopel import sopel.module -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Tools import stock_modules_begone +import sopel_modules.SpiceBot as SpiceBot def setup(bot): - botlogs.log('Sopel_Patch', "Patching Sopels built-in url_callbacks") + SpiceBot.botlogs.log('Sopel_Patch', "Patching Sopels built-in url_callbacks") if 'url_callbacks' not in bot.memory: bot.memory['url_callbacks'] = sopel.tools.SopelMemory() - botlogs.log('Sopel_Patch', "Removing Stock Modules and verifying Dummy Command is present.") - stock_modules_begone(bot) + SpiceBot.botlogs.log('Sopel_Patch', "Removing Stock Modules and verifying Dummy Command is present.") + SpiceBot.stock_modules_begone(bot) diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py index bd9dd6f..9ffdaeb 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py @@ -4,13 +4,12 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Events import botevents +import sopel_modules.SpiceBot as SpiceBot def setup(bot): - botlogs.log('SpiceBot_StartupMonologue', "Starting setup procedure") - botevents.startup_add([botevents.BOT_STARTUPMONOLOGUE_CHANNELS, botevents.BOT_STARTUPMONOLOGUE_COMMANDSQUERY]) # , botevents.BOT_STARTUPMONOLOGUE_CONNECTED]) + SpiceBot.botlogs.log('SpiceBot_StartupMonologue', "Starting setup procedure") + SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CHANNELS, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_COMMANDSQUERY]) # ,SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CONNECTED]) if 'SpiceBot_StartupMonologue' not in bot.memory: bot.memory['SpiceBot_StartupMonologue'] = [] diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py index b8254be..983e3e5 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py @@ -4,18 +4,16 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot.Channels import botchannels +import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(botevents.BOT_CHANNELS) +@sopel.module.event(SpiceBot.botevents.BOT_CHANNELS) @sopel.module.rule('.*') def bot_startup_monologue_channels(bot, trigger): botcount = len(bot.channels.keys()) - servercount = len(botchannels.SpiceBot_Channels['list'].keys()) + servercount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys()) bot.memory['SpiceBot_StartupMonologue'].append("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") - botlogs.log('SpiceBot_StartupMonologue', "I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") + SpiceBot.botlogs.log('SpiceBot_StartupMonologue', "I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") - botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE_CHANNELS, "SpiceBot_StartupMonologue") + SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CHANNELS, "SpiceBot_StartupMonologue") diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py index f613f50..a9132b9 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py @@ -4,21 +4,19 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot.Commands import botcommands +import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(botevents.BOT_COMMANDSQUERY) +@sopel.module.event(SpiceBot.botevents.BOT_COMMANDSQUERY) @sopel.module.rule('.*') def bot_startup_monologue_commands(bot, trigger): availablecomsnum, availablecomsfiles = 0, 0 - for commandstype in botcommands.SpiceBot_Commands['commands'].keys(): - availablecomsnum += len(botcommands.SpiceBot_Commands['commands'][commandstype].keys()) - availablecomsfiles += botcommands.SpiceBot_Commands['counts'] + for commandstype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys(): + availablecomsnum += len(SpiceBot.botcommands.SpiceBot_Commands['commands'][commandstype].keys()) + availablecomsfiles += SpiceBot.botcommands.SpiceBot_Commands['counts'] bot.memory['SpiceBot_StartupMonologue'].append("There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.") - botlogs.log('SpiceBot_StartupMonologue', "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.") + SpiceBot.botlogs.log('SpiceBot_StartupMonologue', "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.") - botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue") + SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue") diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py index e829d82..4132e87 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py @@ -4,16 +4,15 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Events import botevents +import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(botevents.BOT_CONNECTED) +@sopel.module.event(SpiceBot.botevents.BOT_CONNECTED) @sopel.module.rule('.*') def bot_startup_monologue_start(bot, trigger): # Startup - botlogs.log('SpiceBot_StartupMonologue', bot.nick + " is now starting. Please wait while I load my configuration") + SpiceBot.botlogs.log('SpiceBot_StartupMonologue', bot.nick + " is now starting. Please wait while I load my configuration") bot.osd(" is now starting. Please wait while I load my configuration.", bot.channels.keys(), 'ACTION') - botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue") + SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue") diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py index d075cff..dffc532 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py @@ -3,15 +3,14 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Events import botevents +import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(botevents.BOT_STARTUPMONOLOGUE) +@sopel.module.event(SpiceBot.botevents.BOT_STARTUPMONOLOGUE) @sopel.module.rule('.*') def bot_startup_monologue_start(bot, trigger): - debuglines = botlogs.stdio_logs_fetch(bot) + debuglines = SpiceBot.botlogs.stdio_logs_fetch(bot) searchphrasefound = [] for line in debuglines: @@ -20,9 +19,9 @@ def bot_startup_monologue_start(bot, trigger): if len(searchphrasefound): for foundphase in searchphrasefound: - botlogs.log('SpiceBot_Logs', str(foundphase)) + SpiceBot.botlogs.log('SpiceBot_Logs', str(foundphase)) searchphrasefound.insert(0, "Notice to Bot Admins: ") searchphrasefound.append("Run the debug command for more information.") bot.osd(searchphrasefound, bot.channels.keys()) else: - botlogs.log('SpiceBot_Logs', "No issues found at bot startup!", True) + SpiceBot.botlogs.log('SpiceBot_Logs', "No issues found at bot startup!", True) diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py index 7941f57..84e1503 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py @@ -4,26 +4,24 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel.module -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot.Tools import humanized_time +import sopel_modules.SpiceBot as SpiceBot import time -@sopel.module.event(botevents.BOT_LOADED) +@sopel.module.event(SpiceBot.botevents.BOT_LOADED) @sopel.module.rule('.*') def bot_startup_monologue_display(bot, trigger): - if botevents.SpiceBot_Events["RPL_WELCOME_Count"] == 1: - timesince = humanized_time(time.time() - bot.memory["SpiceBot_Uptime"]) - bot.memory['SpiceBot_StartupMonologue'].append("Startup took " + timesince) + if SpiceBot.botevents.SpiceBot_Events["RPL_WELCOME_Count"] == 1: + timesince = SpiceBot.humanized_time(time.time() - bot.memory["SpiceBot_Uptime"]) + SpiceBot.bot.memory['SpiceBot_StartupMonologue'].append("Startup took " + timesince) # Announce to chan, then handle some closing stuff - botlogs.log('SpiceBot_StartupMonologue', bot.nick + " startup complete") + SpiceBot.botlogs.log('SpiceBot_StartupMonologue', bot.nick + " startup complete") bot.memory['SpiceBot_StartupMonologue'].insert(0, " startup complete") bot.osd(bot.memory['SpiceBot_StartupMonologue'], bot.channels.keys(), 'ACTION') - botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue") - botlogs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True) + SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue") + SpiceBot.botlogs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True) diff --git a/sopel_modules/SpiceBot_Update/Update.py b/sopel_modules/SpiceBot_Update/Update.py index 0d7e666..cda3d99 100644 --- a/sopel_modules/SpiceBot_Update/Update.py +++ b/sopel_modules/SpiceBot_Update/Update.py @@ -8,8 +8,7 @@ from sopel.config.types import StaticSection, ValidatedAttribute import spicemanip -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Tools import sopel_triggerargs, command_permissions_check, spicebot_reload, spicebot_update +import sopel_modules.SpiceBot as SpiceBot class SpiceBot_Update_MainSection(StaticSection): @@ -24,18 +23,18 @@ def configure(config): def setup(bot): - botlogs.log('SpiceBot_Update', "Initial Setup processing") + SpiceBot.botlogs.log('SpiceBot_Update', "Initial Setup processing") bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) @sopel.module.nickname_commands('update') def nickname_comand_update(bot, trigger): - if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + if not SpiceBot.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 - triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') + triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') if not len(triggerargs): commandused = 'nodeps' @@ -49,13 +48,13 @@ def nickname_comand_update(bot, trigger): triggerargs = spicemanip.main(triggerargs, '2+', 'list') quitmessage = "Received command from " + trigger.nick + " to update from Github and restart" - botlogs.log('SpiceBot_Update', quitmessage) + SpiceBot.botlogs.log('SpiceBot_Update', quitmessage) bot.osd(quitmessage, bot.channels.keys()) if commandused == 'nodeps': - spicebot_update(bot, False) + SpiceBot.spicebot_update(bot, False) if commandused == 'deps': - spicebot_update(bot, True) + SpiceBot.spicebot_update(bot, True) # service_manip(bot, bot.nick, 'restart', 'SpiceBot_Update') - spicebot_reload(bot, 'SpiceBot_Update', quitmessage) + SpiceBot.spicebot_reload(bot, 'SpiceBot_Update', quitmessage) diff --git a/sopel_modules/SpiceBot_Uptime/Uptime.py b/sopel_modules/SpiceBot_Uptime/Uptime.py index 067f796..5a82333 100644 --- a/sopel_modules/SpiceBot_Uptime/Uptime.py +++ b/sopel_modules/SpiceBot_Uptime/Uptime.py @@ -6,14 +6,13 @@ import sopel.module import time -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Tools import humanized_time +import sopel_modules.SpiceBot as SpiceBot def setup(bot): if 'SpiceBot_Uptime' not in bot.memory: now = time.time() - botlogs.log('SpiceBot_Uptime', "Start time set to " + str(time.time())) + SpiceBot.botlogs.log('SpiceBot_Uptime', "Start time set to " + str(time.time())) bot.memory["SpiceBot_Uptime"] = now @@ -24,5 +23,5 @@ def shutdown(bot): @sopel.module.nickname_commands('uptime') def bot_command_srewyou(bot, trigger): - timesince = str(humanized_time(time.time() - bot.memory["SpiceBot_Uptime"])) + " ago." + timesince = str(SpiceBot.humanized_time(time.time() - bot.memory["SpiceBot_Uptime"])) + " ago." bot.osd("I have been running since " + timesince) diff --git a/sopel_modules/SpiceBot_osd/__init__.py b/sopel_modules/SpiceBot_osd/__init__.py index 6beaa44..e753526 100644 --- a/sopel_modules/SpiceBot_osd/__init__.py +++ b/sopel_modules/SpiceBot_osd/__init__.py @@ -14,7 +14,7 @@ from sopel import tools, module from sopel.tools import Identifier from sopel.config.types import StaticSection, ValidatedAttribute -from sopel_modules.SpiceBot.Logs import botlogs +import sopel_modules.SpiceBot as SpiceBot import time from collections import abc @@ -40,7 +40,7 @@ def configure(config): def setup(bot): # Inject OSD - botlogs.log('SpiceBot_OSD', "Implanting OSD function into bot") + SpiceBot.botlogs.log('SpiceBot_OSD', "Implanting OSD function into bot") bot.osd = SopelOSD.osd sopel.bot.SopelWrapper.osd = SopelWrapperOSD.osd tools.get_available_message_bytes = ToolsOSD.get_available_message_bytes @@ -48,7 +48,7 @@ def setup(bot): tools.get_message_recipientgroups = ToolsOSD.get_message_recipientgroups # overwrite default bot messaging - botlogs.log('SpiceBot_OSD', "Overwrite Default Sopel messaging commands") + SpiceBot.botlogs.log('SpiceBot_OSD', "Overwrite Default Sopel messaging commands") bot.osd = SopelOSD.osd bot.say = SopelOSD.say bot.action = SopelOSD.action @@ -61,7 +61,7 @@ def setup(bot): sopel.bot.SopelWrapper.reply = SopelWrapperOSD.reply # verify config settings for server - botlogs.log('SpiceBot_OSD', "Checking for config settings") + SpiceBot.botlogs.log('SpiceBot_OSD', "Checking for config settings") bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) From 74177e4372f3f41480b2fbaa33d94117eaf544c9 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 11:28:42 -0400 Subject: [PATCH 011/328] Continue import logic --- sopel_modules/SpiceBot/Channels.py | 3 +++ sopel_modules/SpiceBot/Commands.py | 3 +++ sopel_modules/SpiceBot/Database.py | 3 +++ sopel_modules/SpiceBot/Events.py | 3 +++ sopel_modules/SpiceBot/Logs.py | 3 +++ sopel_modules/SpiceBot/Tools.py | 2 +- sopel_modules/SpiceBot/__init__.py | 7 ------- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index 622ca24..433b984 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -70,3 +70,6 @@ class BotChannels(): bot.write(('SAMODE', channel, "+a", bot.nick)) else: bot.part(channel) + + +botchannels = BotChannels() diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index f479f73..5a4eb99 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -51,3 +51,6 @@ class BotCommands(): for comalias in comaliases: if comalias not in self.SpiceBot_Commands['commands'][command_type].keys(): self.SpiceBot_Commands['commands'][command_type][comalias] = {"aliasfor": aliasfor} + + +botcommands = BotCommands() diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 2328881..4cd8390 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -246,3 +246,6 @@ class BotDatabase(): bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key]) self.lock.release() + + +botdb = BotDatabase() diff --git a/sopel_modules/SpiceBot/Events.py b/sopel_modules/SpiceBot/Events.py index b277a77..34dfc54 100644 --- a/sopel_modules/SpiceBot/Events.py +++ b/sopel_modules/SpiceBot/Events.py @@ -124,3 +124,6 @@ class BotEvents(object): return function(*args, **kwargs) return _nop return actual_decorator + + +botevents = BotEvents() diff --git a/sopel_modules/SpiceBot/Logs.py b/sopel_modules/SpiceBot/Logs.py index fe7b0e0..2308c30 100644 --- a/sopel_modules/SpiceBot/Logs.py +++ b/sopel_modules/SpiceBot/Logs.py @@ -101,3 +101,6 @@ class BotLogs(): pidnum = e pidnum = str(os.popen("systemctl show " + str(bot.nick) + " --property=MainPID").read()).split("=")[-1] return pidnum + + +botlogs = BotLogs() diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index fa95b21..ed4ec4b 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -20,7 +20,7 @@ from pygit2 import clone_repository import spicemanip -import sopel_modules.SpiceBot as SpiceBot +from .Logs import botlogs """Variable References""" diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index 3f196cd..2606e87 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -16,10 +16,3 @@ from .Database import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' __version__ = '0.1.1' - - -botdb = BotDatabase() -botchannels = BotChannels() -botcommands = BotCommands() -botevents = BotEvents() -botlogs = BotLogs() From 5f6bcb17263acb58b45f9a68c4a0e82a43f7d7af Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 11:34:20 -0400 Subject: [PATCH 012/328] update tools --- sopel_modules/SpiceBot/Tools.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index ed4ec4b..59306b4 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -305,7 +305,7 @@ def spicebot_update(bot, deps=False): if not os.path.exists(clonepath) or not os.path.isdir(clonepath): os.system(clonepath) - SpiceBot.botlogs.log('SpiceBot_Update', "Cloning to " + clonepath, True) + botlogs.log('SpiceBot_Update', "Cloning to " + clonepath, True) clone_repository(str(bot.config.SpiceBot_Update.gitrepo + ".git"), clonepath, checkout_branch=bot.config.SpiceBot_Update.gitbranch) @@ -316,12 +316,12 @@ def spicebot_update(bot, deps=False): # pipcommand += " git+" + str(bot.config.SpiceBot_Update.gitrepo) + "@" + str(bot.config.SpiceBot_Update.gitbranch) pipcommand += " /tmp/SpiceBot/" - SpiceBot.botlogs.log('SpiceBot_Update', "Running `" + pipcommand + "`", True) + botlogs.log('SpiceBot_Update', "Running `" + pipcommand + "`", True) # for line in os.popen(pipcommand).read().split('\n'): - # SpiceBot.botlogs.log('SpiceBot_Update', " " + line) + # botlogs.log('SpiceBot_Update', " " + line) os.system(pipcommand) - SpiceBot.botlogs.log('SpiceBot_Update', "Deleting " + clonepath, True) + botlogs.log('SpiceBot_Update', "Deleting " + clonepath, True) os.system("sudo rm -r /tmp/SpiceBot") @@ -337,10 +337,10 @@ def service_manip(bot, servicename, dowhat, log_from='service_manip'): if str(dowhat) not in ["start", "stop", "restart"]: return try: - SpiceBot.botlogs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service.") + botlogs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service.") os.system("sudo service " + str(servicename) + " " + str(dowhat)) except Exception as e: - SpiceBot.botlogs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service Failed: " + str(e)) + botlogs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service Failed: " + str(e)) """Config Reading Functions""" @@ -372,7 +372,7 @@ def read_directory_json_to_dict(bot, directories, configtypename="Config File", except Exception as e: filereadgood = False if bot: - SpiceBot.botlogs.log(log_from, "Error loading %s: %s (%s)" % (configtypename, e, filepath)) + botlogs.log(log_from, "Error loading %s: %s (%s)" % (configtypename, e, filepath)) dict_from_file = dict() # Close File inf.close() @@ -387,10 +387,10 @@ def read_directory_json_to_dict(bot, directories, configtypename="Config File", if filecount: if bot: - SpiceBot.botlogs.log(log_from, 'Registered %d %s dict files,' % (filecount, configtypename)) - SpiceBot.botlogs.log(log_from, '%d %s dict files failed to load' % (fileopenfail, configtypename), True) + botlogs.log(log_from, 'Registered %d %s dict files,' % (filecount, configtypename)) + botlogs.log(log_from, '%d %s dict files failed to load' % (fileopenfail, configtypename), True) else: if bot: - SpiceBot.botlogs.log(log_from, "Warning: Couldn't load any %s dict files" % (configtypename)) + botlogs.log(log_from, "Warning: Couldn't load any %s dict files" % (configtypename)) return configs_dict From 7d4cf8522f327df16b0240277ef39d65863532c0 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 12:04:37 -0400 Subject: [PATCH 013/328] remove extra release lines --- sopel_modules/SpiceBot/Database.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 4cd8390..a4aa3c7 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -50,11 +50,9 @@ class BotDatabase(): if nick_id not in self.SpiceBot_Database["nicks"].keys(): self.SpiceBot_Database["nicks"][nick_id] = {} - self.lock.release() if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys(): self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() - self.lock.release() self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] = value From 78c3793fbcbcc212ee0b31e59b2ffc92cb7aab6a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 12:53:55 -0400 Subject: [PATCH 014/328] code cleanup --- sopel_modules/SpiceBot/Tools.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index 59306b4..05ffc21 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -7,7 +7,6 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi import sopel import collections -import re import os import sys import codecs @@ -246,12 +245,6 @@ def letters_in_string(text): """Channel Functions""" -def topic_compile(topic): - actual_topic = re.compile(r'^\[\+[a-zA-Z]+\] (.*)') - topic = re.sub(actual_topic, r'\1', topic) - return topic - - def channel_privs(bot, channel, privtype): privlist = [] for user in bot.channels[channel].privileges.keys(): From d099e3fc2bbf181552651bcf0fb1be3c3fc03d93 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 13:01:00 -0400 Subject: [PATCH 015/328] SpiceBot Class Consistancy --- sopel_modules/SpiceBot/Channels.py | 24 +- sopel_modules/SpiceBot/Commands.py | 14 +- sopel_modules/SpiceBot/Database.py | 154 ++++---- sopel_modules/SpiceBot/Events.py | 30 +- sopel_modules/SpiceBot/Logs.py | 12 +- sopel_modules/SpiceBot/Tools.py | 22 +- sopel_modules/SpiceBot_AI/AI.py | 8 +- .../Channels_Command.py | 32 +- .../Channels_Parsing.py | 64 ++-- .../NickQueryCommand.py | 6 +- .../SpiceBot_CommandsQuery/QueryCommand.py | 8 +- .../Databaseaddons.py | 2 +- sopel_modules/SpiceBot_Events/Connected.py | 4 +- .../SpiceBot_Events/Connection_Count.py | 8 +- sopel_modules/SpiceBot_Events/Loaded.py | 6 +- sopel_modules/SpiceBot_Events/Logging.py | 4 +- sopel_modules/SpiceBot_Events/Queue.py | 10 +- sopel_modules/SpiceBot_Events/Ready.py | 4 +- sopel_modules/SpiceBot_Events/Welcome.py | 6 +- sopel_modules/SpiceBot_GifSearch/gif.py | 2 +- sopel_modules/SpiceBot_GifSearch/gifapi.py | 2 +- sopel_modules/SpiceBot_GifSearch/gifsearch.py | 8 +- .../SpiceBot_InvalidCommand/InvalidCommand.py | 8 +- sopel_modules/SpiceBot_Kick/__init__.py | 4 +- sopel_modules/SpiceBot_Logs/IRC_Events | 362 +++++++++--------- sopel_modules/SpiceBot_Logs/Logs_Command.py | 16 +- sopel_modules/SpiceBot_Logs/Queue.py | 18 +- sopel_modules/SpiceBot_Messaging/Messaging.py | 2 +- .../SpiceBot_Module_Parsing/ModuleParsing.py | 30 +- sopel_modules/SpiceBot_Restart/Restart.py | 2 +- .../SpiceBot_SopelPatches/Patches.py | 4 +- .../StartupMonologue.py | 4 +- .../StartupMonologue_Display_Channels.py | 8 +- .../StartupMonologue_Display_Commands.py | 12 +- .../StartupMonologue_Display_Connected.py | 6 +- .../StartupMonologue_Display_Errors.py | 8 +- .../StartupMonologue_Display_Loaded.py | 10 +- sopel_modules/SpiceBot_Update/Update.py | 4 +- sopel_modules/SpiceBot_Uptime/Uptime.py | 2 +- sopel_modules/SpiceBot_osd/__init__.py | 6 +- 40 files changed, 468 insertions(+), 468 deletions(-) diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index 433b984..a403875 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -24,15 +24,15 @@ class BotChannels(): def channel_list_recieve_input(self, trigger): channel, _, topic = trigger.args[1:] - if channel.lower() not in self.SpiceBot_Channels['list'].keys(): - self.SpiceBot_Channels['list'][channel.lower()] = dict() - self.SpiceBot_Channels['list'][channel.lower()]['name'] = channel - self.SpiceBot_Channels['list'][channel.lower()]['topic'] = self.topic_compile(topic) + if channel.lower() not in self.dict['list'].keys(): + self.dict['list'][channel.lower()] = dict() + self.dict['list'][channel.lower()]['name'] = channel + self.dict['list'][channel.lower()]['topic'] = self.topic_compile(topic) self.channel_lock = True def channel_list_recieve_finish(self): - if not self.SpiceBot_Channels['InitialProcess']: - self.SpiceBot_Channels['InitialProcess'] = True + if not self.dict['InitialProcess']: + self.dict['InitialProcess'] = True self.channel_lock = False def topic_compile(self, topic): @@ -48,17 +48,17 @@ class BotChannels(): for channel in bot.channels.keys(): if len(bot.channels[channel].privileges.keys()) == 1 and channel not in ignorepartlist and channel.startswith("#"): bot.part(channel, "Leaving Empty Channel") - if channel.lower() in self.SpiceBot_Channels['list']: - del self.SpiceBot_Channels['list'][channel.lower()] + if channel.lower() in self.dict['list']: + del self.dict['list'][channel.lower()] def join_all_channels(self, bot): if bot.config.SpiceBot_Channels.joinall: - for channel in self.SpiceBot_Channels['list'].keys(): + for channel in self.dict['list'].keys(): if channel.startswith("#"): if channel not in bot.channels.keys() and channel not in bot.config.SpiceBot_Channels.chanignore: - bot.write(('JOIN', bot.nick, self.SpiceBot_Channels['list'][channel]['name'])) + bot.write(('JOIN', bot.nick, self.dict['list'][channel]['name'])) if channel not in bot.channels.keys() and bot.config.SpiceBot_Channels.operadmin: - bot.write(('SAJOIN', bot.nick, self.SpiceBot_Channels['list'][channel]['name'])) + bot.write(('SAJOIN', bot.nick, self.dict['list'][channel]['name'])) def chanadmin_all_channels(self, bot): # Chan ADMIN +a @@ -72,4 +72,4 @@ class BotChannels(): bot.part(channel) -botchannels = BotChannels() +channels = BotChannels() diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 5a4eb99..67edcca 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -27,9 +27,9 @@ class BotCommands(): if not isinstance(validcoms, list): validcoms = [validcoms] - if command_type not in self.SpiceBot_Commands['commands'].keys(): - self.SpiceBot_Commands['commands'][command_type] = dict() - self.SpiceBot_Commands['counts'] += 1 + if command_type not in self.dict['commands'].keys(): + self.dict['commands'][command_type] = dict() + self.dict['counts'] += 1 dict_from_file = dict() @@ -44,13 +44,13 @@ class BotCommands(): comaliases = spicemanip.main(dict_from_file["validcoms"], '2+', 'list') else: comaliases = [] - self.SpiceBot_Commands['commands'][command_type][maincom] = dict_from_file + self.dict['commands'][command_type][maincom] = dict_from_file else: comaliases = validcoms for comalias in comaliases: - if comalias not in self.SpiceBot_Commands['commands'][command_type].keys(): - self.SpiceBot_Commands['commands'][command_type][comalias] = {"aliasfor": aliasfor} + if comalias not in self.dict['commands'][command_type].keys(): + self.dict['commands'][command_type][comalias] = {"aliasfor": aliasfor} -botcommands = BotCommands() +commands = BotCommands() diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index a4aa3c7..e8822d0 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -28,18 +28,18 @@ class BotDatabase(): nick = Identifier(nick) nick_id = bot.db.get_nick_id(nick, create=True) - if nick_id not in self.SpiceBot_Database["nicks"].keys(): - self.SpiceBot_Database["nicks"][nick_id] = {} + if nick_id not in self.dict["nicks"].keys(): + self.dict["nicks"][nick_id] = {} - if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys(): - self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + if sorting_key not in self.dict["nicks"][nick_id].keys(): + self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() self.lock.release() - if key not in self.SpiceBot_Database["nicks"][nick_id][sorting_key].keys(): + if key not in self.dict["nicks"][nick_id][sorting_key].keys(): return None else: - return self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] + return self.dict["nicks"][nick_id][sorting_key][key] def set_nick_value(self, bot, nick, key, value, sorting_key='unsorted'): @@ -48,15 +48,15 @@ class BotDatabase(): nick = Identifier(nick) nick_id = bot.db.get_nick_id(nick, create=True) - if nick_id not in self.SpiceBot_Database["nicks"].keys(): - self.SpiceBot_Database["nicks"][nick_id] = {} + if nick_id not in self.dict["nicks"].keys(): + self.dict["nicks"][nick_id] = {} - if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys(): - self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + if sorting_key not in self.dict["nicks"][nick_id].keys(): + self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() - self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] = value + self.dict["nicks"][nick_id][sorting_key][key] = value - bot.db.set_nick_value(nick, sorting_key, self.SpiceBot_Database["nicks"][nick_id][sorting_key]) + bot.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) self.lock.release() @@ -67,14 +67,14 @@ class BotDatabase(): nick = Identifier(nick) nick_id = bot.db.get_nick_id(nick, create=True) - if nick_id not in self.SpiceBot_Database["nicks"].keys(): - self.SpiceBot_Database["nicks"][nick_id] = {} + if nick_id not in self.dict["nicks"].keys(): + self.dict["nicks"][nick_id] = {} - if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys(): - self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + if sorting_key not in self.dict["nicks"][nick_id].keys(): + self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() - del self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] - bot.db.set_nick_value(nick, sorting_key, self.SpiceBot_Database["nicks"][nick_id][sorting_key]) + del self.dict["nicks"][nick_id][sorting_key][key] + bot.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) self.lock.release() @@ -85,22 +85,22 @@ class BotDatabase(): nick = Identifier(nick) nick_id = bot.db.get_nick_id(nick, create=True) - if nick_id not in self.SpiceBot_Database["nicks"].keys(): - self.SpiceBot_Database["nicks"][nick_id] = {} + if nick_id not in self.dict["nicks"].keys(): + self.dict["nicks"][nick_id] = {} - if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys(): - self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + if sorting_key not in self.dict["nicks"][nick_id].keys(): + self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() - if key not in self.SpiceBot_Database["nicks"][nick_id][sorting_key].keys(): + if key not in self.dict["nicks"][nick_id][sorting_key].keys(): oldvalue = [] else: - oldvalue = self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] + oldvalue = self.dict["nicks"][nick_id][sorting_key][key] if not oldvalue: - self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] = value + self.dict["nicks"][nick_id][sorting_key][key] = value else: - self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] = oldvalue + value - bot.db.set_nick_value(nick, sorting_key, self.SpiceBot_Database["nicks"][nick_id][sorting_key]) + self.dict["nicks"][nick_id][sorting_key][key] = oldvalue + value + bot.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) self.lock.release() @@ -114,24 +114,24 @@ class BotDatabase(): nick = Identifier(nick) nick_id = bot.db.get_nick_id(nick, create=True) - if nick_id not in self.SpiceBot_Database["nicks"].keys(): - self.SpiceBot_Database["nicks"][nick_id] = {} + if nick_id not in self.dict["nicks"].keys(): + self.dict["nicks"][nick_id] = {} - if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys(): - self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + if sorting_key not in self.dict["nicks"][nick_id].keys(): + self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() - if key not in self.SpiceBot_Database["nicks"][nick_id][sorting_key].keys(): - self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] = [] + if key not in self.dict["nicks"][nick_id][sorting_key].keys(): + self.dict["nicks"][nick_id][sorting_key][key] = [] if adjustmentdirection == 'add': for entry in entries: - if entry not in self.SpiceBot_Database["nicks"][nick_id][sorting_key][key]: - self.SpiceBot_Database["nicks"][nick_id][sorting_key][key].append(entry) + if entry not in self.dict["nicks"][nick_id][sorting_key][key]: + self.dict["nicks"][nick_id][sorting_key][key].append(entry) elif adjustmentdirection == 'del': for entry in entries: - while entry in self.SpiceBot_Database["nicks"][nick_id][sorting_key][key]: - self.SpiceBot_Database["nicks"][nick_id][sorting_key][key].remove(entry) - bot.db.set_nick_value(nick, sorting_key, self.SpiceBot_Database["nicks"][nick_id][sorting_key]) + while entry in self.dict["nicks"][nick_id][sorting_key][key]: + self.dict["nicks"][nick_id][sorting_key][key].remove(entry) + bot.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) self.lock.release() @@ -143,18 +143,18 @@ class BotDatabase(): channel = Identifier(channel) - if channel not in self.SpiceBot_Database["channels"].keys(): - self.SpiceBot_Database["channels"][channel] = {} + if channel not in self.dict["channels"].keys(): + self.dict["channels"][channel] = {} - if sorting_key not in self.SpiceBot_Database["channels"][channel].keys(): - self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + if sorting_key not in self.dict["channels"][channel].keys(): + self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() self.lock.release() - if key not in self.SpiceBot_Database["channels"][channel][sorting_key].keys(): + if key not in self.dict["channels"][channel][sorting_key].keys(): return None else: - return self.SpiceBot_Database["channels"][channel][sorting_key][key] + return self.dict["channels"][channel][sorting_key][key] def set_channel_value(self, bot, channel, key, value, sorting_key='unsorted'): @@ -162,14 +162,14 @@ class BotDatabase(): channel = Identifier(channel) - if channel not in self.SpiceBot_Database["channels"].keys(): - self.SpiceBot_Database["channels"][channel] = {} + if channel not in self.dict["channels"].keys(): + self.dict["channels"][channel] = {} - if sorting_key not in self.SpiceBot_Database["channels"][channel].keys(): - self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + if sorting_key not in self.dict["channels"][channel].keys(): + self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() - self.SpiceBot_Database["channels"][channel][sorting_key][key] = value - bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key]) + self.dict["channels"][channel][sorting_key][key] = value + bot.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) self.lock.release() @@ -179,14 +179,14 @@ class BotDatabase(): channel = Identifier(channel) - if channel not in self.SpiceBot_Database["channels"].keys(): - self.SpiceBot_Database["channels"][channel] = {} + if channel not in self.dict["channels"].keys(): + self.dict["channels"][channel] = {} - if sorting_key not in self.SpiceBot_Database["channels"][channel].keys(): - self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + if sorting_key not in self.dict["channels"][channel].keys(): + self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() - del self.SpiceBot_Database["channels"][channel][sorting_key][key] - bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key]) + del self.dict["channels"][channel][sorting_key][key] + bot.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) self.lock.release() @@ -196,22 +196,22 @@ class BotDatabase(): channel = Identifier(channel) - if channel not in self.SpiceBot_Database["channels"].keys(): - self.SpiceBot_Database["channels"][channel] = {} + if channel not in self.dict["channels"].keys(): + self.dict["channels"][channel] = {} - if sorting_key not in self.SpiceBot_Database["channels"][channel].keys(): - self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + if sorting_key not in self.dict["channels"][channel].keys(): + self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() - if key not in self.SpiceBot_Database["channels"][channel][sorting_key].keys(): + if key not in self.dict["channels"][channel][sorting_key].keys(): oldvalue = None else: - oldvalue = self.SpiceBot_Database["channels"][channel][sorting_key][key] + oldvalue = self.dict["channels"][channel][sorting_key][key] if not oldvalue: - self.SpiceBot_Database["channels"][channel][sorting_key][key] = value + self.dict["channels"][channel][sorting_key][key] = value else: - self.SpiceBot_Database["channels"][channel][sorting_key][key] = oldvalue + value - bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key]) + self.dict["channels"][channel][sorting_key][key] = oldvalue + value + bot.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) self.lock.release() @@ -224,26 +224,26 @@ class BotDatabase(): channel = Identifier(channel) - if channel not in self.SpiceBot_Database["channels"].keys(): - self.SpiceBot_Database["channels"][channel] = {} + if channel not in self.dict["channels"].keys(): + self.dict["channels"][channel] = {} - if sorting_key not in self.SpiceBot_Database["channels"][channel].keys(): - self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + if sorting_key not in self.dict["channels"][channel].keys(): + self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() - if key not in self.SpiceBot_Database["channels"][channel][sorting_key].keys(): - self.SpiceBot_Database["channels"][channel][sorting_key][key] = [] + if key not in self.dict["channels"][channel][sorting_key].keys(): + self.dict["channels"][channel][sorting_key][key] = [] if adjustmentdirection == 'add': for entry in entries: - if entry not in self.SpiceBot_Database["channels"][channel][sorting_key][key]: - self.SpiceBot_Database["channels"][channel][sorting_key][key].append(entry) + if entry not in self.dict["channels"][channel][sorting_key][key]: + self.dict["channels"][channel][sorting_key][key].append(entry) elif adjustmentdirection == 'del': for entry in entries: - while entry in self.SpiceBot_Database["channels"][channel][sorting_key][key]: - self.SpiceBot_Database["channels"][channel][sorting_key][key].remove(entry) - bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key]) + while entry in self.dict["channels"][channel][sorting_key][key]: + self.dict["channels"][channel][sorting_key][key].remove(entry) + bot.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) self.lock.release() -botdb = BotDatabase() +db = BotDatabase() diff --git a/sopel_modules/SpiceBot/Events.py b/sopel_modules/SpiceBot/Events.py index 34dfc54..46d9068 100644 --- a/sopel_modules/SpiceBot/Events.py +++ b/sopel_modules/SpiceBot/Events.py @@ -17,7 +17,7 @@ class BotEvents(object): Events will be assigned a 4-digit number above 1000. - This allows you to do, ``@module.event(botevents.BOT_WELCOME)```` + This allows you to do, ``@module.event(events.BOT_WELCOME)```` Triggers handled by this module will be processed immediately. Others will be placed into a queue. @@ -43,8 +43,8 @@ class BotEvents(object): def __getattr__(self, name): ''' will only get called for undefined attributes ''' - eventnumber = max(list(self.SpiceBot_Events["assigned_IDs"].keys())) + 1 - self.SpiceBot_Events["assigned_IDs"][eventnumber] = str(name) + eventnumber = max(list(self.dict["assigned_IDs"].keys())) + 1 + self.dict["assigned_IDs"][eventnumber] = str(name) setattr(self, name, str(eventnumber)) return str(eventnumber) @@ -53,7 +53,7 @@ class BotEvents(object): if number in self.defaultevents: self.dispatch(bot, pretriggerdict) else: - self.SpiceBot_Events["trigger_queue"].append(pretriggerdict) + self.dict["trigger_queue"].append(pretriggerdict) def dispatch(self, bot, pretriggerdict): number = pretriggerdict["number"] @@ -72,37 +72,37 @@ class BotEvents(object): else: eventnumber = str(trigger.event) message = trigger.args[1] - if eventnumber not in self.SpiceBot_Events["triggers_recieved"]: - self.SpiceBot_Events["triggers_recieved"][eventnumber] = [] - self.SpiceBot_Events["triggers_recieved"][eventnumber].append(message) + if eventnumber not in self.dict["triggers_recieved"]: + self.dict["triggers_recieved"][eventnumber] = [] + self.dict["triggers_recieved"][eventnumber].append(message) def check(self, checklist): if not isinstance(checklist, list): checklist = [str(checklist)] for number in checklist: - if str(number) not in self.SpiceBot_Events["triggers_recieved"].keys(): + if str(number) not in self.dict["triggers_recieved"].keys(): return False return True def startup_add(self, startlist): if not isinstance(startlist, list): startlist = [str(startlist)] - self.SpiceBot_Events["startup_required"].extend(startlist) + self.dict["startup_required"].extend(startlist) def startup_check(self): - for number in self.SpiceBot_Events["startup_required"]: - if str(number) not in self.SpiceBot_Events["triggers_recieved"].keys(): + for number in self.dict["startup_required"]: + if str(number) not in self.dict["triggers_recieved"].keys(): return False return True def startup_debug(self): not_done = [] - for number in self.SpiceBot_Events["startup_required"]: - if str(number) not in self.SpiceBot_Events["triggers_recieved"].keys(): + for number in self.dict["startup_required"]: + if str(number) not in self.dict["triggers_recieved"].keys(): not_done.append(int(number)) reference_not_done = [] for item in not_done: - reference_not_done.append(str(self.SpiceBot_Events["assigned_IDs"][item])) + reference_not_done.append(str(self.dict["assigned_IDs"][item])) return reference_not_done def check_ready(self, checklist): @@ -126,4 +126,4 @@ class BotEvents(object): return actual_decorator -botevents = BotEvents() +events = BotEvents() diff --git a/sopel_modules/SpiceBot/Logs.py b/sopel_modules/SpiceBot/Logs.py index 2308c30..6937137 100644 --- a/sopel_modules/SpiceBot/Logs.py +++ b/sopel_modules/SpiceBot/Logs.py @@ -28,14 +28,14 @@ class BotLogs(): logmessage = logtitle + " " + logentry if self.sopel_config["logging_channel"]: - self.SpiceBot_Logs["queue"].append(logmessage) + self.dict["queue"].append(logmessage) if stdio: sopel.tools.stderr(logmessage) - if logtype not in self.SpiceBot_Logs["list"].keys(): - self.SpiceBot_Logs["list"][logtype] = [] - self.SpiceBot_Logs["list"][logtype].append(logentry) + if logtype not in self.dict["list"].keys(): + self.dict["list"][logtype] = [] + self.dict["list"][logtype].append(logentry) def get_logs(self): return [] @@ -43,7 +43,7 @@ class BotLogs(): def stdio_logs_fetch(self, bot): stdio_ignore = [] - for logtype in self.SpiceBot_Logs["list"].keys(): + for logtype in self.dict["list"].keys(): stdio_ignore.append("[" + logtype + "]") logfile = os.path.os.path.join(bot.config.core.logdir, 'stdio.log') @@ -103,4 +103,4 @@ class BotLogs(): return pidnum -botlogs = BotLogs() +logs = BotLogs() diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index 05ffc21..c25823b 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -19,7 +19,7 @@ from pygit2 import clone_repository import spicemanip -from .Logs import botlogs +from .Logs import logs """Variable References""" @@ -298,7 +298,7 @@ def spicebot_update(bot, deps=False): if not os.path.exists(clonepath) or not os.path.isdir(clonepath): os.system(clonepath) - botlogs.log('SpiceBot_Update', "Cloning to " + clonepath, True) + logs.log('SpiceBot_Update', "Cloning to " + clonepath, True) clone_repository(str(bot.config.SpiceBot_Update.gitrepo + ".git"), clonepath, checkout_branch=bot.config.SpiceBot_Update.gitbranch) @@ -309,12 +309,12 @@ def spicebot_update(bot, deps=False): # pipcommand += " git+" + str(bot.config.SpiceBot_Update.gitrepo) + "@" + str(bot.config.SpiceBot_Update.gitbranch) pipcommand += " /tmp/SpiceBot/" - botlogs.log('SpiceBot_Update', "Running `" + pipcommand + "`", True) + logs.log('SpiceBot_Update', "Running `" + pipcommand + "`", True) # for line in os.popen(pipcommand).read().split('\n'): - # botlogs.log('SpiceBot_Update', " " + line) + # logs.log('SpiceBot_Update', " " + line) os.system(pipcommand) - botlogs.log('SpiceBot_Update', "Deleting " + clonepath, True) + logs.log('SpiceBot_Update', "Deleting " + clonepath, True) os.system("sudo rm -r /tmp/SpiceBot") @@ -330,10 +330,10 @@ def service_manip(bot, servicename, dowhat, log_from='service_manip'): if str(dowhat) not in ["start", "stop", "restart"]: return try: - botlogs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service.") + logs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service.") os.system("sudo service " + str(servicename) + " " + str(dowhat)) except Exception as e: - botlogs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service Failed: " + str(e)) + logs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service Failed: " + str(e)) """Config Reading Functions""" @@ -365,7 +365,7 @@ def read_directory_json_to_dict(bot, directories, configtypename="Config File", except Exception as e: filereadgood = False if bot: - botlogs.log(log_from, "Error loading %s: %s (%s)" % (configtypename, e, filepath)) + logs.log(log_from, "Error loading %s: %s (%s)" % (configtypename, e, filepath)) dict_from_file = dict() # Close File inf.close() @@ -380,10 +380,10 @@ def read_directory_json_to_dict(bot, directories, configtypename="Config File", if filecount: if bot: - botlogs.log(log_from, 'Registered %d %s dict files,' % (filecount, configtypename)) - botlogs.log(log_from, '%d %s dict files failed to load' % (fileopenfail, configtypename), True) + logs.log(log_from, 'Registered %d %s dict files,' % (filecount, configtypename)) + logs.log(log_from, '%d %s dict files failed to load' % (fileopenfail, configtypename), True) else: if bot: - botlogs.log(log_from, "Warning: Couldn't load any %s dict files" % (configtypename)) + logs.log(log_from, "Warning: Couldn't load any %s dict files" % (configtypename)) return configs_dict diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index 5ca12ab..593b8c9 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -9,7 +9,7 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot -@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOADED, SpiceBot.botevents.BOT_COMMANDSQUERY]) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDSQUERY]) @sopel.module.nickname_commands('(.*)') def bot_command_nick(bot, trigger): @@ -21,13 +21,13 @@ def bot_command_nick(bot, trigger): if triggercommand[0] == "?": return - if triggercommand in SpiceBot.botcommands.SpiceBot_Commands['commands']["nickname"].keys(): + if triggercommand in SpiceBot.commands.dict['commands']["nickname"].keys(): return triggerargs.insert(0, triggercommand) fulltrigger = spicemanip.main(triggerargs, 0).lower() - if fulltrigger in SpiceBot.botcommands.SpiceBot_Commands['nickrules']: + if fulltrigger in SpiceBot.commands.dict['nickrules']: return if fulltrigger.lower().startswith("what is"): @@ -154,7 +154,7 @@ def bot_command_nick(bot, trigger): else: - closestmatches = SpiceBot.similar_list(bot, triggercommand, SpiceBot.botcommands.SpiceBot_Commands['commands']["nickname"].keys(), 3, 'reverse') + closestmatches = SpiceBot.similar_list(bot, triggercommand, SpiceBot.commands.dict['commands']["nickname"].keys(), 3, 'reverse') if len(closestmatches): closestmatches = spicemanip.main(closestmatches, "andlist") diff --git a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py index 1599bc3..eafdda9 100644 --- a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py +++ b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py @@ -9,7 +9,7 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot -@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOADED]) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @sopel.module.nickname_commands('channels', 'channel') def nickname_comand_channels(bot, trigger): @@ -29,14 +29,14 @@ def nickname_comand_channels(bot, trigger): elif commandused == 'total': botcount = len(bot.channels.keys()) - servercount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys()) + servercount = len(SpiceBot.channels.dict['list'].keys()) bot.osd("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") return elif commandused == 'random': - channel = spicemanip.main(SpiceBot.botchannels.SpiceBot_Channels['list'], 'random') - topic = SpiceBot.botchannels.SpiceBot_Channels['list'][channel]['topic'] - msg = ["Random channel for you: {}.".format(SpiceBot.botchannels.SpiceBot_Channels['list'][channel]['name'])] + channel = spicemanip.main(SpiceBot.channels.dict['list'], 'random') + topic = SpiceBot.channels.dict['list'][channel]['topic'] + msg = ["Random channel for you: {}.".format(SpiceBot.channels.dict['list'][channel]['name'])] if topic and not topic.isspace(): msg.append("The topic is: {}".format(topic)) else: @@ -48,15 +48,15 @@ def nickname_comand_channels(bot, trigger): if not trigger.admin: bot.osd("You do not have permission to update the channel listing.") return - SpiceBot.botchannels.bot_part_empty(bot) - SpiceBot.botchannels.channel_list_request(bot) + SpiceBot.channels.bot_part_empty(bot) + SpiceBot.channels.channel_list_request(bot) bot.osd(["[SpiceBot_Channels]", "I am now updating the channel listing for this server."]) - while SpiceBot.botchannels.channel_lock: + while SpiceBot.channels.channel_lock: pass - SpiceBot.botchannels.join_all_channels(bot) - foundchannelcount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys()) + SpiceBot.channels.join_all_channels(bot) + foundchannelcount = len(SpiceBot.channels.dict['list'].keys()) bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.") - SpiceBot.botchannels.bot_part_empty(bot) + SpiceBot.channels.bot_part_empty(bot) return elif commandused == 'topic': @@ -64,11 +64,11 @@ def nickname_comand_channels(bot, trigger): bot.osd("Channel name input missing.") return channel = spicemanip.main(triggerargs, 1) - if not SpiceBot.inlist(channel.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys()): + if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()): bot.osd("Channel name {} not valid.".format(channel)) return - topic = SpiceBot.botchannels.SpiceBot_Channels['list'][channel.lower()]['topic'] - channel = SpiceBot.botchannels.SpiceBot_Channels['list'][channel.lower()]['name'] + topic = SpiceBot.channels.dict['list'][channel.lower()]['topic'] + channel = SpiceBot.channels.dict['list'][channel.lower()]['name'] bot.osd("Topic for {}: {}".format(channel, topic)) return @@ -81,7 +81,7 @@ def nickname_comand_channels(bot, trigger): channel = trigger.sender else: channel = spicemanip.main(triggerargs, 1) - if not SpiceBot.inlist(channel.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys()): + if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()): bot.osd("Channel name {} not valid.".format(channel)) return if not SpiceBot.inlist(channel.lower(), bot.channels.keys()): @@ -101,7 +101,7 @@ def nickname_comand_channels(bot, trigger): # Users List if commandused == 'users': channel = spicemanip.main(triggerargs, 1) - if not SpiceBot.inlist(channel.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys()): + if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()): bot.osd("Channel name {} not valid.".format(channel)) return if not SpiceBot.inlist(channel.lower(), bot.channels.keys()): diff --git a/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py b/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py index 8951ed5..a9002e7 100644 --- a/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py +++ b/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py @@ -29,91 +29,91 @@ def configure(config): def setup(bot): - SpiceBot.botlogs.log('SpiceBot_Channels', "Starting setup procedure") - SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_CHANNELS]) + SpiceBot.logs.log('SpiceBot_Channels', "Starting setup procedure") + SpiceBot.events.startup_add([SpiceBot.events.BOT_CHANNELS]) bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) -@sopel.module.event(SpiceBot.botevents.RPL_WELCOME) +@sopel.module.event(SpiceBot.events.RPL_WELCOME) @sopel.module.rule('.*') def unkickable_bot(bot, trigger): if bot.config.SpiceBot_Channels.operadmin: bot.write(('SAMODE', bot.nick, '+q')) -@sopel.module.event(SpiceBot.botevents.RPL_WELCOME) +@sopel.module.event(SpiceBot.events.RPL_WELCOME) @sopel.module.rule('.*') def request_channels_list_initial(bot, trigger): - SpiceBot.botchannels.bot_part_empty(bot) + SpiceBot.channels.bot_part_empty(bot) - SpiceBot.botlogs.log('SpiceBot_Channels', "Sending Request for all server channels") - SpiceBot.botchannels.channel_list_request(bot) + SpiceBot.logs.log('SpiceBot_Channels', "Sending Request for all server channels") + SpiceBot.channels.channel_list_request(bot) starttime = time.time() # wait 60 seconds for initial population of information - while not SpiceBot.botchannels.SpiceBot_Channels['InitialProcess']: + while not SpiceBot.channels.dict['InitialProcess']: if time.time() - starttime >= 60: - SpiceBot.botlogs.log('SpiceBot_Channels', "Initial Channel list populating Timed Out") - SpiceBot.botchannels.SpiceBot_Channels['InitialProcess'] = True + SpiceBot.logs.log('SpiceBot_Channels', "Initial Channel list populating Timed Out") + SpiceBot.channels.dict['InitialProcess'] = True else: pass - foundchannelcount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys()) - SpiceBot.botlogs.log('SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.") + foundchannelcount = len(SpiceBot.channels.dict['list'].keys()) + SpiceBot.logs.log('SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.") - SpiceBot.botchannels.join_all_channels(bot) - SpiceBot.botchannels.chanadmin_all_channels(bot) + SpiceBot.channels.join_all_channels(bot) + SpiceBot.channels.chanadmin_all_channels(bot) - if "*" in SpiceBot.botchannels.SpiceBot_Channels['list'].keys(): - del SpiceBot.botchannels.SpiceBot_Channels['list']["*"] + if "*" in SpiceBot.channels.dict['list'].keys(): + del SpiceBot.channels.dict['list']["*"] - SpiceBot.botchannels.bot_part_empty(bot) - SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_CHANNELS, "SpiceBot_Channels") + SpiceBot.channels.bot_part_empty(bot) + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_CHANNELS, "SpiceBot_Channels") @sopel.module.event('321') @sopel.module.rule('.*') def watch_chanlist_start(bot, trigger): - SpiceBot.botchannels.channel_list_recieve_start() + SpiceBot.channels.channel_list_recieve_start() @sopel.module.event('322') @sopel.module.rule('.*') def watch_chanlist_populate(bot, trigger): - SpiceBot.botchannels.channel_list_recieve_input(trigger) + SpiceBot.channels.channel_list_recieve_input(trigger) @sopel.module.event('323') @sopel.module.rule('.*') def watch_chanlist_complete(bot, trigger): - SpiceBot.botchannels.channel_list_recieve_finish() + SpiceBot.channels.channel_list_recieve_finish() -@sopel.module.event(SpiceBot.botevents.BOT_CHANNELS) +@sopel.module.event(SpiceBot.events.BOT_CHANNELS) @sopel.module.rule('.*') def trigger_channel_list_recurring(bot, trigger): while True: time.sleep(1800) - SpiceBot.botchannels.bot_part_empty(bot) + SpiceBot.channels.bot_part_empty(bot) - oldlist = list(SpiceBot.botchannels.SpiceBot_Channels['list'].keys()) - SpiceBot.botchannels.channel_list_request(bot) + oldlist = list(SpiceBot.channels.dict['list'].keys()) + SpiceBot.channels.channel_list_request(bot) - while SpiceBot.botchannels.channel_lock: + while SpiceBot.channels.channel_lock: pass - newlist = [item.lower() for item in oldlist if item.lower() not in list(SpiceBot.botchannels.SpiceBot_Channels['list'].keys())] + newlist = [item.lower() for item in oldlist if item.lower() not in list(SpiceBot.channels.dict['list'].keys())] if "*" in newlist: newlist.remove("*") if len(newlist) and bot.config.SpiceBot_Channels.announcenew: bot.osd(["The Following channel(s) are new:", spicemanip.main(newlist, 'andlist')], bot.channels.keys()) - SpiceBot.botchannels.join_all_channels(bot) + SpiceBot.channels.join_all_channels(bot) - SpiceBot.botchannels.chanadmin_all_channels(bot) + SpiceBot.channels.chanadmin_all_channels(bot) - if "*" in SpiceBot.botchannels.SpiceBot_Channels['list'].keys(): - del SpiceBot.botchannels.SpiceBot_Channels['list']["*"] - SpiceBot.botchannels.bot_part_empty(bot) + if "*" in SpiceBot.channels.dict['list'].keys(): + del SpiceBot.channels.dict['list']["*"] + SpiceBot.channels.bot_part_empty(bot) diff --git a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py index 3c37745..6e3df6c 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py @@ -10,7 +10,7 @@ import sopel_modules.SpiceBot as SpiceBot import spicemanip -@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_COMMANDSQUERY]) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY]) @sopel.module.nickname_commands('(.*)') def query_detection_nick(bot, trigger): @@ -28,9 +28,9 @@ def query_detection_nick(bot, trigger): return commands_list = dict() - for com in SpiceBot.botcommands.SpiceBot_Commands['commands']['nickname'].keys(): + for com in SpiceBot.commands.dict['commands']['nickname'].keys(): if com not in commands_list.keys(): - commands_list[com] = SpiceBot.botcommands.SpiceBot_Commands['commands']['nickname'][com] + commands_list[com] = SpiceBot.commands.dict['commands']['nickname'][com] if triggercommand.endswith("+"): diff --git a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py index 1711cb7..d4629d3 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py @@ -10,7 +10,7 @@ import sopel_modules.SpiceBot as SpiceBot import spicemanip -@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_COMMANDSQUERY]) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY]) @sopel.module.rule('^\?(.*)') def query_detection(bot, trigger): @@ -24,11 +24,11 @@ def query_detection(bot, trigger): return commands_list = dict() - for commandstype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys(): + for commandstype in SpiceBot.commands.dict['commands'].keys(): if commandstype not in ['rule', 'nickname']: - for com in SpiceBot.botcommands.SpiceBot_Commands['commands'][commandstype].keys(): + for com in SpiceBot.commands.dict['commands'][commandstype].keys(): if com not in commands_list.keys(): - commands_list[com] = SpiceBot.botcommands.SpiceBot_Commands['commands'][commandstype][com] + commands_list[com] = SpiceBot.commands.dict['commands'][commandstype][com] if triggercommand[:-1] == "+": diff --git a/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py b/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py index 99dbc39..fe360d3 100644 --- a/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py +++ b/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py @@ -16,7 +16,7 @@ import sopel_modules.SpiceBot as SpiceBot def setup(bot): # Inject Database Functions - SpiceBot.botlogs.log('SpiceBot_Databaseaddons', "Implanting Database functions into bot") + SpiceBot.logs.log('SpiceBot_Databaseaddons', "Implanting Database functions into bot") SopelDB.delete_nick_value = SopelDBCache.delete_nick_value SopelDB.adjust_nick_value = SopelDBCache.adjust_nick_value SopelDB.delete_channel_value = SopelDBCache.delete_channel_value diff --git a/sopel_modules/SpiceBot_Events/Connected.py b/sopel_modules/SpiceBot_Events/Connected.py index be399d2..ecf81ac 100644 --- a/sopel_modules/SpiceBot_Events/Connected.py +++ b/sopel_modules/SpiceBot_Events/Connected.py @@ -7,10 +7,10 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(SpiceBot.botevents.BOT_WELCOME) +@sopel.module.event(SpiceBot.events.BOT_WELCOME) @sopel.module.rule('.*') def bot_events_Connected(bot, trigger): """Here, we wait until we are in at least one channel""" while not len(bot.channels.keys()) > 0: pass - SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_CONNECTED, "Bot Connected to IRC") + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_CONNECTED, "Bot Connected to IRC") diff --git a/sopel_modules/SpiceBot_Events/Connection_Count.py b/sopel_modules/SpiceBot_Events/Connection_Count.py index dfa4887..461ed8d 100644 --- a/sopel_modules/SpiceBot_Events/Connection_Count.py +++ b/sopel_modules/SpiceBot_Events/Connection_Count.py @@ -7,9 +7,9 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(SpiceBot.botevents.RPL_WELCOME) +@sopel.module.event(SpiceBot.events.RPL_WELCOME) @sopel.module.rule('.*') def bot_startup_welcome(bot, trigger): - SpiceBot.botevents.SpiceBot_Events["RPL_WELCOME_Count"] += 1 - if SpiceBot.botevents.SpiceBot_Events["RPL_WELCOME_Count"] > 1: - SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_RECONNECTED, "Bot ReConnected to IRC") + SpiceBot.events.dict["RPL_WELCOME_Count"] += 1 + if SpiceBot.events.dict["RPL_WELCOME_Count"] > 1: + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_RECONNECTED, "Bot ReConnected to IRC") diff --git a/sopel_modules/SpiceBot_Events/Loaded.py b/sopel_modules/SpiceBot_Events/Loaded.py index e1e5c12..820c3b2 100644 --- a/sopel_modules/SpiceBot_Events/Loaded.py +++ b/sopel_modules/SpiceBot_Events/Loaded.py @@ -7,9 +7,9 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@SpiceBot.botevents.startup_check_ready() -@sopel.module.event(SpiceBot.botevents.BOT_READY) +@SpiceBot.events.startup_check_ready() +@sopel.module.event(SpiceBot.events.BOT_READY) @sopel.module.rule('.*') def bot_events_startup_complete(bot, trigger): """All events registered as required for startup have completed""" - SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_LOADED, "All registered modules setup procedures have completed") + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_LOADED, "All registered modules setup procedures have completed") diff --git a/sopel_modules/SpiceBot_Events/Logging.py b/sopel_modules/SpiceBot_Events/Logging.py index fb111db..77c1fb8 100644 --- a/sopel_modules/SpiceBot_Events/Logging.py +++ b/sopel_modules/SpiceBot_Events/Logging.py @@ -7,8 +7,8 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(SpiceBot.botevents.BOT_WELCOME, SpiceBot.botevents.BOT_READY, SpiceBot.botevents.BOT_CONNECTED, SpiceBot.botevents.BOT_LOADED) +@sopel.module.event(SpiceBot.events.BOT_WELCOME, SpiceBot.events.BOT_READY, SpiceBot.events.BOT_CONNECTED, SpiceBot.events.BOT_LOADED) @sopel.module.rule('.*') def bot_events_complete(bot, trigger): """This is here simply to log to stderr that this was recieved.""" - SpiceBot.botlogs.log('SpiceBot_Events', trigger.args[1], True) + SpiceBot.logs.log('SpiceBot_Events', trigger.args[1], True) diff --git a/sopel_modules/SpiceBot_Events/Queue.py b/sopel_modules/SpiceBot_Events/Queue.py index 778642c..68905c0 100644 --- a/sopel_modules/SpiceBot_Events/Queue.py +++ b/sopel_modules/SpiceBot_Events/Queue.py @@ -7,12 +7,12 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(SpiceBot.botevents.BOT_WELCOME) +@sopel.module.event(SpiceBot.events.BOT_WELCOME) @sopel.module.rule('.*') def bot_events_connected(bot, trigger): """For items tossed in a queue, this will trigger them accordingly""" while True: - if len(SpiceBot.botevents.SpiceBot_Events["trigger_queue"]): - pretriggerdict = SpiceBot.botevents.SpiceBot_Events["trigger_queue"][0] - SpiceBot.botevents.dispatch(bot, pretriggerdict) - del SpiceBot.botevents.SpiceBot_Events["trigger_queue"][0] + if len(SpiceBot.events.dict["trigger_queue"]): + pretriggerdict = SpiceBot.events.dict["trigger_queue"][0] + SpiceBot.events.dispatch(bot, pretriggerdict) + del SpiceBot.events.dict["trigger_queue"][0] diff --git a/sopel_modules/SpiceBot_Events/Ready.py b/sopel_modules/SpiceBot_Events/Ready.py index 2ff6f28..9284475 100644 --- a/sopel_modules/SpiceBot_Events/Ready.py +++ b/sopel_modules/SpiceBot_Events/Ready.py @@ -7,8 +7,8 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(SpiceBot.botevents.BOT_WELCOME) +@sopel.module.event(SpiceBot.events.BOT_WELCOME) @sopel.module.rule('.*') def bot_events_start(bot, trigger): """This stage is redundant, but shows the system is working.""" - SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_READY, "Ready To Process module setup procedures") + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_READY, "Ready To Process module setup procedures") diff --git a/sopel_modules/SpiceBot_Events/Welcome.py b/sopel_modules/SpiceBot_Events/Welcome.py index 1102a53..27e3c3d 100644 --- a/sopel_modules/SpiceBot_Events/Welcome.py +++ b/sopel_modules/SpiceBot_Events/Welcome.py @@ -7,11 +7,11 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(SpiceBot.botevents.RPL_WELCOME) +@sopel.module.event(SpiceBot.events.RPL_WELCOME) @sopel.module.rule('.*') def bot_startup_welcome(bot, trigger): """The Bot events system does not start until RPL_WELCOME 001 is recieved from the server""" - if SpiceBot.botevents.check(SpiceBot.botevents.BOT_WELCOME): + if SpiceBot.events.check(SpiceBot.events.BOT_WELCOME): return - SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_WELCOME, "Welcome to the SpiceBot Events System") + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_WELCOME, "Welcome to the SpiceBot Events System") diff --git a/sopel_modules/SpiceBot_GifSearch/gif.py b/sopel_modules/SpiceBot_GifSearch/gif.py index 9298bee..518f95d 100644 --- a/sopel_modules/SpiceBot_GifSearch/gif.py +++ b/sopel_modules/SpiceBot_GifSearch/gif.py @@ -11,7 +11,7 @@ import sopel_modules.SpiceBot as SpiceBot import spicemanip -@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_GIFSEARCH]) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH]) @module.commands('gif') def gif_trigger(bot, trigger): diff --git a/sopel_modules/SpiceBot_GifSearch/gifapi.py b/sopel_modules/SpiceBot_GifSearch/gifapi.py index 147888f..dc119cd 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifapi.py +++ b/sopel_modules/SpiceBot_GifSearch/gifapi.py @@ -11,7 +11,7 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot -@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_GIFSEARCH]) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH]) @sopel.module.commands('(.*)') def gifapi_triggers(bot, trigger): diff --git a/sopel_modules/SpiceBot_GifSearch/gifsearch.py b/sopel_modules/SpiceBot_GifSearch/gifsearch.py index 6e697e8..75e84d9 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifsearch.py +++ b/sopel_modules/SpiceBot_GifSearch/gifsearch.py @@ -42,8 +42,8 @@ def configure(config): def setup(bot): - SpiceBot.botlogs.log('SpiceBot_GifSearch', "Starting Setup Procedure") - SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_GIFSEARCH]) + SpiceBot.logs.log('SpiceBot_GifSearch', "Starting Setup Procedure") + SpiceBot.events.startup_add([SpiceBot.events.BOT_GIFSEARCH]) if 'SpiceBot_GifSearch' not in bot.memory: bot.memory["SpiceBot_GifSearch"] = {"cache": {}, "badgiflinks": [], 'valid_gif_api_dict': {}} @@ -70,12 +70,12 @@ def setup(bot): bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'][gif_api] = valid_gif_api_dict[gif_api] for validgifapi in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): - SpiceBot.botcommands.commandsquery_register(bot, "prefix", validgifapi) + SpiceBot.commands.commandsquery_register(bot, "prefix", validgifapi) if validgifapi not in bot.memory["SpiceBot_GifSearch"]['cache'].keys(): bot.memory["SpiceBot_GifSearch"]['cache'][validgifapi] = dict() - SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_GIFSEARCH, "SpiceBot_GifSearch") + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_GIFSEARCH, "SpiceBot_GifSearch") def shutdown(bot): diff --git a/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py b/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py index 58536c1..63c18f5 100644 --- a/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py +++ b/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py @@ -17,14 +17,14 @@ def shutdown(bot): del bot.memory["SpiceBot_InvalidCommand"] -@sopel.module.event(SpiceBot.botevents.BOT_LOADED) +@sopel.module.event(SpiceBot.events.BOT_LOADED) @sopel.module.rule('.*') def bot_events_complete(bot, trigger): - for comtype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys(): - bot.memory["SpiceBot_InvalidCommand"]["valid"].extend(SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype].keys()) + for comtype in SpiceBot.commands.dict['commands'].keys(): + bot.memory["SpiceBot_InvalidCommand"]["valid"].extend(SpiceBot.commands.dict['commands'][comtype].keys()) -@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOADED, SpiceBot.botevents.BOT_COMMANDSQUERY]) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDSQUERY]) @sopel.module.commands('(.*)') def InvalidCommand_triggers(bot, trigger): return diff --git a/sopel_modules/SpiceBot_Kick/__init__.py b/sopel_modules/SpiceBot_Kick/__init__.py index 03b230c..d00503b 100644 --- a/sopel_modules/SpiceBot_Kick/__init__.py +++ b/sopel_modules/SpiceBot_Kick/__init__.py @@ -35,12 +35,12 @@ def configure(config): def setup(bot): # Inject KICK - SpiceBot.botlogs.log('SpiceBot_Kick', "Implanting Kick function into bot") + SpiceBot.logs.log('SpiceBot_Kick', "Implanting Kick function into bot") bot.kick = SopelKICK.kick sopel.bot.SopelWrapper.kick = SopelWrapperKICK.kick # verify config settings for server - SpiceBot.botlogs.log('SpiceBot_Kick', "Checking for config settings") + SpiceBot.logs.log('SpiceBot_Kick', "Checking for config settings") bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) diff --git a/sopel_modules/SpiceBot_Logs/IRC_Events b/sopel_modules/SpiceBot_Logs/IRC_Events index de5eb52..79a665d 100644 --- a/sopel_modules/SpiceBot_Logs/IRC_Events +++ b/sopel_modules/SpiceBot_Logs/IRC_Events @@ -11,1256 +11,1256 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.moduleevent('NICK') @sopel.modulerule('.*') def parse_event_NICK(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.moduleevent('QUIT') @sopel.modulerule('.*') def parse_event_QUIT(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.moduleevent('PART') def parse_event_PART(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.moduleevent('MODE') @sopel.modulerule('.*') def parse_event_MODE(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.moduleevent('KICK') @sopel.modulerule('.*') def parse_event_KICK(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.moduleevent('JOIN') @sopel.modulerule('.*') def parse_event_JOIN(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.moduleevent('INVITE') @sopel.modulerule('.*') def parse_event_INVITE(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.moduleevent('TOPIC') @sopel.modulerule('.*') def parse_event_TOPIC(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WELCOME = '001' @sopel.moduleevent('001') @sopel.modulerule('.*') def parse_event_001(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_YOURHOST = '002' @sopel.moduleevent('002') @sopel.modulerule('.*') def parse_event_002(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_CREATED = '003' @sopel.moduleevent('003') @sopel.modulerule('.*') def parse_event_003(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MYINFO = '004' @sopel.moduleevent('004') @sopel.modulerule('.*') def parse_event_004(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_BOUNCE = '005' @sopel.moduleevent('005') @sopel.modulerule('.*') def parse_event_005(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ISUPPORT = '005' @sopel.moduleevent('005') @sopel.modulerule('.*') def parse_event_005b(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACELINK = '200' @sopel.moduleevent('200') @sopel.modulerule('.*') def parse_event_200(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACECONNECTING = '201' @sopel.moduleevent('201') @sopel.modulerule('.*') def parse_event_201(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEHANDSHAKE = '202' @sopel.moduleevent('202') @sopel.modulerule('.*') def parse_event_202(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEUNKNOWN = '203' @sopel.moduleevent('203') @sopel.modulerule('.*') def parse_event_203(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEOPERATOR = '204' @sopel.moduleevent('204') @sopel.modulerule('.*') def parse_event_204(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEUSER = '205' @sopel.moduleevent('205') @sopel.modulerule('.*') def parse_event_205(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACESERVER = '206' @sopel.moduleevent('206') @sopel.modulerule('.*') def parse_event_206(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACESERVICE = '207' @sopel.moduleevent('207') @sopel.modulerule('.*') def parse_event_207(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACENEWTYPE = '208' @sopel.moduleevent('208') @sopel.modulerule('.*') def parse_event_208(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACECLASS = '209' @sopel.moduleevent('209') @sopel.modulerule('.*') def parse_event_209(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACERECONNECT = '210' @sopel.moduleevent('210') @sopel.modulerule('.*') def parse_event_210(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSLINKINFO = '211' @sopel.moduleevent('211') @sopel.modulerule('.*') def parse_event_211(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSCOMMANDS = '212' @sopel.moduleevent('212') @sopel.modulerule('.*') def parse_event_212(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSCLINE = '213' @sopel.moduleevent('213') @sopel.modulerule('.*') def parse_event_213(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSNLINE = '214' @sopel.moduleevent('214') @sopel.modulerule('.*') def parse_event_214(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSILINE = '215' @sopel.moduleevent('215') @sopel.modulerule('.*') def parse_event_215(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSKLINE = '216' @sopel.moduleevent('216') @sopel.modulerule('.*') def parse_event_216(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSYLINE = '218' @sopel.moduleevent('218') @sopel.modulerule('.*') def parse_event_218(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFSTATS = '219' @sopel.moduleevent('219') @sopel.modulerule('.*') def parse_event_219(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_UMODEIS = '221' @sopel.moduleevent('221') @sopel.modulerule('.*') def parse_event_221(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SERVLIST = '234' @sopel.moduleevent('234') @sopel.modulerule('.*') def parse_event_234(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SERVLISTEND = '235' @sopel.moduleevent('235') @sopel.modulerule('.*') def parse_event_235(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSLLINE = '241' @sopel.moduleevent('241') @sopel.modulerule('.*') def parse_event_241(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSUPTIME = '242' @sopel.moduleevent('242') @sopel.modulerule('.*') def parse_event_242(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSOLINE = '243' @sopel.moduleevent('243') @sopel.modulerule('.*') def parse_event_243(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSHLINE = '244' @sopel.moduleevent('244') @sopel.modulerule('.*') def parse_event_244(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERCLIENT = '251' @sopel.moduleevent('251') @sopel.modulerule('.*') def parse_event_251(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSEROP = '252' @sopel.moduleevent('252') @sopel.modulerule('.*') def parse_event_252(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERUNKNOWN = '253' @sopel.moduleevent('253') @sopel.modulerule('.*') def parse_event_253(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERCHANNELS = '254' @sopel.moduleevent('254') @sopel.modulerule('.*') def parse_event_254(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERME = '255' @sopel.moduleevent('255') @sopel.modulerule('.*') def parse_event_255(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINME = '256' @sopel.moduleevent('256') @sopel.modulerule('.*') def parse_event_256(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINLOC1 = '257' @sopel.moduleevent('257') @sopel.modulerule('.*') def parse_event_257(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINLOC2 = '258' @sopel.moduleevent('258') @sopel.modulerule('.*') def parse_event_258(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINEMAIL = '259' @sopel.moduleevent('259') @sopel.modulerule('.*') def parse_event_259(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACELOG = '261' @sopel.moduleevent('261') @sopel.modulerule('.*') def parse_event_261(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEEND = '262' @sopel.moduleevent('262') @sopel.modulerule('.*') def parse_event_262(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRYAGAIN = '263' @sopel.moduleevent('263') @sopel.modulerule('.*') def parse_event_263(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NONE = '300' @sopel.moduleevent('300') @sopel.modulerule('.*') def parse_event_300(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_AWAY = '301' @sopel.moduleevent('301') @sopel.modulerule('.*') def parse_event_301(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_USERHOST = '302' @sopel.moduleevent('302') @sopel.modulerule('.*') def parse_event_302(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ISON = '303' @sopel.moduleevent('303') @sopel.modulerule('.*') def parse_event_303(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_UNAWAY = '305' @sopel.moduleevent('305') @sopel.modulerule('.*') def parse_event_305(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NOWAWAY = '306' @sopel.moduleevent('306') @sopel.modulerule('.*') def parse_event_306(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISUSER = '311' @sopel.moduleevent('311') @sopel.modulerule('.*') def parse_event_311(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISSERVER = '312' @sopel.moduleevent('312') @sopel.modulerule('.*') def parse_event_312(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISOPERATOR = '313' @sopel.moduleevent('313') @sopel.modulerule('.*') def parse_event_313(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOWASUSER = '314' @sopel.moduleevent('314') @sopel.modulerule('.*') def parse_event_314(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFWHO = '315' @sopel.moduleevent('315') @sopel.modulerule('.*') def parse_event_315(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISIDLE = '317' @sopel.moduleevent('317') @sopel.modulerule('.*') def parse_event_317(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFWHOIS = '318' @sopel.moduleevent('318') @sopel.modulerule('.*') def parse_event_318(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISCHANNELS = '319' @sopel.moduleevent('319') @sopel.modulerule('.*') def parse_event_319(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LISTSTART = '321' @sopel.moduleevent('321') @sopel.modulerule('.*') def parse_event_321(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LIST = '322' @sopel.moduleevent('322') @sopel.modulerule('.*') def parse_event_322(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LISTEND = '323' @sopel.moduleevent('323') @sopel.modulerule('.*') def parse_event_323(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_CHANNELMODEIS = '324' @sopel.moduleevent('324') @sopel.modulerule('.*') def parse_event_324(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_UNIQOPIS = '325' @sopel.moduleevent('325') @sopel.modulerule('.*') def parse_event_325(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NOTOPIC = '331' @sopel.moduleevent('331') @sopel.modulerule('.*') def parse_event_331(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TOPIC = '332' @sopel.moduleevent('332') @sopel.modulerule('.*') def parse_event_332(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_INVITING = '341' @sopel.moduleevent('341') @sopel.modulerule('.*') def parse_event_341(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SUMMONING = '342' @sopel.moduleevent('342') @sopel.modulerule('.*') def parse_event_342(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_INVITELIST = '346' @sopel.moduleevent('346') @sopel.modulerule('.*') def parse_event_346(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFINVITELIST = '347' @sopel.moduleevent('347') @sopel.modulerule('.*') def parse_event_347(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_EXCEPTLIST = '348' @sopel.moduleevent('348') @sopel.modulerule('.*') def parse_event_348(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFEXCEPTLIST = '349' @sopel.moduleevent('349') @sopel.modulerule('.*') def parse_event_349(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_VERSION = '351' @sopel.moduleevent('351') @sopel.modulerule('.*') def parse_event_351(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOREPLY = '352' @sopel.moduleevent('352') @sopel.modulerule('.*') def parse_event_352(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NAMREPLY = '353' @sopel.moduleevent('353') @sopel.modulerule('.*') def parse_event_353(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOSPCRPL = '354' @sopel.moduleevent('354') @sopel.modulerule('.*') def parse_event_354(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LINKS = '364' @sopel.moduleevent('364') @sopel.modulerule('.*') def parse_event_364(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFLINKS = '365' @sopel.moduleevent('365') @sopel.modulerule('.*') def parse_event_365(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFNAMES = '366' @sopel.moduleevent('366') @sopel.modulerule('.*') def parse_event_366(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_BANLIST = '367' @sopel.moduleevent('367') @sopel.modulerule('.*') def parse_event_367(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFBANLIST = '368' @sopel.moduleevent('368') @sopel.modulerule('.*') def parse_event_368(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFWHOWAS = '369' @sopel.moduleevent('369') @sopel.modulerule('.*') def parse_event_369(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_INFO = '371' @sopel.moduleevent('371') @sopel.modulerule('.*') def parse_event_371(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MOTD = '372' @sopel.moduleevent('372') @sopel.modulerule('.*') def parse_event_372(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFINFO = '374' @sopel.moduleevent('374') @sopel.modulerule('.*') def parse_event_374(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MOTDSTART = '375' @sopel.moduleevent('375') @sopel.modulerule('.*') def parse_event_375(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFMOTD = '376' @sopel.moduleevent('376') @sopel.modulerule('.*') def parse_event_376(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_YOUREOPER = '381' @sopel.moduleevent('381') @sopel.modulerule('.*') def parse_event_381(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_REHASHING = '382' @sopel.moduleevent('382') @sopel.modulerule('.*') def parse_event_382(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_YOURESERVICE = '383' @sopel.moduleevent('383') @sopel.modulerule('.*') def parse_event_383(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TIME = '391' @sopel.moduleevent('391') @sopel.modulerule('.*') def parse_event_391(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_USERSSTART = '392' @sopel.moduleevent('392') @sopel.modulerule('.*') def parse_event_392(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_USERS = '393' @sopel.moduleevent('393') @sopel.modulerule('.*') def parse_event_393(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFUSERS = '394' @sopel.moduleevent('394') @sopel.modulerule('.*') def parse_event_394(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NOUSERS = '395' @sopel.moduleevent('395') @sopel.modulerule('.*') def parse_event_395(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHNICK = '401' @sopel.moduleevent('401') @sopel.modulerule('.*') def parse_event_401(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHSERVER = '402' @sopel.moduleevent('402') @sopel.modulerule('.*') def parse_event_402(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHCHANNEL = '403' @sopel.moduleevent('403') @sopel.modulerule('.*') def parse_event_403(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CANNOTSENDTOCHAN = '404' @sopel.moduleevent('404') @sopel.modulerule('.*') def parse_event_404(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_TOOMANYCHANNELS = '405' @sopel.moduleevent('405') @sopel.modulerule('.*') def parse_event_405(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_WASNOSUCHNICK = '406' @sopel.moduleevent('406') @sopel.modulerule('.*') def parse_event_406(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_TOOMANYTARGETS = '407' @sopel.moduleevent('407') @sopel.modulerule('.*') def parse_event_407(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHSERVICE = '408' @sopel.moduleevent('408') @sopel.modulerule('.*') def parse_event_408(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOORIGIN = '409' @sopel.moduleevent('409') @sopel.modulerule('.*') def parse_event_409(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_INVALIDCAPCMD = '410' @sopel.moduleevent('410') @sopel.modulerule('.*') def parse_event_410(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NORECIPIENT = '411' @sopel.moduleevent('411') @sopel.modulerule('.*') def parse_event_411(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTEXTTOSEND = '412' @sopel.moduleevent('412') @sopel.modulerule('.*') def parse_event_412(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTOPLEVEL = '413' @sopel.moduleevent('413') @sopel.modulerule('.*') def parse_event_413(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_WILDTOPLEVEL = '414' @sopel.moduleevent('414') @sopel.modulerule('.*') def parse_event_414(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BADMASK = '415' @sopel.moduleevent('415') @sopel.modulerule('.*') def parse_event_415(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNKNOWNCOMMAND = '421' @sopel.moduleevent('421') @sopel.modulerule('.*') def parse_event_421(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOMOTD = '422' @sopel.moduleevent('422') @sopel.modulerule('.*') def parse_event_422(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOADMININFO = '423' @sopel.moduleevent('423') @sopel.modulerule('.*') def parse_event_423(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_FILEERROR = '424' @sopel.moduleevent('424') @sopel.modulerule('.*') def parse_event_424(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NONICKNAMEGIVEN = '431' @sopel.moduleevent('431') @sopel.modulerule('.*') def parse_event_431(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_ERRONEUSNICKNAME = '432' @sopel.moduleevent('432') @sopel.modulerule('.*') def parse_event_432(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NICKNAMEINUSE = '433' @sopel.moduleevent('433') @sopel.modulerule('.*') def parse_event_433(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NICKCOLLISION = '436' @sopel.moduleevent('436') @sopel.modulerule('.*') def parse_event_436(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNAVAILRESOURCE = '437' @sopel.moduleevent('437') @sopel.modulerule('.*') def parse_event_437(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERNOTINCHANNEL = '441' @sopel.moduleevent('441') @sopel.modulerule('.*') def parse_event_441(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTONCHANNEL = '442' @sopel.moduleevent('442') @sopel.modulerule('.*') def parse_event_442(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERONCHANNEL = '443' @sopel.moduleevent('443') @sopel.modulerule('.*') def parse_event_443(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOLOGIN = '444' @sopel.moduleevent('444') @sopel.modulerule('.*') def parse_event_444(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SUMMONDISABLED = '445' @sopel.moduleevent('445') @sopel.modulerule('.*') def parse_event_445(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERSDISABLED = '446' @sopel.moduleevent('446') @sopel.modulerule('.*') def parse_event_446(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTREGISTERED = '451' @sopel.moduleevent('451') @sopel.modulerule('.*') def parse_event_451(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NEEDMOREPARAMS = '461' @sopel.moduleevent('461') @sopel.modulerule('.*') def parse_event_461(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_ALREADYREGISTRED = '462' @sopel.moduleevent('462') @sopel.modulerule('.*') def parse_event_462(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOPERMFORHOST = '463' @sopel.moduleevent('463') @sopel.modulerule('.*') def parse_event_463(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_PASSWDMISMATCH = '464' @sopel.moduleevent('464') @sopel.modulerule('.*') def parse_event_464(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_YOUREBANNEDCREEP = '465' @sopel.moduleevent('465') @sopel.modulerule('.*') def parse_event_465(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_YOUWILLBEBANNED = '466' @sopel.moduleevent('466') @sopel.modulerule('.*') def parse_event_466(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYSET = '467' @sopel.moduleevent('467') @sopel.modulerule('.*') def parse_event_467(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CHANNELISFULL = '471' @sopel.moduleevent('471') @sopel.modulerule('.*') def parse_event_471(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNKNOWNMODE = '472' @sopel.moduleevent('472') @sopel.modulerule('.*') def parse_event_472(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_INVITEONLYCHAN = '473' @sopel.moduleevent('473') @sopel.modulerule('.*') def parse_event_473(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BANNEDFROMCHAN = '474' @sopel.moduleevent('474') @sopel.modulerule('.*') def parse_event_474(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BADCHANNELKEY = '475' @sopel.moduleevent('475') @sopel.modulerule('.*') def parse_event_475(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BADCHANMASK = '476' @sopel.moduleevent('476') @sopel.modulerule('.*') def parse_event_476(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOCHANMODES = '477' @sopel.moduleevent('477') @sopel.modulerule('.*') def parse_event_477(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BANLISTFULL = '478' @sopel.moduleevent('478') @sopel.modulerule('.*') def parse_event_478(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOPRIVILEGES = '481' @sopel.moduleevent('481') @sopel.modulerule('.*') def parse_event_481(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CHANOPRIVSNEEDED = '482' @sopel.moduleevent('482') @sopel.modulerule('.*') def parse_event_482(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CANTKILLSERVER = '483' @sopel.moduleevent('483') @sopel.modulerule('.*') def parse_event_483(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_RESTRICTED = '484' @sopel.moduleevent('484') @sopel.modulerule('.*') def parse_event_484(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNIQOPPRIVSNEEDED = '485' @sopel.moduleevent('485') @sopel.modulerule('.*') def parse_event_485(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOOPERHOST = '491' @sopel.moduleevent('491') @sopel.modulerule('.*') def parse_event_491(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UMODEUNKNOWNFLAG = '501' @sopel.moduleevent('501') @sopel.modulerule('.*') def parse_event_501(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERSDONTMATCH = '502' @sopel.moduleevent('502') @sopel.modulerule('.*') def parse_event_502(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STARTTLS = '670' @sopel.moduleevent('670') @sopel.modulerule('.*') def parse_event_670(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_STARTTLS = '691' @sopel.moduleevent('691') @sopel.modulerule('.*') def parse_event_691(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MONONLINE = '730' @sopel.moduleevent('730') @sopel.modulerule('.*') def parse_event_730(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MONOFFLINE = '731' @sopel.moduleevent('731') @sopel.modulerule('.*') def parse_event_731(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MONLIST = '732' @sopel.moduleevent('732') @sopel.modulerule('.*') def parse_event_732(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFMONLIST = '733' @sopel.moduleevent('733') @sopel.modulerule('.*') def parse_event_733(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_MONLISTFULL = '734' @sopel.moduleevent('734') @sopel.modulerule('.*') def parse_event_734(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISKEYVALUE = '760' @sopel.moduleevent('760') @sopel.modulerule('.*') def parse_event_760(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_KEYVALUE = '761' @sopel.moduleevent('761') @sopel.modulerule('.*') def parse_event_761(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_METADATAEND = '762' @sopel.moduleevent('762') @sopel.modulerule('.*') def parse_event_762(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_METADATALIMIT = '764' @sopel.moduleevent('764') @sopel.modulerule('.*') def parse_event_764(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_TARGETINVALID = '765' @sopel.moduleevent('765') @sopel.modulerule('.*') def parse_event_765(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOMATCHINGKEY = '766' @sopel.moduleevent('766') @sopel.modulerule('.*') def parse_event_766(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYINVALID = '767' @sopel.moduleevent('767') @sopel.modulerule('.*') def parse_event_767(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYNOTSET = '768' @sopel.moduleevent('768') @sopel.modulerule('.*') def parse_event_768(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYNOPERMISSION = '769' @sopel.moduleevent('769') @sopel.modulerule('.*') def parse_event_769(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LOGGEDIN = '900' @sopel.moduleevent('900') @sopel.modulerule('.*') def parse_event_900(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LOGGEDOUT = '901' @sopel.moduleevent('901') @sopel.modulerule('.*') def parse_event_901(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NICKLOCKED = '902' @sopel.moduleevent('902') @sopel.modulerule('.*') def parse_event_902(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SASLSUCCESS = '903' @sopel.moduleevent('903') @sopel.modulerule('.*') def parse_event_903(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLFAIL = '904' @sopel.moduleevent('904') @sopel.modulerule('.*') def parse_event_904(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLTOOLONG = '905' @sopel.moduleevent('905') @sopel.modulerule('.*') def parse_event_905(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLABORTED = '906' @sopel.moduleevent('906') @sopel.modulerule('.*') def parse_event_906(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLALREADY = '907' @sopel.moduleevent('907') @sopel.modulerule('.*') def parse_event_907(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SASLMECHS = '908' @sopel.moduleevent('908') @sopel.modulerule('.*') def parse_event_908(bot, trigger): - SpiceBot.botlogs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) + SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) diff --git a/sopel_modules/SpiceBot_Logs/Logs_Command.py b/sopel_modules/SpiceBot_Logs/Logs_Command.py index 2917e09..6c42b3f 100644 --- a/sopel_modules/SpiceBot_Logs/Logs_Command.py +++ b/sopel_modules/SpiceBot_Logs/Logs_Command.py @@ -8,7 +8,7 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot -@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOGS]) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOGS]) @sopel.module.nickname_commands('logs', 'debug') def bot_command_logs(bot, trigger): @@ -20,11 +20,11 @@ def bot_command_logs(bot, trigger): logtype = spicemanip.main(triggerargs, 1) or None if not logtype: - bot.osd("Current valid log(s) include: " + spicemanip.main(SpiceBot.botlogs.SpiceBot_Logs["list"].keys(), 'andlist'), trigger.sender, 'action') + bot.osd("Current valid log(s) include: " + spicemanip.main(SpiceBot.logs.dict["list"].keys(), 'andlist'), trigger.sender, 'action') return - if not SpiceBot.inlist(logtype, SpiceBot.botlogs.SpiceBot_Logs["list"].keys()): - closestmatches = SpiceBot.similar_list(bot, logtype, SpiceBot.botlogs.SpiceBot_Logs["list"].keys(), 10, 'reverse') + if not SpiceBot.inlist(logtype, SpiceBot.logs.dict["list"].keys()): + closestmatches = SpiceBot.similar_list(bot, logtype, SpiceBot.logs.dict["list"].keys(), 10, 'reverse') if not len(closestmatches): bot.notice("No valid logs match " + str(logtype) + ".", trigger.nick) else: @@ -32,14 +32,14 @@ def bot_command_logs(bot, trigger): return - logtype = SpiceBot.inlist_match(logtype, SpiceBot.botlogs.SpiceBot_Logs["list"].keys()) + logtype = SpiceBot.inlist_match(logtype, SpiceBot.logs.dict["list"].keys()) if logtype == "Sopel_systemd": - logindex = SpiceBot.botlogs.systemd_logs_fetch(bot) + logindex = SpiceBot.logs.systemd_logs_fetch(bot) elif logtype == "Sopel_stdio": - logindex = SpiceBot.botlogs.stdio_logs_fetch(bot) + logindex = SpiceBot.logs.stdio_logs_fetch(bot) else: - logindex = SpiceBot.botlogs.SpiceBot_Logs["list"][logtype] + logindex = SpiceBot.logs.dict["list"][logtype] if not len(logindex): bot.osd("No logs found for " + str(logtype) + ".") diff --git a/sopel_modules/SpiceBot_Logs/Queue.py b/sopel_modules/SpiceBot_Logs/Queue.py index 0b93ff8..bbfe113 100644 --- a/sopel_modules/SpiceBot_Logs/Queue.py +++ b/sopel_modules/SpiceBot_Logs/Queue.py @@ -9,12 +9,12 @@ import sopel_modules.SpiceBot as SpiceBot def setup(bot): - SpiceBot.botlogs.log('SpiceBot_Logs', "Starting Setup Procedure") - SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_LOGS]) - SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_LOGS, "SpiceBot_Logs") + SpiceBot.logs.log('SpiceBot_Logs', "Starting Setup Procedure") + SpiceBot.events.startup_add([SpiceBot.events.BOT_LOGS]) + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_LOGS, "SpiceBot_Logs") -@sopel.module.event(SpiceBot.botevents.RPL_WELCOME) +@sopel.module.event(SpiceBot.events.RPL_WELCOME) @sopel.module.rule('.*') def join_log_channel(bot, trigger): @@ -26,9 +26,9 @@ def join_log_channel(bot, trigger): bot.write(('SAJOIN', bot.nick, channel)) while True: - if len(SpiceBot.botlogs.SpiceBot_Logs["queue"]): - bot.say(str(SpiceBot.botlogs.SpiceBot_Logs["queue"][0]), channel) - del SpiceBot.botlogs.SpiceBot_Logs["queue"][0] + if len(SpiceBot.logs.dict["queue"]): + bot.say(str(SpiceBot.logs.dict["queue"][0]), channel) + del SpiceBot.logs.dict["queue"][0] else: - SpiceBot.botlogs.sopel_config["logging_channel"] = False - SpiceBot.botlogs.SpiceBot_Logs["queue"] = [] + SpiceBot.logs.sopel_config["logging_channel"] = False + SpiceBot.logs.dict["queue"] = [] diff --git a/sopel_modules/SpiceBot_Messaging/Messaging.py b/sopel_modules/SpiceBot_Messaging/Messaging.py index 17754ac..66e81f5 100644 --- a/sopel_modules/SpiceBot_Messaging/Messaging.py +++ b/sopel_modules/SpiceBot_Messaging/Messaging.py @@ -41,7 +41,7 @@ def bot_command_process(bot, trigger): target = spicemanip.main(triggerargs, 1) if (target not in ['allchans', 'allnicks'] - and not SpiceBot.inlist(target.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys()) + 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 diff --git a/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py b/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py index 31c392c..01a90b9 100644 --- a/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py +++ b/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py @@ -13,8 +13,8 @@ import spicemanip def setup(bot): - SpiceBot.botlogs.log('SpiceBot_CommandsQuery', "Starting setup procedure") - SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_COMMANDSQUERY]) + SpiceBot.logs.log('SpiceBot_CommandsQuery', "Starting setup procedure") + SpiceBot.events.startup_add([SpiceBot.events.BOT_COMMANDSQUERY]) filepathlisting = [] @@ -36,7 +36,7 @@ def setup(bot): pypi_modules_dir = os.path.join(plugin_dir, pathname) filepathlisting.append(pypi_modules_dir) except Exception as e: - SpiceBot.botlogs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) + SpiceBot.logs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) # Extra directories filepathlist = [] @@ -120,7 +120,7 @@ def setup(bot): currentsuccesslines += 1 if currentsuccesslines: - SpiceBot.botcommands.SpiceBot_Commands['counts'] += 1 + SpiceBot.commands.dict['counts'] += 1 if len(filelinelist): for atlinefound in filelinelist: @@ -140,27 +140,27 @@ def setup(bot): else: comaliases = [] - SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype][maincom] = dict_from_file + SpiceBot.commands.dict['commands'][comtype][maincom] = dict_from_file for comalias in comaliases: - if comalias not in SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype].keys(): - SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype][comalias] = {"aliasfor": maincom} + if comalias not in SpiceBot.commands.dict['commands'][comtype].keys(): + SpiceBot.commands.dict['commands'][comtype][comalias] = {"aliasfor": maincom} for comtype in ['module', 'nickname', 'rule']: - SpiceBot.botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) + SpiceBot.logs.log('SpiceBot_CommandsQuery', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) - for command in SpiceBot.botcommands.SpiceBot_Commands['commands']['rule'].keys(): + for command in SpiceBot.commands.dict['commands']['rule'].keys(): if command.startswith("$nickname"): command = command.split("$nickname")[-1] - if command not in SpiceBot.botcommands.SpiceBot_Commands['nickrules']: - SpiceBot.botcommands.SpiceBot_Commands['nickrules'].append(command) + if command not in SpiceBot.commands.dict['nickrules']: + SpiceBot.commands.dict['nickrules'].append(command) - SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_COMMANDSQUERY, "SpiceBot_CommandsQuery") + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_COMMANDSQUERY, "SpiceBot_CommandsQuery") -@sopel.module.event(SpiceBot.botevents.BOT_LOADED) +@sopel.module.event(SpiceBot.events.BOT_LOADED) @sopel.module.rule('.*') def bot_events_complete(bot, trigger): - for comtype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys(): + for comtype in SpiceBot.commands.dict['commands'].keys(): if comtype not in ['module', 'nickname', 'rule']: - SpiceBot.botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True) + SpiceBot.logs.log('SpiceBot_CommandsQuery', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) diff --git a/sopel_modules/SpiceBot_Restart/Restart.py b/sopel_modules/SpiceBot_Restart/Restart.py index 76d5f56..bc4ef6f 100644 --- a/sopel_modules/SpiceBot_Restart/Restart.py +++ b/sopel_modules/SpiceBot_Restart/Restart.py @@ -15,7 +15,7 @@ def nickname_comand_restart(bot, trigger): bot.say("You are not authorized to perform this function.") quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!" - SpiceBot.botlogs.log('SpiceBot_Restart', quitmessage) + SpiceBot.logs.log('SpiceBot_Restart', quitmessage) bot.osd(quitmessage, bot.channels.keys()) # service_manip(bot, bot.nick, 'restart', 'SpiceBot_Restart') diff --git a/sopel_modules/SpiceBot_SopelPatches/Patches.py b/sopel_modules/SpiceBot_SopelPatches/Patches.py index 4df1c1e..eb4d009 100644 --- a/sopel_modules/SpiceBot_SopelPatches/Patches.py +++ b/sopel_modules/SpiceBot_SopelPatches/Patches.py @@ -11,9 +11,9 @@ import sopel_modules.SpiceBot as SpiceBot def setup(bot): - SpiceBot.botlogs.log('Sopel_Patch', "Patching Sopels built-in url_callbacks") + SpiceBot.logs.log('Sopel_Patch', "Patching Sopels built-in url_callbacks") if 'url_callbacks' not in bot.memory: bot.memory['url_callbacks'] = sopel.tools.SopelMemory() - SpiceBot.botlogs.log('Sopel_Patch', "Removing Stock Modules and verifying Dummy Command is present.") + SpiceBot.logs.log('Sopel_Patch', "Removing Stock Modules and verifying Dummy Command is present.") SpiceBot.stock_modules_begone(bot) diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py index 9ffdaeb..05364c9 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py @@ -8,8 +8,8 @@ import sopel_modules.SpiceBot as SpiceBot def setup(bot): - SpiceBot.botlogs.log('SpiceBot_StartupMonologue', "Starting setup procedure") - SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CHANNELS, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_COMMANDSQUERY]) # ,SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CONNECTED]) + SpiceBot.logs.log('SpiceBot_StartupMonologue', "Starting setup procedure") + SpiceBot.events.startup_add([SpiceBot.events.BOT_STARTUPMONOLOGUE_CHANNELS, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDSQUERY]) # ,SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED]) if 'SpiceBot_StartupMonologue' not in bot.memory: bot.memory['SpiceBot_StartupMonologue'] = [] diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py index 983e3e5..70eecdc 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py @@ -7,13 +7,13 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(SpiceBot.botevents.BOT_CHANNELS) +@sopel.module.event(SpiceBot.events.BOT_CHANNELS) @sopel.module.rule('.*') def bot_startup_monologue_channels(bot, trigger): botcount = len(bot.channels.keys()) - servercount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys()) + servercount = len(SpiceBot.channels.dict['list'].keys()) bot.memory['SpiceBot_StartupMonologue'].append("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") - SpiceBot.botlogs.log('SpiceBot_StartupMonologue', "I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") + SpiceBot.logs.log('SpiceBot_StartupMonologue', "I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") - SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CHANNELS, "SpiceBot_StartupMonologue") + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CHANNELS, "SpiceBot_StartupMonologue") diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py index a9132b9..e5a490f 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py @@ -7,16 +7,16 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(SpiceBot.botevents.BOT_COMMANDSQUERY) +@sopel.module.event(SpiceBot.events.BOT_COMMANDSQUERY) @sopel.module.rule('.*') def bot_startup_monologue_commands(bot, trigger): availablecomsnum, availablecomsfiles = 0, 0 - for commandstype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys(): - availablecomsnum += len(SpiceBot.botcommands.SpiceBot_Commands['commands'][commandstype].keys()) - availablecomsfiles += SpiceBot.botcommands.SpiceBot_Commands['counts'] + for commandstype in SpiceBot.commands.dict['commands'].keys(): + availablecomsnum += len(SpiceBot.commands.dict['commands'][commandstype].keys()) + availablecomsfiles += SpiceBot.commands.dict['counts'] bot.memory['SpiceBot_StartupMonologue'].append("There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.") - SpiceBot.botlogs.log('SpiceBot_StartupMonologue', "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.") + SpiceBot.logs.log('SpiceBot_StartupMonologue', "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.") - SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue") + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue") diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py index 4132e87..0eaa358 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py @@ -7,12 +7,12 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(SpiceBot.botevents.BOT_CONNECTED) +@sopel.module.event(SpiceBot.events.BOT_CONNECTED) @sopel.module.rule('.*') def bot_startup_monologue_start(bot, trigger): # Startup - SpiceBot.botlogs.log('SpiceBot_StartupMonologue', bot.nick + " is now starting. Please wait while I load my configuration") + SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " is now starting. Please wait while I load my configuration") bot.osd(" is now starting. Please wait while I load my configuration.", bot.channels.keys(), 'ACTION') - SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue") + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue") diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py index dffc532..34b0ede 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py @@ -6,11 +6,11 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(SpiceBot.botevents.BOT_STARTUPMONOLOGUE) +@sopel.module.event(SpiceBot.events.BOT_STARTUPMONOLOGUE) @sopel.module.rule('.*') def bot_startup_monologue_start(bot, trigger): - debuglines = SpiceBot.botlogs.stdio_logs_fetch(bot) + debuglines = SpiceBot.logs.stdio_logs_fetch(bot) searchphrasefound = [] for line in debuglines: @@ -19,9 +19,9 @@ def bot_startup_monologue_start(bot, trigger): if len(searchphrasefound): for foundphase in searchphrasefound: - SpiceBot.botlogs.log('SpiceBot_Logs', str(foundphase)) + SpiceBot.logs.log('SpiceBot_Logs', str(foundphase)) searchphrasefound.insert(0, "Notice to Bot Admins: ") searchphrasefound.append("Run the debug command for more information.") bot.osd(searchphrasefound, bot.channels.keys()) else: - SpiceBot.botlogs.log('SpiceBot_Logs', "No issues found at bot startup!", True) + SpiceBot.logs.log('SpiceBot_Logs', "No issues found at bot startup!", True) diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py index 84e1503..c7bb713 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py @@ -9,19 +9,19 @@ import sopel_modules.SpiceBot as SpiceBot import time -@sopel.module.event(SpiceBot.botevents.BOT_LOADED) +@sopel.module.event(SpiceBot.events.BOT_LOADED) @sopel.module.rule('.*') def bot_startup_monologue_display(bot, trigger): - if SpiceBot.botevents.SpiceBot_Events["RPL_WELCOME_Count"] == 1: + if SpiceBot.events.dict["RPL_WELCOME_Count"] == 1: timesince = SpiceBot.humanized_time(time.time() - bot.memory["SpiceBot_Uptime"]) SpiceBot.bot.memory['SpiceBot_StartupMonologue'].append("Startup took " + timesince) # Announce to chan, then handle some closing stuff - SpiceBot.botlogs.log('SpiceBot_StartupMonologue', bot.nick + " startup complete") + SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " startup complete") bot.memory['SpiceBot_StartupMonologue'].insert(0, " startup complete") bot.osd(bot.memory['SpiceBot_StartupMonologue'], bot.channels.keys(), 'ACTION') - SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue") - SpiceBot.botlogs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True) + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue") + SpiceBot.logs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True) diff --git a/sopel_modules/SpiceBot_Update/Update.py b/sopel_modules/SpiceBot_Update/Update.py index cda3d99..d0a4efc 100644 --- a/sopel_modules/SpiceBot_Update/Update.py +++ b/sopel_modules/SpiceBot_Update/Update.py @@ -23,7 +23,7 @@ def configure(config): def setup(bot): - SpiceBot.botlogs.log('SpiceBot_Update', "Initial Setup processing") + SpiceBot.logs.log('SpiceBot_Update', "Initial Setup processing") bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) @@ -48,7 +48,7 @@ def nickname_comand_update(bot, trigger): triggerargs = spicemanip.main(triggerargs, '2+', 'list') quitmessage = "Received command from " + trigger.nick + " to update from Github and restart" - SpiceBot.botlogs.log('SpiceBot_Update', quitmessage) + SpiceBot.logs.log('SpiceBot_Update', quitmessage) bot.osd(quitmessage, bot.channels.keys()) if commandused == 'nodeps': diff --git a/sopel_modules/SpiceBot_Uptime/Uptime.py b/sopel_modules/SpiceBot_Uptime/Uptime.py index 5a82333..8273582 100644 --- a/sopel_modules/SpiceBot_Uptime/Uptime.py +++ b/sopel_modules/SpiceBot_Uptime/Uptime.py @@ -12,7 +12,7 @@ import sopel_modules.SpiceBot as SpiceBot def setup(bot): if 'SpiceBot_Uptime' not in bot.memory: now = time.time() - SpiceBot.botlogs.log('SpiceBot_Uptime', "Start time set to " + str(time.time())) + SpiceBot.logs.log('SpiceBot_Uptime', "Start time set to " + str(time.time())) bot.memory["SpiceBot_Uptime"] = now diff --git a/sopel_modules/SpiceBot_osd/__init__.py b/sopel_modules/SpiceBot_osd/__init__.py index e753526..5dce22e 100644 --- a/sopel_modules/SpiceBot_osd/__init__.py +++ b/sopel_modules/SpiceBot_osd/__init__.py @@ -40,7 +40,7 @@ def configure(config): def setup(bot): # Inject OSD - SpiceBot.botlogs.log('SpiceBot_OSD', "Implanting OSD function into bot") + SpiceBot.logs.log('SpiceBot_OSD', "Implanting OSD function into bot") bot.osd = SopelOSD.osd sopel.bot.SopelWrapper.osd = SopelWrapperOSD.osd tools.get_available_message_bytes = ToolsOSD.get_available_message_bytes @@ -48,7 +48,7 @@ def setup(bot): tools.get_message_recipientgroups = ToolsOSD.get_message_recipientgroups # overwrite default bot messaging - SpiceBot.botlogs.log('SpiceBot_OSD', "Overwrite Default Sopel messaging commands") + SpiceBot.logs.log('SpiceBot_OSD', "Overwrite Default Sopel messaging commands") bot.osd = SopelOSD.osd bot.say = SopelOSD.say bot.action = SopelOSD.action @@ -61,7 +61,7 @@ def setup(bot): sopel.bot.SopelWrapper.reply = SopelWrapperOSD.reply # verify config settings for server - SpiceBot.botlogs.log('SpiceBot_OSD', "Checking for config settings") + SpiceBot.logs.log('SpiceBot_OSD', "Checking for config settings") bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) From 8304350b1a157028676260e2b9fd410d00e23c89 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 13:02:17 -0400 Subject: [PATCH 016/328] complete previous push --- sopel_modules/SpiceBot/Channels.py | 8 ++++---- sopel_modules/SpiceBot/Commands.py | 18 +++++++++--------- sopel_modules/SpiceBot/Database.py | 8 ++++---- sopel_modules/SpiceBot/Events.py | 14 +++++++------- sopel_modules/SpiceBot/Logs.py | 8 ++++---- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index a403875..37f0e6d 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -11,10 +11,10 @@ class BotChannels(): """This Logs all channels known to the server""" def __init__(self): self.channel_lock = False - self.SpiceBot_Channels = { - "list": {}, - "InitialProcess": False - } + self.dict = { + "list": {}, + "InitialProcess": False + } def channel_list_request(self, bot): bot.write(['LIST']) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 67edcca..d9e3293 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -12,15 +12,15 @@ import spicemanip class BotCommands(): """This Logs all commands known to the bot""" def __init__(self): - self.SpiceBot_Commands = { - "counts": 0, - "commands": { - 'module': {}, - 'nickname': {}, - 'rule': {} - }, - "nickrules": [] - } + self.dict = { + "counts": 0, + "commands": { + 'module': {}, + 'nickname': {}, + 'rule': {} + }, + "nickrules": [] + } def commandsquery_register(self, bot, command_type, validcoms, aliasfor=None): diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index e8822d0..c03364d 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -14,10 +14,10 @@ class BotDatabase(): def __init__(self): self.lock = threading.Lock() - self.SpiceBot_Database = { - "nicks": {}, - "channels": {}, - } + self.dict = { + "nicks": {}, + "channels": {}, + } """Nick""" diff --git a/sopel_modules/SpiceBot/Events.py b/sopel_modules/SpiceBot/Events.py index 46d9068..96185d0 100644 --- a/sopel_modules/SpiceBot/Events.py +++ b/sopel_modules/SpiceBot/Events.py @@ -33,13 +33,13 @@ class BotEvents(object): self.BOT_LOADED = '1004' self.BOT_RECONNECTED = '1005' self.defaultevents = [self.BOT_WELCOME, self.BOT_READY, self.BOT_CONNECTED, self.BOT_LOADED, self.BOT_RECONNECTED] - self.SpiceBot_Events = { - "assigned_IDs": {1000: "Default", 1001: "BOT_WELCOME", 1002: "BOT_READY", 1003: "BOT_CONNECTED", 1004: "BOT_LOADED", 1005: "BOT_RECONNECTED"}, - "triggers_recieved": {}, - "trigger_queue": [], - "startup_required": [self.BOT_WELCOME, self.BOT_READY, self.BOT_CONNECTED], - "RPL_WELCOME_Count": 0 - } + self.dict = { + "assigned_IDs": {1000: "Default", 1001: "BOT_WELCOME", 1002: "BOT_READY", 1003: "BOT_CONNECTED", 1004: "BOT_LOADED", 1005: "BOT_RECONNECTED"}, + "triggers_recieved": {}, + "trigger_queue": [], + "startup_required": [self.BOT_WELCOME, self.BOT_READY, self.BOT_CONNECTED], + "RPL_WELCOME_Count": 0 + } def __getattr__(self, name): ''' will only get called for undefined attributes ''' diff --git a/sopel_modules/SpiceBot/Logs.py b/sopel_modules/SpiceBot/Logs.py index 6937137..9927d09 100644 --- a/sopel_modules/SpiceBot/Logs.py +++ b/sopel_modules/SpiceBot/Logs.py @@ -15,10 +15,10 @@ import spicemanip class BotLogs(): """This Is a contained source of log information""" def __init__(self): - self.SpiceBot_Logs = { - "list": {"Sopel_systemd": [], "Sopel_stdio": []}, - "queue": [] - } + self.dict = { + "list": {"Sopel_systemd": [], "Sopel_stdio": []}, + "queue": [] + } self.sopel_config = { "logging_channel": True } From 4e46bbc0a2c40d5dcf4b737c0adf8170773f5111 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 14:06:41 -0400 Subject: [PATCH 017/328] too many updates for one test, but oh well --- sopel_modules/SpiceBot/Channels.py | 8 + sopel_modules/SpiceBot/Commands.py | 154 ++++++++++++++++-- sopel_modules/SpiceBot/Events.py | 8 + sopel_modules/SpiceBot/Logs.py | 18 +- sopel_modules/SpiceBot_AI/AI.py | 15 -- .../{gifapi.py => Gif_API_Commands.py} | 0 .../{gif.py => Gif_Command.py} | 0 .../SpiceBot_GifSearch/Gif_Search_Commands | 34 ++++ sopel_modules/SpiceBot_GifSearch/__init__.py | 5 +- sopel_modules/SpiceBot_GifSearch/gifsearch.py | 7 +- .../SpiceBot_InvalidCommand/InvalidCommand.py | 42 ----- .../SpiceBot_InvalidCommand/__init__.py | 12 -- sopel_modules/SpiceBot_Logs/Logs_Command.py | 7 +- .../SpiceBot_Module_Parsing/ModuleParsing.py | 147 +---------------- 14 files changed, 221 insertions(+), 236 deletions(-) rename sopel_modules/SpiceBot_GifSearch/{gifapi.py => Gif_API_Commands.py} (100%) rename sopel_modules/SpiceBot_GifSearch/{gif.py => Gif_Command.py} (100%) create mode 100644 sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands delete mode 100644 sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py delete mode 100644 sopel_modules/SpiceBot_InvalidCommand/__init__.py diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index 37f0e6d..998ee55 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -5,11 +5,13 @@ This is the SpiceBot Channels system. """ import sopel import re +import threading class BotChannels(): """This Logs all channels known to the server""" def __init__(self): + self.lock = threading.Lock() self.channel_lock = False self.dict = { "list": {}, @@ -23,16 +25,20 @@ class BotChannels(): self.channel_lock = True def channel_list_recieve_input(self, trigger): + self.lock.acquire() channel, _, topic = trigger.args[1:] if channel.lower() not in self.dict['list'].keys(): self.dict['list'][channel.lower()] = dict() self.dict['list'][channel.lower()]['name'] = channel self.dict['list'][channel.lower()]['topic'] = self.topic_compile(topic) self.channel_lock = True + self.lock.release() def channel_list_recieve_finish(self): + self.lock.acquire() if not self.dict['InitialProcess']: self.dict['InitialProcess'] = True + self.lock.release() self.channel_lock = False def topic_compile(self, topic): @@ -49,7 +55,9 @@ class BotChannels(): if len(bot.channels[channel].privileges.keys()) == 1 and channel not in ignorepartlist and channel.startswith("#"): bot.part(channel, "Leaving Empty Channel") if channel.lower() in self.dict['list']: + self.lock.acquire() del self.dict['list'][channel.lower()] + self.lock.release() def join_all_channels(self, bot): if bot.config.SpiceBot_Channels.joinall: diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index d9e3293..dbdc57d 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -5,13 +5,19 @@ This is the SpiceBot Commands system. This Class stores commands in an easy to access manner """ +import sopel +import os +import threading import spicemanip +from .Logs import logs + class BotCommands(): """This Logs all commands known to the bot""" def __init__(self): + self.lock = threading.Lock() self.dict = { "counts": 0, "commands": { @@ -19,17 +25,20 @@ class BotCommands(): 'nickname': {}, 'rule': {} }, - "nickrules": [] } - def commandsquery_register(self, bot, command_type, validcoms, aliasfor=None): + def register(self, bot, command_dict): + + self.lock.acquire() + + command_type = command_dict["comtype"] + validcoms = command_dict["validcoms"] if not isinstance(validcoms, list): validcoms = [validcoms] if command_type not in self.dict['commands'].keys(): self.dict['commands'][command_type] = dict() - self.dict['counts'] += 1 dict_from_file = dict() @@ -37,20 +46,139 @@ class BotCommands(): if "validcoms" not in dict_from_file.keys(): dict_from_file["validcoms"] = validcoms - if not aliasfor: - - maincom = dict_from_file["validcoms"][0] - if len(dict_from_file["validcoms"]) > 1: - comaliases = spicemanip.main(dict_from_file["validcoms"], '2+', 'list') - else: - comaliases = [] - self.dict['commands'][command_type][maincom] = dict_from_file + maincom = dict_from_file["validcoms"][0] + if len(dict_from_file["validcoms"]) > 1: + comaliases = spicemanip.main(dict_from_file["validcoms"], '2+', 'list') else: - comaliases = validcoms + comaliases = [] + self.dict['commands'][command_type][maincom] = dict_from_file for comalias in comaliases: if comalias not in self.dict['commands'][command_type].keys(): - self.dict['commands'][command_type][comalias] = {"aliasfor": aliasfor} + self.dict['commands'][command_type][comalias] = {"aliasfor": maincom} + + self.lock.release() + + def module_directory_list(self, bot): + filepathlisting = [] + + # main Modules directory + main_dir = os.path.dirname(os.path.abspath(sopel.__file__)) + modules_dir = os.path.join(main_dir, 'modules') + filepathlisting.append(modules_dir) + + # Home Directory + home_modules_dir = os.path.join(bot.config.homedir, 'modules') + if os.path.isdir(home_modules_dir): + filepathlisting.append(home_modules_dir) + + # pypi installed + try: + import sopel_modules + for plugin_dir in set(sopel_modules.__path__): + for pathname in os.listdir(plugin_dir): + pypi_modules_dir = os.path.join(plugin_dir, pathname) + filepathlisting.append(pypi_modules_dir) + except Exception as e: + logs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) + + # Extra directories + for directory in bot.config.core.extra: + filepathlisting.append(directory) + + return filepathlisting + + def module_files_list(self, bot): + filepathlisting = self.module_directory_list(bot) + + filepathlist = [] + + for directory in filepathlisting: + for pathname in os.listdir(directory): + path = os.path.join(directory, pathname) + if (os.path.isfile(path) and path.endswith('.py') and not path.startswith('_')): + if pathname not in ["SpiceBot_dummycommand.py"]: + filepathlist.append(str(path)) + + # CoreTasks + main_dir = os.path.dirname(os.path.abspath(sopel.__file__)) + ct_path = os.path.join(main_dir, 'coretasks.py') + filepathlist.append(ct_path) + + return filepathlist + + def module_files_parse(self, bot): + filepathlist = self.module_files_list(bot) + + for modulefile in filepathlist: + + module_file_lines = [] + module_file = open(modulefile, 'r') + lines = module_file.readlines() + for line in lines: + module_file_lines.append(line) + module_file.close() + + detected_lines = [] + for line in module_file_lines: + + if str(line).startswith("@"): + line = str(line)[1:] + + if str(line).startswith(tuple(["commands", "module.commands", "sopel.module.commands"])): + line = str(line).split("commands")[-1] + line = "commands" + line + detected_lines.append(line) + elif str(line).startswith(tuple(["nickname_commands", "module.nickname_commands", "sopel.module.nickname_commands"])): + line = str(line).split("nickname_commands")[-1] + line = "nickname_commands" + line + detected_lines.append(line) + elif str(line).startswith(tuple(["rule", "module.rule", "sopel.module.rule"])): + line = str(line).split("rule")[-1] + line = "rule" + line + else: + line = None + + if line: + detected_lines.append(line) + + if len(detected_lines): + + filelinelist = [] + currentsuccesslines = 0 + for detected_line in detected_lines: + + # Commands + if str(detected_line).startswith("commands"): + comtype = "module" + validcoms = eval(str(detected_line).split("commands")[-1]) + elif str(detected_line).startswith("nickname_commands"): + comtype = "nickname" + validcoms = eval(str(detected_line).split("nickname_commands")[-1]) + elif str(detected_line).startswith("rule"): + comtype = "rule" + validcoms = eval(str(detected_line).split("rule")[-1]) + + if isinstance(validcoms, tuple): + validcoms = list(validcoms) + else: + validcoms = [validcoms] + for regexcom in ["(.*)", '^\?(.*)']: + if regexcom in validcoms: + while regexcom in validcoms: + validcoms.remove(regexcom) + + if len(validcoms): + validcomdict = {"comtype": comtype, "validcoms": validcoms} + filelinelist.append(validcomdict) + currentsuccesslines += 1 + + if currentsuccesslines: + self.dict['counts'] += 1 + + if len(filelinelist): + for atlinefound in filelinelist: + self.register(bot, atlinefound) commands = BotCommands() diff --git a/sopel_modules/SpiceBot/Events.py b/sopel_modules/SpiceBot/Events.py index 96185d0..9337192 100644 --- a/sopel_modules/SpiceBot/Events.py +++ b/sopel_modules/SpiceBot/Events.py @@ -10,6 +10,7 @@ self-trigger the bot into performing actions import sopel import functools +import threading class BotEvents(object): @@ -26,6 +27,7 @@ class BotEvents(object): """ def __init__(self): + self.lock = threading.Lock() self.RPL_WELCOME = '001' # This is a defined IRC event self.BOT_WELCOME = '1001' self.BOT_READY = '1002' @@ -43,9 +45,11 @@ class BotEvents(object): def __getattr__(self, name): ''' will only get called for undefined attributes ''' + self.lock.acquire() eventnumber = max(list(self.dict["assigned_IDs"].keys())) + 1 self.dict["assigned_IDs"][eventnumber] = str(name) setattr(self, name, str(eventnumber)) + self.lock.release() return str(eventnumber) def trigger(self, bot, number, message="SpiceBot_Events"): @@ -66,6 +70,7 @@ class BotEvents(object): self.recieved({"number": number, "message": message}) def recieved(self, trigger): + self.lock.acquire() if isinstance(trigger, dict): eventnumber = str(trigger["number"]) message = str(trigger["message"]) @@ -75,6 +80,7 @@ class BotEvents(object): if eventnumber not in self.dict["triggers_recieved"]: self.dict["triggers_recieved"][eventnumber] = [] self.dict["triggers_recieved"][eventnumber].append(message) + self.lock.release() def check(self, checklist): if not isinstance(checklist, list): @@ -85,9 +91,11 @@ class BotEvents(object): return True def startup_add(self, startlist): + self.lock.acquire() if not isinstance(startlist, list): startlist = [str(startlist)] self.dict["startup_required"].extend(startlist) + self.lock.release() def startup_check(self): for number in self.dict["startup_required"]: diff --git a/sopel_modules/SpiceBot/Logs.py b/sopel_modules/SpiceBot/Logs.py index 9927d09..0b13058 100644 --- a/sopel_modules/SpiceBot/Logs.py +++ b/sopel_modules/SpiceBot/Logs.py @@ -6,8 +6,8 @@ This is the SpiceBot Logs system. This Class stores logs in an easy to access manner """ - import sopel +import threading import os import spicemanip @@ -15,6 +15,7 @@ import spicemanip class BotLogs(): """This Is a contained source of log information""" def __init__(self): + self.lock = threading.Lock() self.dict = { "list": {"Sopel_systemd": [], "Sopel_stdio": []}, "queue": [] @@ -24,6 +25,9 @@ class BotLogs(): } def log(self, logtype, logentry, stdio=False): + + self.lock.acquire() + logtitle = "[" + logtype + "]" logmessage = logtitle + " " + logentry @@ -37,8 +41,16 @@ class BotLogs(): self.dict["list"][logtype] = [] self.dict["list"][logtype].append(logentry) - def get_logs(self): - return [] + self.lock.release() + + def get_logs(self, bot, logtype): + if logtype == "Sopel_systemd": + logindex = self.systemd_logs_fetch(bot) + elif logtype == "Sopel_stdio": + logindex = self.stdio_logs_fetch(bot) + else: + logindex = self.dict["list"][logtype] + return logindex def stdio_logs_fetch(self, bot): diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index 593b8c9..3d2a6ae 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -27,9 +27,6 @@ def bot_command_nick(bot, trigger): fulltrigger = spicemanip.main(triggerargs, 0).lower() - if fulltrigger in SpiceBot.commands.dict['nickrules']: - return - if fulltrigger.lower().startswith("what is"): searchterm = spicemanip.main(triggerargs, "3+") or None if searchterm: @@ -151,15 +148,3 @@ def bot_command_nick(bot, trigger): # bot.osd("I have never seen " + str(target) + ".") # TODO return - - else: - - closestmatches = SpiceBot.similar_list(bot, triggercommand, SpiceBot.commands.dict['commands']["nickname"].keys(), 3, 'reverse') - - if len(closestmatches): - closestmatches = spicemanip.main(closestmatches, "andlist") - bot.osd("I don't know what you are asking me to do! Did you mean: " + str(closestmatches) + "?") - return - else: - bot.osd("I don't know what you are asking me to do!") - return diff --git a/sopel_modules/SpiceBot_GifSearch/gifapi.py b/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py similarity index 100% rename from sopel_modules/SpiceBot_GifSearch/gifapi.py rename to sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py diff --git a/sopel_modules/SpiceBot_GifSearch/gif.py b/sopel_modules/SpiceBot_GifSearch/Gif_Command.py similarity index 100% rename from sopel_modules/SpiceBot_GifSearch/gif.py rename to sopel_modules/SpiceBot_GifSearch/Gif_Command.py diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands b/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands new file mode 100644 index 0000000..dc119cd --- /dev/null +++ b/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands @@ -0,0 +1,34 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +from .gifsearch import getGif + +import sopel.module + +import spicemanip + +import sopel_modules.SpiceBot as SpiceBot + + +@SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH]) +@sopel.module.commands('(.*)') +def gifapi_triggers(bot, trigger): + + triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'prefix_command') + + if triggercommand not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): + return + + if not len(triggerargs): + return bot.osd("Please present a query to search.") + + query = spicemanip.main(triggerargs, 0) + searchdict = {"query": query, "gifsearch": triggercommand} + + gifdict = getGif(bot, searchdict) + + if gifdict["error"]: + bot.osd(gifdict["error"]) + else: + bot.osd(str(gifdict['gifapi'].title() + " Result (" + str(query) + " #" + str(gifdict["returnnum"]) + "): " + str(gifdict["returnurl"]))) diff --git a/sopel_modules/SpiceBot_GifSearch/__init__.py b/sopel_modules/SpiceBot_GifSearch/__init__.py index 841b583..c91a38a 100644 --- a/sopel_modules/SpiceBot_GifSearch/__init__.py +++ b/sopel_modules/SpiceBot_GifSearch/__init__.py @@ -5,8 +5,9 @@ Sopel Gif Search builds a convenient framework for searching for Gifs """ from __future__ import unicode_literals, absolute_import, division, print_function -from .gif import * -from .gifapi import * +from .Gif_Command import * +from .Gif_API_Commands import * +# from .Gif_Search_Commands import * from .gifsearch import * __author__ = 'Sam Zick' diff --git a/sopel_modules/SpiceBot_GifSearch/gifsearch.py b/sopel_modules/SpiceBot_GifSearch/gifsearch.py index 75e84d9..a63bf93 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifsearch.py +++ b/sopel_modules/SpiceBot_GifSearch/gifsearch.py @@ -70,7 +70,12 @@ def setup(bot): bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'][gif_api] = valid_gif_api_dict[gif_api] for validgifapi in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): - SpiceBot.commands.commandsquery_register(bot, "prefix", validgifapi) + command_dict = { + "comtype": "prefix", + "validcoms": validgifapi + } + SpiceBot.commands.dict['counts'] += 1 + SpiceBot.commands.register(bot, command_dict) if validgifapi not in bot.memory["SpiceBot_GifSearch"]['cache'].keys(): bot.memory["SpiceBot_GifSearch"]['cache'][validgifapi] = dict() diff --git a/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py b/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py deleted file mode 100644 index 63c18f5..0000000 --- a/sopel_modules/SpiceBot_InvalidCommand/InvalidCommand.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -def setup(bot): - if 'SpiceBot_InvalidCommand' not in bot.memory: - bot.memory["SpiceBot_InvalidCommand"] = {"valid": []} - - -def shutdown(bot): - if "SpiceBot_InvalidCommand" in bot.memory: - del bot.memory["SpiceBot_InvalidCommand"] - - -@sopel.module.event(SpiceBot.events.BOT_LOADED) -@sopel.module.rule('.*') -def bot_events_complete(bot, trigger): - for comtype in SpiceBot.commands.dict['commands'].keys(): - bot.memory["SpiceBot_InvalidCommand"]["valid"].extend(SpiceBot.commands.dict['commands'][comtype].keys()) - - -@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDSQUERY]) -@sopel.module.commands('(.*)') -def InvalidCommand_triggers(bot, trigger): - return - - triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'prefix_command') - - # patch for people typing "...", maybe other stuff, but this verifies that there is still a command here - if triggercommand.startswith("."): - return - - if triggercommand not in bot.memory["SpiceBot_InvalidCommand"]["valid"]: - invalid_display = ["I don't seem to have a command for " + str(triggercommand) + "!"] - invalid_display.append("If you have a suggestion for this command, you can run .feature ." + str(triggercommand)) - invalid_display.append("ADD DESCRIPTION HERE!") - bot.osd(invalid_display, trigger.nick, 'notice') diff --git a/sopel_modules/SpiceBot_InvalidCommand/__init__.py b/sopel_modules/SpiceBot_InvalidCommand/__init__.py deleted file mode 100644 index 6f704e6..0000000 --- a/sopel_modules/SpiceBot_InvalidCommand/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -# coding=utf8 -"""Sopel Gif Search - -Sopel Gif Search builds a convenient framework for searching for Gifs -""" -from __future__ import unicode_literals, absolute_import, division, print_function - -from .InvalidCommand import * - -__author__ = 'Sam Zick' -__email__ = 'sam@deathbybandaid.net' -__version__ = '0.1.1' diff --git a/sopel_modules/SpiceBot_Logs/Logs_Command.py b/sopel_modules/SpiceBot_Logs/Logs_Command.py index 6c42b3f..46f3322 100644 --- a/sopel_modules/SpiceBot_Logs/Logs_Command.py +++ b/sopel_modules/SpiceBot_Logs/Logs_Command.py @@ -34,12 +34,7 @@ def bot_command_logs(bot, trigger): logtype = SpiceBot.inlist_match(logtype, SpiceBot.logs.dict["list"].keys()) - if logtype == "Sopel_systemd": - logindex = SpiceBot.logs.systemd_logs_fetch(bot) - elif logtype == "Sopel_stdio": - logindex = SpiceBot.logs.stdio_logs_fetch(bot) - else: - logindex = SpiceBot.logs.dict["list"][logtype] + logindex = SpiceBot.logs.get_logs(bot, logtype) if not len(logindex): bot.osd("No logs found for " + str(logtype) + ".") diff --git a/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py b/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py index 01a90b9..0802d4f 100644 --- a/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py +++ b/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py @@ -5,156 +5,19 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import sopel import sopel.module -import os - import sopel_modules.SpiceBot as SpiceBot -import spicemanip - def setup(bot): - SpiceBot.logs.log('SpiceBot_CommandsQuery', "Starting setup procedure") + SpiceBot.logs.log('SpiceBot_Commands', "Starting setup procedure") SpiceBot.events.startup_add([SpiceBot.events.BOT_COMMANDSQUERY]) - filepathlisting = [] - - # main Modules directory - main_dir = os.path.dirname(os.path.abspath(sopel.__file__)) - modules_dir = os.path.join(main_dir, 'modules') - filepathlisting.append(modules_dir) - - # Home Directory - home_modules_dir = os.path.join(bot.config.homedir, 'modules') - if os.path.isdir(home_modules_dir): - filepathlisting.append(home_modules_dir) - - # pypi installed - try: - import sopel_modules - for plugin_dir in set(sopel_modules.__path__): - for pathname in os.listdir(plugin_dir): - pypi_modules_dir = os.path.join(plugin_dir, pathname) - filepathlisting.append(pypi_modules_dir) - except Exception as e: - SpiceBot.logs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) - - # Extra directories - filepathlist = [] - for directory in bot.config.core.extra: - filepathlisting.append(directory) - - for directory in filepathlisting: - for pathname in os.listdir(directory): - path = os.path.join(directory, pathname) - if (os.path.isfile(path) and path.endswith('.py') and not path.startswith('_')): - if pathname not in ["SpiceBot_dummycommand.py"]: - filepathlist.append(str(path)) - - # CoreTasks - ct_path = os.path.join(main_dir, 'coretasks.py') - filepathlist.append(ct_path) - - for modulefile in filepathlist: - - module_file_lines = [] - module_file = open(modulefile, 'r') - lines = module_file.readlines() - for line in lines: - module_file_lines.append(line) - module_file.close() - - dict_from_file = dict() - - detected_lines = [] - for line in module_file_lines: - - if str(line).startswith("@"): - line = str(line)[1:] - - if str(line).startswith(tuple(["commands", "module.commands", "sopel.module.commands"])): - line = str(line).split("commands")[-1] - line = "commands" + line - detected_lines.append(line) - elif str(line).startswith(tuple(["nickname_commands", "module.nickname_commands", "sopel.module.nickname_commands"])): - line = str(line).split("nickname_commands")[-1] - line = "nickname_commands" + line - detected_lines.append(line) - elif str(line).startswith(tuple(["rule", "module.rule", "sopel.module.rule"])): - line = str(line).split("rule")[-1] - line = "rule" + line - else: - line = None - - if line: - detected_lines.append(line) - - if len(detected_lines): - - filelinelist = [] - currentsuccesslines = 0 - for detected_line in detected_lines: - - # Commands - if str(detected_line).startswith("commands"): - comtype = "module" - validcoms = eval(str(detected_line).split("commands")[-1]) - elif str(detected_line).startswith("nickname_commands"): - comtype = "nickname" - validcoms = eval(str(detected_line).split("nickname_commands")[-1]) - elif str(detected_line).startswith("rule"): - comtype = "rule" - validcoms = eval(str(detected_line).split("rule")[-1]) - - if isinstance(validcoms, tuple): - validcoms = list(validcoms) - else: - validcoms = [validcoms] - for regexcom in ["(.*)", '^\?(.*)']: - if regexcom in validcoms: - while regexcom in validcoms: - validcoms.remove(regexcom) - - if len(validcoms): - validcomdict = {"comtype": comtype, "validcoms": validcoms} - filelinelist.append(validcomdict) - currentsuccesslines += 1 - - if currentsuccesslines: - SpiceBot.commands.dict['counts'] += 1 - - if len(filelinelist): - for atlinefound in filelinelist: - - dict_from_file = dict() - - comtype = atlinefound["comtype"] - validcoms = atlinefound["validcoms"] - - # default command to filename - if "validcoms" not in dict_from_file.keys(): - dict_from_file["validcoms"] = validcoms - - maincom = dict_from_file["validcoms"][0] - if len(dict_from_file["validcoms"]) > 1: - comaliases = spicemanip.main(dict_from_file["validcoms"], '2+', 'list') - else: - comaliases = [] - - SpiceBot.commands.dict['commands'][comtype][maincom] = dict_from_file - for comalias in comaliases: - if comalias not in SpiceBot.commands.dict['commands'][comtype].keys(): - SpiceBot.commands.dict['commands'][comtype][comalias] = {"aliasfor": maincom} + SpiceBot.commands.module_files_parse(bot) for comtype in ['module', 'nickname', 'rule']: - SpiceBot.logs.log('SpiceBot_CommandsQuery', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) + SpiceBot.logs.log('SpiceBot_Commands', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) - for command in SpiceBot.commands.dict['commands']['rule'].keys(): - if command.startswith("$nickname"): - command = command.split("$nickname")[-1] - if command not in SpiceBot.commands.dict['nickrules']: - SpiceBot.commands.dict['nickrules'].append(command) - - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_COMMANDSQUERY, "SpiceBot_CommandsQuery") + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_COMMANDSQUERY, "SpiceBot_Commands") @sopel.module.event(SpiceBot.events.BOT_LOADED) @@ -163,4 +26,4 @@ def bot_events_complete(bot, trigger): for comtype in SpiceBot.commands.dict['commands'].keys(): if comtype not in ['module', 'nickname', 'rule']: - SpiceBot.logs.log('SpiceBot_CommandsQuery', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) + SpiceBot.logs.log('SpiceBot_Commands', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) From 49d11813e0fc23e7cc906beee13260e73fc47994 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 14:16:04 -0400 Subject: [PATCH 018/328] irc events logger --- sopel_modules/SpiceBot_Logs/{IRC_Events => IRC_Events.py} | 0 sopel_modules/SpiceBot_Logs/__init__.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename sopel_modules/SpiceBot_Logs/{IRC_Events => IRC_Events.py} (100%) diff --git a/sopel_modules/SpiceBot_Logs/IRC_Events b/sopel_modules/SpiceBot_Logs/IRC_Events.py similarity index 100% rename from sopel_modules/SpiceBot_Logs/IRC_Events rename to sopel_modules/SpiceBot_Logs/IRC_Events.py diff --git a/sopel_modules/SpiceBot_Logs/__init__.py b/sopel_modules/SpiceBot_Logs/__init__.py index f6ef4d1..eace833 100644 --- a/sopel_modules/SpiceBot_Logs/__init__.py +++ b/sopel_modules/SpiceBot_Logs/__init__.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi from .Queue import * from .Logs_Command import * -# from .IRC_Events import * +from .IRC_Events import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' From 830aacc38c633993dab98b25c3e3f8c6ff321903 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 14:20:16 -0400 Subject: [PATCH 019/328] more logging --- sopel_modules/SpiceBot/Events.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Events.py b/sopel_modules/SpiceBot/Events.py index 9337192..b228352 100644 --- a/sopel_modules/SpiceBot/Events.py +++ b/sopel_modules/SpiceBot/Events.py @@ -7,11 +7,12 @@ We utilize the Sopel code for event numbers and self-trigger the bot into performing actions """ - import sopel import functools import threading +from .Logs import logs + class BotEvents(object): """A dynamic listing of all the notable Bot numeric events. @@ -71,12 +72,14 @@ class BotEvents(object): def recieved(self, trigger): self.lock.acquire() + if isinstance(trigger, dict): eventnumber = str(trigger["number"]) message = str(trigger["message"]) else: eventnumber = str(trigger.event) message = trigger.args[1] + logs.log('SpiceBot_Events', str(eventnumber) + " " + str(message)) if eventnumber not in self.dict["triggers_recieved"]: self.dict["triggers_recieved"][eventnumber] = [] self.dict["triggers_recieved"][eventnumber].append(message) From 2f95cdc066b9b8273ac52e529c5653abd818a3c5 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 14:24:28 -0400 Subject: [PATCH 020/328] fix --- sopel_modules/SpiceBot_Logs/IRC_Events.py | 362 +++++++++++----------- 1 file changed, 181 insertions(+), 181 deletions(-) diff --git a/sopel_modules/SpiceBot_Logs/IRC_Events.py b/sopel_modules/SpiceBot_Logs/IRC_Events.py index 79a665d..2d1236b 100644 --- a/sopel_modules/SpiceBot_Logs/IRC_Events.py +++ b/sopel_modules/SpiceBot_Logs/IRC_Events.py @@ -8,1259 +8,1259 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@sopel.moduleevent('NICK') +@sopel.module.event('NICK') @sopel.modulerule('.*') def parse_event_NICK(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) -@sopel.moduleevent('QUIT') +@sopel.module.event('QUIT') @sopel.modulerule('.*') def parse_event_QUIT(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) -@sopel.moduleevent('PART') +@sopel.module.event('PART') def parse_event_PART(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) -@sopel.moduleevent('MODE') +@sopel.module.event('MODE') @sopel.modulerule('.*') def parse_event_MODE(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) -@sopel.moduleevent('KICK') +@sopel.module.event('KICK') @sopel.modulerule('.*') def parse_event_KICK(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) -@sopel.moduleevent('JOIN') +@sopel.module.event('JOIN') @sopel.modulerule('.*') def parse_event_JOIN(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) -@sopel.moduleevent('INVITE') +@sopel.module.event('INVITE') @sopel.modulerule('.*') def parse_event_INVITE(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) -@sopel.moduleevent('TOPIC') +@sopel.module.event('TOPIC') @sopel.modulerule('.*') def parse_event_TOPIC(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WELCOME = '001' -@sopel.moduleevent('001') +@sopel.module.event('001') @sopel.modulerule('.*') def parse_event_001(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_YOURHOST = '002' -@sopel.moduleevent('002') +@sopel.module.event('002') @sopel.modulerule('.*') def parse_event_002(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_CREATED = '003' -@sopel.moduleevent('003') +@sopel.module.event('003') @sopel.modulerule('.*') def parse_event_003(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MYINFO = '004' -@sopel.moduleevent('004') +@sopel.module.event('004') @sopel.modulerule('.*') def parse_event_004(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_BOUNCE = '005' -@sopel.moduleevent('005') +@sopel.module.event('005') @sopel.modulerule('.*') def parse_event_005(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ISUPPORT = '005' -@sopel.moduleevent('005') +@sopel.module.event('005') @sopel.modulerule('.*') def parse_event_005b(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACELINK = '200' -@sopel.moduleevent('200') +@sopel.module.event('200') @sopel.modulerule('.*') def parse_event_200(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACECONNECTING = '201' -@sopel.moduleevent('201') +@sopel.module.event('201') @sopel.modulerule('.*') def parse_event_201(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEHANDSHAKE = '202' -@sopel.moduleevent('202') +@sopel.module.event('202') @sopel.modulerule('.*') def parse_event_202(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEUNKNOWN = '203' -@sopel.moduleevent('203') +@sopel.module.event('203') @sopel.modulerule('.*') def parse_event_203(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEOPERATOR = '204' -@sopel.moduleevent('204') +@sopel.module.event('204') @sopel.modulerule('.*') def parse_event_204(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEUSER = '205' -@sopel.moduleevent('205') +@sopel.module.event('205') @sopel.modulerule('.*') def parse_event_205(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACESERVER = '206' -@sopel.moduleevent('206') +@sopel.module.event('206') @sopel.modulerule('.*') def parse_event_206(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACESERVICE = '207' -@sopel.moduleevent('207') +@sopel.module.event('207') @sopel.modulerule('.*') def parse_event_207(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACENEWTYPE = '208' -@sopel.moduleevent('208') +@sopel.module.event('208') @sopel.modulerule('.*') def parse_event_208(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACECLASS = '209' -@sopel.moduleevent('209') +@sopel.module.event('209') @sopel.modulerule('.*') def parse_event_209(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACERECONNECT = '210' -@sopel.moduleevent('210') +@sopel.module.event('210') @sopel.modulerule('.*') def parse_event_210(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSLINKINFO = '211' -@sopel.moduleevent('211') +@sopel.module.event('211') @sopel.modulerule('.*') def parse_event_211(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSCOMMANDS = '212' -@sopel.moduleevent('212') +@sopel.module.event('212') @sopel.modulerule('.*') def parse_event_212(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSCLINE = '213' -@sopel.moduleevent('213') +@sopel.module.event('213') @sopel.modulerule('.*') def parse_event_213(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSNLINE = '214' -@sopel.moduleevent('214') +@sopel.module.event('214') @sopel.modulerule('.*') def parse_event_214(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSILINE = '215' -@sopel.moduleevent('215') +@sopel.module.event('215') @sopel.modulerule('.*') def parse_event_215(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSKLINE = '216' -@sopel.moduleevent('216') +@sopel.module.event('216') @sopel.modulerule('.*') def parse_event_216(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSYLINE = '218' -@sopel.moduleevent('218') +@sopel.module.event('218') @sopel.modulerule('.*') def parse_event_218(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFSTATS = '219' -@sopel.moduleevent('219') +@sopel.module.event('219') @sopel.modulerule('.*') def parse_event_219(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_UMODEIS = '221' -@sopel.moduleevent('221') +@sopel.module.event('221') @sopel.modulerule('.*') def parse_event_221(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SERVLIST = '234' -@sopel.moduleevent('234') +@sopel.module.event('234') @sopel.modulerule('.*') def parse_event_234(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SERVLISTEND = '235' -@sopel.moduleevent('235') +@sopel.module.event('235') @sopel.modulerule('.*') def parse_event_235(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSLLINE = '241' -@sopel.moduleevent('241') +@sopel.module.event('241') @sopel.modulerule('.*') def parse_event_241(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSUPTIME = '242' -@sopel.moduleevent('242') +@sopel.module.event('242') @sopel.modulerule('.*') def parse_event_242(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSOLINE = '243' -@sopel.moduleevent('243') +@sopel.module.event('243') @sopel.modulerule('.*') def parse_event_243(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSHLINE = '244' -@sopel.moduleevent('244') +@sopel.module.event('244') @sopel.modulerule('.*') def parse_event_244(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERCLIENT = '251' -@sopel.moduleevent('251') +@sopel.module.event('251') @sopel.modulerule('.*') def parse_event_251(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSEROP = '252' -@sopel.moduleevent('252') +@sopel.module.event('252') @sopel.modulerule('.*') def parse_event_252(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERUNKNOWN = '253' -@sopel.moduleevent('253') +@sopel.module.event('253') @sopel.modulerule('.*') def parse_event_253(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERCHANNELS = '254' -@sopel.moduleevent('254') +@sopel.module.event('254') @sopel.modulerule('.*') def parse_event_254(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERME = '255' -@sopel.moduleevent('255') +@sopel.module.event('255') @sopel.modulerule('.*') def parse_event_255(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINME = '256' -@sopel.moduleevent('256') +@sopel.module.event('256') @sopel.modulerule('.*') def parse_event_256(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINLOC1 = '257' -@sopel.moduleevent('257') +@sopel.module.event('257') @sopel.modulerule('.*') def parse_event_257(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINLOC2 = '258' -@sopel.moduleevent('258') +@sopel.module.event('258') @sopel.modulerule('.*') def parse_event_258(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINEMAIL = '259' -@sopel.moduleevent('259') +@sopel.module.event('259') @sopel.modulerule('.*') def parse_event_259(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACELOG = '261' -@sopel.moduleevent('261') +@sopel.module.event('261') @sopel.modulerule('.*') def parse_event_261(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEEND = '262' -@sopel.moduleevent('262') +@sopel.module.event('262') @sopel.modulerule('.*') def parse_event_262(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRYAGAIN = '263' -@sopel.moduleevent('263') +@sopel.module.event('263') @sopel.modulerule('.*') def parse_event_263(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NONE = '300' -@sopel.moduleevent('300') +@sopel.module.event('300') @sopel.modulerule('.*') def parse_event_300(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_AWAY = '301' -@sopel.moduleevent('301') +@sopel.module.event('301') @sopel.modulerule('.*') def parse_event_301(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_USERHOST = '302' -@sopel.moduleevent('302') +@sopel.module.event('302') @sopel.modulerule('.*') def parse_event_302(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ISON = '303' -@sopel.moduleevent('303') +@sopel.module.event('303') @sopel.modulerule('.*') def parse_event_303(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_UNAWAY = '305' -@sopel.moduleevent('305') +@sopel.module.event('305') @sopel.modulerule('.*') def parse_event_305(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NOWAWAY = '306' -@sopel.moduleevent('306') +@sopel.module.event('306') @sopel.modulerule('.*') def parse_event_306(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISUSER = '311' -@sopel.moduleevent('311') +@sopel.module.event('311') @sopel.modulerule('.*') def parse_event_311(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISSERVER = '312' -@sopel.moduleevent('312') +@sopel.module.event('312') @sopel.modulerule('.*') def parse_event_312(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISOPERATOR = '313' -@sopel.moduleevent('313') +@sopel.module.event('313') @sopel.modulerule('.*') def parse_event_313(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOWASUSER = '314' -@sopel.moduleevent('314') +@sopel.module.event('314') @sopel.modulerule('.*') def parse_event_314(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFWHO = '315' -@sopel.moduleevent('315') +@sopel.module.event('315') @sopel.modulerule('.*') def parse_event_315(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISIDLE = '317' -@sopel.moduleevent('317') +@sopel.module.event('317') @sopel.modulerule('.*') def parse_event_317(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFWHOIS = '318' -@sopel.moduleevent('318') +@sopel.module.event('318') @sopel.modulerule('.*') def parse_event_318(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISCHANNELS = '319' -@sopel.moduleevent('319') +@sopel.module.event('319') @sopel.modulerule('.*') def parse_event_319(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LISTSTART = '321' -@sopel.moduleevent('321') +@sopel.module.event('321') @sopel.modulerule('.*') def parse_event_321(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LIST = '322' -@sopel.moduleevent('322') +@sopel.module.event('322') @sopel.modulerule('.*') def parse_event_322(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LISTEND = '323' -@sopel.moduleevent('323') +@sopel.module.event('323') @sopel.modulerule('.*') def parse_event_323(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_CHANNELMODEIS = '324' -@sopel.moduleevent('324') +@sopel.module.event('324') @sopel.modulerule('.*') def parse_event_324(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_UNIQOPIS = '325' -@sopel.moduleevent('325') +@sopel.module.event('325') @sopel.modulerule('.*') def parse_event_325(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NOTOPIC = '331' -@sopel.moduleevent('331') +@sopel.module.event('331') @sopel.modulerule('.*') def parse_event_331(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TOPIC = '332' -@sopel.moduleevent('332') +@sopel.module.event('332') @sopel.modulerule('.*') def parse_event_332(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_INVITING = '341' -@sopel.moduleevent('341') +@sopel.module.event('341') @sopel.modulerule('.*') def parse_event_341(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SUMMONING = '342' -@sopel.moduleevent('342') +@sopel.module.event('342') @sopel.modulerule('.*') def parse_event_342(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_INVITELIST = '346' -@sopel.moduleevent('346') +@sopel.module.event('346') @sopel.modulerule('.*') def parse_event_346(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFINVITELIST = '347' -@sopel.moduleevent('347') +@sopel.module.event('347') @sopel.modulerule('.*') def parse_event_347(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_EXCEPTLIST = '348' -@sopel.moduleevent('348') +@sopel.module.event('348') @sopel.modulerule('.*') def parse_event_348(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFEXCEPTLIST = '349' -@sopel.moduleevent('349') +@sopel.module.event('349') @sopel.modulerule('.*') def parse_event_349(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_VERSION = '351' -@sopel.moduleevent('351') +@sopel.module.event('351') @sopel.modulerule('.*') def parse_event_351(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOREPLY = '352' -@sopel.moduleevent('352') +@sopel.module.event('352') @sopel.modulerule('.*') def parse_event_352(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NAMREPLY = '353' -@sopel.moduleevent('353') +@sopel.module.event('353') @sopel.modulerule('.*') def parse_event_353(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOSPCRPL = '354' -@sopel.moduleevent('354') +@sopel.module.event('354') @sopel.modulerule('.*') def parse_event_354(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LINKS = '364' -@sopel.moduleevent('364') +@sopel.module.event('364') @sopel.modulerule('.*') def parse_event_364(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFLINKS = '365' -@sopel.moduleevent('365') +@sopel.module.event('365') @sopel.modulerule('.*') def parse_event_365(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFNAMES = '366' -@sopel.moduleevent('366') +@sopel.module.event('366') @sopel.modulerule('.*') def parse_event_366(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_BANLIST = '367' -@sopel.moduleevent('367') +@sopel.module.event('367') @sopel.modulerule('.*') def parse_event_367(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFBANLIST = '368' -@sopel.moduleevent('368') +@sopel.module.event('368') @sopel.modulerule('.*') def parse_event_368(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFWHOWAS = '369' -@sopel.moduleevent('369') +@sopel.module.event('369') @sopel.modulerule('.*') def parse_event_369(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_INFO = '371' -@sopel.moduleevent('371') +@sopel.module.event('371') @sopel.modulerule('.*') def parse_event_371(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MOTD = '372' -@sopel.moduleevent('372') +@sopel.module.event('372') @sopel.modulerule('.*') def parse_event_372(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFINFO = '374' -@sopel.moduleevent('374') +@sopel.module.event('374') @sopel.modulerule('.*') def parse_event_374(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MOTDSTART = '375' -@sopel.moduleevent('375') +@sopel.module.event('375') @sopel.modulerule('.*') def parse_event_375(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFMOTD = '376' -@sopel.moduleevent('376') +@sopel.module.event('376') @sopel.modulerule('.*') def parse_event_376(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_YOUREOPER = '381' -@sopel.moduleevent('381') +@sopel.module.event('381') @sopel.modulerule('.*') def parse_event_381(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_REHASHING = '382' -@sopel.moduleevent('382') +@sopel.module.event('382') @sopel.modulerule('.*') def parse_event_382(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_YOURESERVICE = '383' -@sopel.moduleevent('383') +@sopel.module.event('383') @sopel.modulerule('.*') def parse_event_383(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TIME = '391' -@sopel.moduleevent('391') +@sopel.module.event('391') @sopel.modulerule('.*') def parse_event_391(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_USERSSTART = '392' -@sopel.moduleevent('392') +@sopel.module.event('392') @sopel.modulerule('.*') def parse_event_392(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_USERS = '393' -@sopel.moduleevent('393') +@sopel.module.event('393') @sopel.modulerule('.*') def parse_event_393(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFUSERS = '394' -@sopel.moduleevent('394') +@sopel.module.event('394') @sopel.modulerule('.*') def parse_event_394(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NOUSERS = '395' -@sopel.moduleevent('395') +@sopel.module.event('395') @sopel.modulerule('.*') def parse_event_395(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHNICK = '401' -@sopel.moduleevent('401') +@sopel.module.event('401') @sopel.modulerule('.*') def parse_event_401(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHSERVER = '402' -@sopel.moduleevent('402') +@sopel.module.event('402') @sopel.modulerule('.*') def parse_event_402(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHCHANNEL = '403' -@sopel.moduleevent('403') +@sopel.module.event('403') @sopel.modulerule('.*') def parse_event_403(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CANNOTSENDTOCHAN = '404' -@sopel.moduleevent('404') +@sopel.module.event('404') @sopel.modulerule('.*') def parse_event_404(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_TOOMANYCHANNELS = '405' -@sopel.moduleevent('405') +@sopel.module.event('405') @sopel.modulerule('.*') def parse_event_405(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_WASNOSUCHNICK = '406' -@sopel.moduleevent('406') +@sopel.module.event('406') @sopel.modulerule('.*') def parse_event_406(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_TOOMANYTARGETS = '407' -@sopel.moduleevent('407') +@sopel.module.event('407') @sopel.modulerule('.*') def parse_event_407(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHSERVICE = '408' -@sopel.moduleevent('408') +@sopel.module.event('408') @sopel.modulerule('.*') def parse_event_408(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOORIGIN = '409' -@sopel.moduleevent('409') +@sopel.module.event('409') @sopel.modulerule('.*') def parse_event_409(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_INVALIDCAPCMD = '410' -@sopel.moduleevent('410') +@sopel.module.event('410') @sopel.modulerule('.*') def parse_event_410(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NORECIPIENT = '411' -@sopel.moduleevent('411') +@sopel.module.event('411') @sopel.modulerule('.*') def parse_event_411(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTEXTTOSEND = '412' -@sopel.moduleevent('412') +@sopel.module.event('412') @sopel.modulerule('.*') def parse_event_412(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTOPLEVEL = '413' -@sopel.moduleevent('413') +@sopel.module.event('413') @sopel.modulerule('.*') def parse_event_413(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_WILDTOPLEVEL = '414' -@sopel.moduleevent('414') +@sopel.module.event('414') @sopel.modulerule('.*') def parse_event_414(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BADMASK = '415' -@sopel.moduleevent('415') +@sopel.module.event('415') @sopel.modulerule('.*') def parse_event_415(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNKNOWNCOMMAND = '421' -@sopel.moduleevent('421') +@sopel.module.event('421') @sopel.modulerule('.*') def parse_event_421(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOMOTD = '422' -@sopel.moduleevent('422') +@sopel.module.event('422') @sopel.modulerule('.*') def parse_event_422(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOADMININFO = '423' -@sopel.moduleevent('423') +@sopel.module.event('423') @sopel.modulerule('.*') def parse_event_423(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_FILEERROR = '424' -@sopel.moduleevent('424') +@sopel.module.event('424') @sopel.modulerule('.*') def parse_event_424(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NONICKNAMEGIVEN = '431' -@sopel.moduleevent('431') +@sopel.module.event('431') @sopel.modulerule('.*') def parse_event_431(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_ERRONEUSNICKNAME = '432' -@sopel.moduleevent('432') +@sopel.module.event('432') @sopel.modulerule('.*') def parse_event_432(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NICKNAMEINUSE = '433' -@sopel.moduleevent('433') +@sopel.module.event('433') @sopel.modulerule('.*') def parse_event_433(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NICKCOLLISION = '436' -@sopel.moduleevent('436') +@sopel.module.event('436') @sopel.modulerule('.*') def parse_event_436(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNAVAILRESOURCE = '437' -@sopel.moduleevent('437') +@sopel.module.event('437') @sopel.modulerule('.*') def parse_event_437(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERNOTINCHANNEL = '441' -@sopel.moduleevent('441') +@sopel.module.event('441') @sopel.modulerule('.*') def parse_event_441(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTONCHANNEL = '442' -@sopel.moduleevent('442') +@sopel.module.event('442') @sopel.modulerule('.*') def parse_event_442(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERONCHANNEL = '443' -@sopel.moduleevent('443') +@sopel.module.event('443') @sopel.modulerule('.*') def parse_event_443(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOLOGIN = '444' -@sopel.moduleevent('444') +@sopel.module.event('444') @sopel.modulerule('.*') def parse_event_444(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SUMMONDISABLED = '445' -@sopel.moduleevent('445') +@sopel.module.event('445') @sopel.modulerule('.*') def parse_event_445(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERSDISABLED = '446' -@sopel.moduleevent('446') +@sopel.module.event('446') @sopel.modulerule('.*') def parse_event_446(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTREGISTERED = '451' -@sopel.moduleevent('451') +@sopel.module.event('451') @sopel.modulerule('.*') def parse_event_451(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NEEDMOREPARAMS = '461' -@sopel.moduleevent('461') +@sopel.module.event('461') @sopel.modulerule('.*') def parse_event_461(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_ALREADYREGISTRED = '462' -@sopel.moduleevent('462') +@sopel.module.event('462') @sopel.modulerule('.*') def parse_event_462(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOPERMFORHOST = '463' -@sopel.moduleevent('463') +@sopel.module.event('463') @sopel.modulerule('.*') def parse_event_463(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_PASSWDMISMATCH = '464' -@sopel.moduleevent('464') +@sopel.module.event('464') @sopel.modulerule('.*') def parse_event_464(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_YOUREBANNEDCREEP = '465' -@sopel.moduleevent('465') +@sopel.module.event('465') @sopel.modulerule('.*') def parse_event_465(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_YOUWILLBEBANNED = '466' -@sopel.moduleevent('466') +@sopel.module.event('466') @sopel.modulerule('.*') def parse_event_466(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYSET = '467' -@sopel.moduleevent('467') +@sopel.module.event('467') @sopel.modulerule('.*') def parse_event_467(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CHANNELISFULL = '471' -@sopel.moduleevent('471') +@sopel.module.event('471') @sopel.modulerule('.*') def parse_event_471(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNKNOWNMODE = '472' -@sopel.moduleevent('472') +@sopel.module.event('472') @sopel.modulerule('.*') def parse_event_472(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_INVITEONLYCHAN = '473' -@sopel.moduleevent('473') +@sopel.module.event('473') @sopel.modulerule('.*') def parse_event_473(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BANNEDFROMCHAN = '474' -@sopel.moduleevent('474') +@sopel.module.event('474') @sopel.modulerule('.*') def parse_event_474(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BADCHANNELKEY = '475' -@sopel.moduleevent('475') +@sopel.module.event('475') @sopel.modulerule('.*') def parse_event_475(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BADCHANMASK = '476' -@sopel.moduleevent('476') +@sopel.module.event('476') @sopel.modulerule('.*') def parse_event_476(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOCHANMODES = '477' -@sopel.moduleevent('477') +@sopel.module.event('477') @sopel.modulerule('.*') def parse_event_477(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BANLISTFULL = '478' -@sopel.moduleevent('478') +@sopel.module.event('478') @sopel.modulerule('.*') def parse_event_478(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOPRIVILEGES = '481' -@sopel.moduleevent('481') +@sopel.module.event('481') @sopel.modulerule('.*') def parse_event_481(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CHANOPRIVSNEEDED = '482' -@sopel.moduleevent('482') +@sopel.module.event('482') @sopel.modulerule('.*') def parse_event_482(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CANTKILLSERVER = '483' -@sopel.moduleevent('483') +@sopel.module.event('483') @sopel.modulerule('.*') def parse_event_483(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_RESTRICTED = '484' -@sopel.moduleevent('484') +@sopel.module.event('484') @sopel.modulerule('.*') def parse_event_484(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNIQOPPRIVSNEEDED = '485' -@sopel.moduleevent('485') +@sopel.module.event('485') @sopel.modulerule('.*') def parse_event_485(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOOPERHOST = '491' -@sopel.moduleevent('491') +@sopel.module.event('491') @sopel.modulerule('.*') def parse_event_491(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UMODEUNKNOWNFLAG = '501' -@sopel.moduleevent('501') +@sopel.module.event('501') @sopel.modulerule('.*') def parse_event_501(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERSDONTMATCH = '502' -@sopel.moduleevent('502') +@sopel.module.event('502') @sopel.modulerule('.*') def parse_event_502(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STARTTLS = '670' -@sopel.moduleevent('670') +@sopel.module.event('670') @sopel.modulerule('.*') def parse_event_670(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_STARTTLS = '691' -@sopel.moduleevent('691') +@sopel.module.event('691') @sopel.modulerule('.*') def parse_event_691(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MONONLINE = '730' -@sopel.moduleevent('730') +@sopel.module.event('730') @sopel.modulerule('.*') def parse_event_730(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MONOFFLINE = '731' -@sopel.moduleevent('731') +@sopel.module.event('731') @sopel.modulerule('.*') def parse_event_731(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MONLIST = '732' -@sopel.moduleevent('732') +@sopel.module.event('732') @sopel.modulerule('.*') def parse_event_732(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFMONLIST = '733' -@sopel.moduleevent('733') +@sopel.module.event('733') @sopel.modulerule('.*') def parse_event_733(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_MONLISTFULL = '734' -@sopel.moduleevent('734') +@sopel.module.event('734') @sopel.modulerule('.*') def parse_event_734(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISKEYVALUE = '760' -@sopel.moduleevent('760') +@sopel.module.event('760') @sopel.modulerule('.*') def parse_event_760(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_KEYVALUE = '761' -@sopel.moduleevent('761') +@sopel.module.event('761') @sopel.modulerule('.*') def parse_event_761(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_METADATAEND = '762' -@sopel.moduleevent('762') +@sopel.module.event('762') @sopel.modulerule('.*') def parse_event_762(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_METADATALIMIT = '764' -@sopel.moduleevent('764') +@sopel.module.event('764') @sopel.modulerule('.*') def parse_event_764(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_TARGETINVALID = '765' -@sopel.moduleevent('765') +@sopel.module.event('765') @sopel.modulerule('.*') def parse_event_765(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOMATCHINGKEY = '766' -@sopel.moduleevent('766') +@sopel.module.event('766') @sopel.modulerule('.*') def parse_event_766(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYINVALID = '767' -@sopel.moduleevent('767') +@sopel.module.event('767') @sopel.modulerule('.*') def parse_event_767(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYNOTSET = '768' -@sopel.moduleevent('768') +@sopel.module.event('768') @sopel.modulerule('.*') def parse_event_768(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYNOPERMISSION = '769' -@sopel.moduleevent('769') +@sopel.module.event('769') @sopel.modulerule('.*') def parse_event_769(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LOGGEDIN = '900' -@sopel.moduleevent('900') +@sopel.module.event('900') @sopel.modulerule('.*') def parse_event_900(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LOGGEDOUT = '901' -@sopel.moduleevent('901') +@sopel.module.event('901') @sopel.modulerule('.*') def parse_event_901(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NICKLOCKED = '902' -@sopel.moduleevent('902') +@sopel.module.event('902') @sopel.modulerule('.*') def parse_event_902(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SASLSUCCESS = '903' -@sopel.moduleevent('903') +@sopel.module.event('903') @sopel.modulerule('.*') def parse_event_903(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLFAIL = '904' -@sopel.moduleevent('904') +@sopel.module.event('904') @sopel.modulerule('.*') def parse_event_904(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLTOOLONG = '905' -@sopel.moduleevent('905') +@sopel.module.event('905') @sopel.modulerule('.*') def parse_event_905(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLABORTED = '906' -@sopel.moduleevent('906') +@sopel.module.event('906') @sopel.modulerule('.*') def parse_event_906(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLALREADY = '907' -@sopel.moduleevent('907') +@sopel.module.event('907') @sopel.modulerule('.*') def parse_event_907(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SASLMECHS = '908' -@sopel.moduleevent('908') +@sopel.module.event('908') @sopel.modulerule('.*') def parse_event_908(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) From 7398c742a70c5928f6d96f7a39c75259c2eb2b20 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 14:25:28 -0400 Subject: [PATCH 021/328] split IRC Logging --- .../{SpiceBot_Logs => SpiceBot_IRC_Logs}/IRC_Events.py | 0 sopel_modules/SpiceBot_IRC_Logs/__init__.py | 8 ++++++++ sopel_modules/SpiceBot_Logs/__init__.py | 1 - 3 files changed, 8 insertions(+), 1 deletion(-) rename sopel_modules/{SpiceBot_Logs => SpiceBot_IRC_Logs}/IRC_Events.py (100%) create mode 100644 sopel_modules/SpiceBot_IRC_Logs/__init__.py diff --git a/sopel_modules/SpiceBot_Logs/IRC_Events.py b/sopel_modules/SpiceBot_IRC_Logs/IRC_Events.py similarity index 100% rename from sopel_modules/SpiceBot_Logs/IRC_Events.py rename to sopel_modules/SpiceBot_IRC_Logs/IRC_Events.py diff --git a/sopel_modules/SpiceBot_IRC_Logs/__init__.py b/sopel_modules/SpiceBot_IRC_Logs/__init__.py new file mode 100644 index 0000000..932b488 --- /dev/null +++ b/sopel_modules/SpiceBot_IRC_Logs/__init__.py @@ -0,0 +1,8 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function + +from .IRC_Events import * + +__author__ = 'Sam Zick' +__email__ = 'sam@deathbybandaid.net' +__version__ = '0.1.1' diff --git a/sopel_modules/SpiceBot_Logs/__init__.py b/sopel_modules/SpiceBot_Logs/__init__.py index eace833..ce9f911 100644 --- a/sopel_modules/SpiceBot_Logs/__init__.py +++ b/sopel_modules/SpiceBot_Logs/__init__.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals, absolute_import, division, print_functi from .Queue import * from .Logs_Command import * -from .IRC_Events import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' From 912e8a1b75143bfdea83061eb561da11c26e8ea3 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 14:57:55 -0400 Subject: [PATCH 022/328] not sure what happened to this file --- sopel_modules/SpiceBot_IRC_Logs/IRC_Events.py | 360 +++++++++--------- 1 file changed, 180 insertions(+), 180 deletions(-) diff --git a/sopel_modules/SpiceBot_IRC_Logs/IRC_Events.py b/sopel_modules/SpiceBot_IRC_Logs/IRC_Events.py index 2d1236b..2eb4f73 100644 --- a/sopel_modules/SpiceBot_IRC_Logs/IRC_Events.py +++ b/sopel_modules/SpiceBot_IRC_Logs/IRC_Events.py @@ -9,13 +9,13 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.event('NICK') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_NICK(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.module.event('QUIT') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_QUIT(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @@ -26,1241 +26,1241 @@ def parse_event_PART(bot, trigger): @sopel.module.event('MODE') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_MODE(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.module.event('KICK') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_KICK(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.module.event('JOIN') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_JOIN(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.module.event('INVITE') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_INVITE(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) @sopel.module.event('TOPIC') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_TOPIC(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WELCOME = '001' @sopel.module.event('001') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_001(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_YOURHOST = '002' @sopel.module.event('002') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_002(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_CREATED = '003' @sopel.module.event('003') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_003(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MYINFO = '004' @sopel.module.event('004') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_004(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_BOUNCE = '005' @sopel.module.event('005') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_005(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ISUPPORT = '005' @sopel.module.event('005') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_005b(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACELINK = '200' @sopel.module.event('200') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_200(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACECONNECTING = '201' @sopel.module.event('201') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_201(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEHANDSHAKE = '202' @sopel.module.event('202') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_202(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEUNKNOWN = '203' @sopel.module.event('203') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_203(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEOPERATOR = '204' @sopel.module.event('204') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_204(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEUSER = '205' @sopel.module.event('205') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_205(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACESERVER = '206' @sopel.module.event('206') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_206(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACESERVICE = '207' @sopel.module.event('207') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_207(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACENEWTYPE = '208' @sopel.module.event('208') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_208(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACECLASS = '209' @sopel.module.event('209') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_209(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACERECONNECT = '210' @sopel.module.event('210') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_210(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSLINKINFO = '211' @sopel.module.event('211') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_211(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSCOMMANDS = '212' @sopel.module.event('212') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_212(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSCLINE = '213' @sopel.module.event('213') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_213(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSNLINE = '214' @sopel.module.event('214') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_214(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSILINE = '215' @sopel.module.event('215') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_215(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSKLINE = '216' @sopel.module.event('216') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_216(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSYLINE = '218' @sopel.module.event('218') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_218(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFSTATS = '219' @sopel.module.event('219') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_219(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_UMODEIS = '221' @sopel.module.event('221') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_221(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SERVLIST = '234' @sopel.module.event('234') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_234(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SERVLISTEND = '235' @sopel.module.event('235') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_235(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSLLINE = '241' @sopel.module.event('241') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_241(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSUPTIME = '242' @sopel.module.event('242') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_242(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSOLINE = '243' @sopel.module.event('243') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_243(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STATSHLINE = '244' @sopel.module.event('244') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_244(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERCLIENT = '251' @sopel.module.event('251') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_251(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSEROP = '252' @sopel.module.event('252') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_252(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERUNKNOWN = '253' @sopel.module.event('253') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_253(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERCHANNELS = '254' @sopel.module.event('254') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_254(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LUSERME = '255' @sopel.module.event('255') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_255(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINME = '256' @sopel.module.event('256') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_256(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINLOC1 = '257' @sopel.module.event('257') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_257(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINLOC2 = '258' @sopel.module.event('258') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_258(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ADMINEMAIL = '259' @sopel.module.event('259') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_259(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACELOG = '261' @sopel.module.event('261') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_261(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRACEEND = '262' @sopel.module.event('262') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_262(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TRYAGAIN = '263' @sopel.module.event('263') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_263(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NONE = '300' @sopel.module.event('300') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_300(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_AWAY = '301' @sopel.module.event('301') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_301(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_USERHOST = '302' @sopel.module.event('302') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_302(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ISON = '303' @sopel.module.event('303') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_303(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_UNAWAY = '305' @sopel.module.event('305') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_305(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NOWAWAY = '306' @sopel.module.event('306') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_306(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISUSER = '311' @sopel.module.event('311') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_311(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISSERVER = '312' @sopel.module.event('312') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_312(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISOPERATOR = '313' @sopel.module.event('313') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_313(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOWASUSER = '314' @sopel.module.event('314') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_314(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFWHO = '315' @sopel.module.event('315') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_315(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISIDLE = '317' @sopel.module.event('317') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_317(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFWHOIS = '318' @sopel.module.event('318') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_318(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISCHANNELS = '319' @sopel.module.event('319') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_319(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LISTSTART = '321' @sopel.module.event('321') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_321(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LIST = '322' @sopel.module.event('322') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_322(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LISTEND = '323' @sopel.module.event('323') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_323(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_CHANNELMODEIS = '324' @sopel.module.event('324') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_324(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_UNIQOPIS = '325' @sopel.module.event('325') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_325(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NOTOPIC = '331' @sopel.module.event('331') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_331(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TOPIC = '332' @sopel.module.event('332') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_332(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_INVITING = '341' @sopel.module.event('341') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_341(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SUMMONING = '342' @sopel.module.event('342') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_342(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_INVITELIST = '346' @sopel.module.event('346') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_346(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFINVITELIST = '347' @sopel.module.event('347') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_347(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_EXCEPTLIST = '348' @sopel.module.event('348') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_348(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFEXCEPTLIST = '349' @sopel.module.event('349') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_349(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_VERSION = '351' @sopel.module.event('351') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_351(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOREPLY = '352' @sopel.module.event('352') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_352(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NAMREPLY = '353' @sopel.module.event('353') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_353(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOSPCRPL = '354' @sopel.module.event('354') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_354(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LINKS = '364' @sopel.module.event('364') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_364(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFLINKS = '365' @sopel.module.event('365') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_365(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFNAMES = '366' @sopel.module.event('366') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_366(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_BANLIST = '367' @sopel.module.event('367') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_367(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFBANLIST = '368' @sopel.module.event('368') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_368(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFWHOWAS = '369' @sopel.module.event('369') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_369(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_INFO = '371' @sopel.module.event('371') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_371(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MOTD = '372' @sopel.module.event('372') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_372(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFINFO = '374' @sopel.module.event('374') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_374(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MOTDSTART = '375' @sopel.module.event('375') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_375(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFMOTD = '376' @sopel.module.event('376') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_376(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_YOUREOPER = '381' @sopel.module.event('381') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_381(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_REHASHING = '382' @sopel.module.event('382') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_382(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_YOURESERVICE = '383' @sopel.module.event('383') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_383(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_TIME = '391' @sopel.module.event('391') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_391(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_USERSSTART = '392' @sopel.module.event('392') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_392(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_USERS = '393' @sopel.module.event('393') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_393(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFUSERS = '394' @sopel.module.event('394') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_394(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_NOUSERS = '395' @sopel.module.event('395') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_395(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHNICK = '401' @sopel.module.event('401') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_401(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHSERVER = '402' @sopel.module.event('402') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_402(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHCHANNEL = '403' @sopel.module.event('403') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_403(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CANNOTSENDTOCHAN = '404' @sopel.module.event('404') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_404(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_TOOMANYCHANNELS = '405' @sopel.module.event('405') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_405(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_WASNOSUCHNICK = '406' @sopel.module.event('406') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_406(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_TOOMANYTARGETS = '407' @sopel.module.event('407') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_407(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOSUCHSERVICE = '408' @sopel.module.event('408') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_408(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOORIGIN = '409' @sopel.module.event('409') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_409(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_INVALIDCAPCMD = '410' @sopel.module.event('410') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_410(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NORECIPIENT = '411' @sopel.module.event('411') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_411(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTEXTTOSEND = '412' @sopel.module.event('412') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_412(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTOPLEVEL = '413' @sopel.module.event('413') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_413(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_WILDTOPLEVEL = '414' @sopel.module.event('414') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_414(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BADMASK = '415' @sopel.module.event('415') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_415(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNKNOWNCOMMAND = '421' @sopel.module.event('421') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_421(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOMOTD = '422' @sopel.module.event('422') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_422(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOADMININFO = '423' @sopel.module.event('423') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_423(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_FILEERROR = '424' @sopel.module.event('424') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_424(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NONICKNAMEGIVEN = '431' @sopel.module.event('431') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_431(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_ERRONEUSNICKNAME = '432' @sopel.module.event('432') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_432(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NICKNAMEINUSE = '433' @sopel.module.event('433') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_433(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NICKCOLLISION = '436' @sopel.module.event('436') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_436(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNAVAILRESOURCE = '437' @sopel.module.event('437') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_437(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERNOTINCHANNEL = '441' @sopel.module.event('441') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_441(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTONCHANNEL = '442' @sopel.module.event('442') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_442(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERONCHANNEL = '443' @sopel.module.event('443') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_443(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOLOGIN = '444' @sopel.module.event('444') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_444(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SUMMONDISABLED = '445' @sopel.module.event('445') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_445(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERSDISABLED = '446' @sopel.module.event('446') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_446(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOTREGISTERED = '451' @sopel.module.event('451') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_451(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NEEDMOREPARAMS = '461' @sopel.module.event('461') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_461(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_ALREADYREGISTRED = '462' @sopel.module.event('462') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_462(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOPERMFORHOST = '463' @sopel.module.event('463') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_463(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_PASSWDMISMATCH = '464' @sopel.module.event('464') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_464(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_YOUREBANNEDCREEP = '465' @sopel.module.event('465') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_465(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_YOUWILLBEBANNED = '466' @sopel.module.event('466') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_466(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYSET = '467' @sopel.module.event('467') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_467(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CHANNELISFULL = '471' @sopel.module.event('471') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_471(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNKNOWNMODE = '472' @sopel.module.event('472') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_472(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_INVITEONLYCHAN = '473' @sopel.module.event('473') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_473(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BANNEDFROMCHAN = '474' @sopel.module.event('474') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_474(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BADCHANNELKEY = '475' @sopel.module.event('475') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_475(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BADCHANMASK = '476' @sopel.module.event('476') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_476(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOCHANMODES = '477' @sopel.module.event('477') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_477(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_BANLISTFULL = '478' @sopel.module.event('478') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_478(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOPRIVILEGES = '481' @sopel.module.event('481') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_481(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CHANOPRIVSNEEDED = '482' @sopel.module.event('482') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_482(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_CANTKILLSERVER = '483' @sopel.module.event('483') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_483(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_RESTRICTED = '484' @sopel.module.event('484') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_484(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UNIQOPPRIVSNEEDED = '485' @sopel.module.event('485') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_485(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOOPERHOST = '491' @sopel.module.event('491') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_491(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_UMODEUNKNOWNFLAG = '501' @sopel.module.event('501') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_501(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_USERSDONTMATCH = '502' @sopel.module.event('502') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_502(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_STARTTLS = '670' @sopel.module.event('670') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_670(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_STARTTLS = '691' @sopel.module.event('691') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_691(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MONONLINE = '730' @sopel.module.event('730') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_730(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MONOFFLINE = '731' @sopel.module.event('731') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_731(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_MONLIST = '732' @sopel.module.event('732') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_732(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_ENDOFMONLIST = '733' @sopel.module.event('733') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_733(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_MONLISTFULL = '734' @sopel.module.event('734') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_734(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_WHOISKEYVALUE = '760' @sopel.module.event('760') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_760(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_KEYVALUE = '761' @sopel.module.event('761') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_761(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_METADATAEND = '762' @sopel.module.event('762') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_762(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_METADATALIMIT = '764' @sopel.module.event('764') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_764(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_TARGETINVALID = '765' @sopel.module.event('765') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_765(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NOMATCHINGKEY = '766' @sopel.module.event('766') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_766(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYINVALID = '767' @sopel.module.event('767') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_767(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYNOTSET = '768' @sopel.module.event('768') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_768(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_KEYNOPERMISSION = '769' @sopel.module.event('769') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_769(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LOGGEDIN = '900' @sopel.module.event('900') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_900(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_LOGGEDOUT = '901' @sopel.module.event('901') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_901(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_NICKLOCKED = '902' @sopel.module.event('902') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_902(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SASLSUCCESS = '903' @sopel.module.event('903') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_903(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLFAIL = '904' @sopel.module.event('904') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_904(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLTOOLONG = '905' @sopel.module.event('905') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_905(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLABORTED = '906' @sopel.module.event('906') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_906(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # ERR_SASLALREADY = '907' @sopel.module.event('907') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_907(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) # RPL_SASLMECHS = '908' @sopel.module.event('908') -@sopel.modulerule('.*') +@sopel.module.rule('.*') def parse_event_908(bot, trigger): SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) From 820d0ef3a3148d0bb7675efbf3e7da83e8975ed2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 22 May 2019 19:58:35 -0400 Subject: [PATCH 023/328] Database type --- .../SpiceBot_Database_Command/DatabaseCommand.py | 11 +++++++++++ sopel_modules/SpiceBot_Database_Command/__init__.py | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py create mode 100644 sopel_modules/SpiceBot_Database_Command/__init__.py diff --git a/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py b/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py new file mode 100644 index 0000000..10b314a --- /dev/null +++ b/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +# coding=utf-8 +from __future__ import unicode_literals, absolute_import, print_function, division + +# sopel imports +import sopel.module + + +@sopel.module.nickname_commands('database') +def bot_command_gender(bot, trigger): + bot.osd("Database is " + bot.config.core.db_type) diff --git a/sopel_modules/SpiceBot_Database_Command/__init__.py b/sopel_modules/SpiceBot_Database_Command/__init__.py new file mode 100644 index 0000000..5e8ee90 --- /dev/null +++ b/sopel_modules/SpiceBot_Database_Command/__init__.py @@ -0,0 +1,6 @@ +# coding=utf-8 +"""Command for database information +""" +from __future__ import unicode_literals, absolute_import, print_function, division + +from .DatabaseCommand import * From 0f62718ae0cfb51588fce71551edc4fa33a62ebb Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 08:52:16 -0400 Subject: [PATCH 024/328] test new prerun class --- sopel_modules/SpiceBot/Prerun.py | 31 ++++++++++++++++++++++++++++++ sopel_modules/SpiceBot/__init__.py | 1 + 2 files changed, 32 insertions(+) create mode 100644 sopel_modules/SpiceBot/Prerun.py diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py new file mode 100644 index 0000000..710419d --- /dev/null +++ b/sopel_modules/SpiceBot/Prerun.py @@ -0,0 +1,31 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot Prerun system. +""" + +import functools +import spicemanip + + +class BotPrerun(): + def __init__(self): + self.dict = {} + + def args(level, message=None, reply=False): + def actual_decorator(function): + @functools.wraps(function) + def argsbuilder(bot, trigger, *args, **kwargs): + triggerargs = spicemanip.main(trigger.args[1], 'create') + if triggerargs[0].lower() == bot.nick.lower(): + trigger.command = spicemanip.main(triggerargs, 2).lower() + trigger.arglist = spicemanip.main(triggerargs, '3+', 'list') + else: + trigger.command = spicemanip.main(triggerargs, 1).lower()[1:] + trigger.arglist = spicemanip.main(triggerargs, '2+', 'list') + return function(bot, trigger, *args, **kwargs) + return argsbuilder + return actual_decorator + + +prerun = BotPrerun() diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index 2606e87..f2496fc 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -12,6 +12,7 @@ from .Commands import * from .Events import * from .Channels import * from .Database import * +from .Prerun import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' From a0b81518d8c5cf7f4edbe4f0a1c80e9cfe69ec9b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 09:12:15 -0400 Subject: [PATCH 025/328] really test this time --- sopel_modules/SpiceBot/Prerun.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 710419d..311a899 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -12,20 +12,24 @@ class BotPrerun(): def __init__(self): self.dict = {} - def args(level, message=None, reply=False): + def args(self, command_type='module_command'): def actual_decorator(function): @functools.wraps(function) def argsbuilder(bot, trigger, *args, **kwargs): - triggerargs = spicemanip.main(trigger.args[1], 'create') - if triggerargs[0].lower() == bot.nick.lower(): - trigger.command = spicemanip.main(triggerargs, 2).lower() - trigger.arglist = spicemanip.main(triggerargs, '3+', 'list') - else: - trigger.command = spicemanip.main(triggerargs, 1).lower()[1:] - trigger.arglist = spicemanip.main(triggerargs, '2+', 'list') + trigger.argcommand, trigger.arglist = self.sopel_triggerargs(bot, 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') + else: + command = spicemanip.main(triggerargs, 1).lower()[1:] + triggerargs = spicemanip.main(triggerargs, '2+', 'list') + return triggerargs, command + prerun = BotPrerun() From a56f9b3ab972adf9a11bcecfc92102ec23fbc4ba Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 09:20:09 -0400 Subject: [PATCH 026/328] another test --- sopel_modules/SpiceBot/Prerun.py | 4 ++-- sopel_modules/SpiceBot/Tools.py | 2 +- sopel_modules/SpiceBot_AI/AI.py | 2 +- sopel_modules/SpiceBot_BotPrivs/BotPrivs.py | 2 +- sopel_modules/SpiceBot_Channels_Command/Channels_Command.py | 2 +- sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py | 2 +- sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py | 2 +- sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py | 2 +- sopel_modules/SpiceBot_GifSearch/Gif_Command.py | 2 +- sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands | 2 +- sopel_modules/SpiceBot_Logs/Logs_Command.py | 2 +- sopel_modules/SpiceBot_Messaging/Messaging.py | 2 +- sopel_modules/SpiceBot_Update/Update.py | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 311a899..bbb6f3f 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -16,7 +16,7 @@ class BotPrerun(): def actual_decorator(function): @functools.wraps(function) def argsbuilder(bot, trigger, *args, **kwargs): - trigger.argcommand, trigger.arglist = self.sopel_triggerargs(bot, trigger, command_type) + trigger.argcommand, trigger.arglist, trigger.command_type = self.sopel_triggerargs(bot, trigger, command_type) return function(bot, trigger, *args, **kwargs) return argsbuilder return actual_decorator @@ -29,7 +29,7 @@ class BotPrerun(): else: command = spicemanip.main(triggerargs, 1).lower()[1:] triggerargs = spicemanip.main(triggerargs, '2+', 'list') - return triggerargs, command + return triggerargs, command, command_type prerun = BotPrerun() diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index c25823b..5286667 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -52,7 +52,7 @@ def sopel_triggerargs(bot, trigger, command_type='module_command'): command = spicemanip.main(triggerargs, 1).lower()[1:] triggerargs = spicemanip.main(triggerargs, '2+', 'list') - return triggerargs, command + return triggerargs, command, command_type def bot_privs(bot, privtype): diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index 3d2a6ae..7c1b616 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -13,7 +13,7 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.nickname_commands('(.*)') def bot_command_nick(bot, trigger): - triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') + triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') if not triggercommand: return diff --git a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py index 95cf09f..c29a5ba 100644 --- a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py +++ b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py @@ -20,7 +20,7 @@ def bot_command_admins(bot, trigger): def bot_command_process(bot, trigger): - triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') + triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') if triggercommand == 'owner': triggercommand = 'owners' diff --git a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py index eafdda9..e4266b2 100644 --- a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py +++ b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py @@ -13,7 +13,7 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.nickname_commands('channels', 'channel') def nickname_comand_channels(bot, trigger): - triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') + triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') if not len(triggerargs): commandused = 'list' diff --git a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py index 6e3df6c..5318bcd 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py @@ -14,7 +14,7 @@ import spicemanip @sopel.module.nickname_commands('(.*)') def query_detection_nick(bot, trigger): - triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') + triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') # command issued, check if valid if not triggercommand or not len(triggercommand): diff --git a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py index d4629d3..08a46aa 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py @@ -14,7 +14,7 @@ import spicemanip @sopel.module.rule('^\?(.*)') def query_detection(bot, trigger): - triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'query_command') + triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'query_command') # command issued, check if valid if not triggercommand or not len(triggercommand): diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py b/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py index dc119cd..ae8f3d1 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py +++ b/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py @@ -15,7 +15,7 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.commands('(.*)') def gifapi_triggers(bot, trigger): - triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'prefix_command') + triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'prefix_command') if triggercommand not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): return diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_Command.py b/sopel_modules/SpiceBot_GifSearch/Gif_Command.py index 518f95d..10d6c3e 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_Command.py +++ b/sopel_modules/SpiceBot_GifSearch/Gif_Command.py @@ -15,7 +15,7 @@ import spicemanip @module.commands('gif') def gif_trigger(bot, trigger): - triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger) + triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger) if not len(triggerargs): return bot.osd("Please present a query to search.") diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands b/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands index dc119cd..ae8f3d1 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands +++ b/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands @@ -15,7 +15,7 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.commands('(.*)') def gifapi_triggers(bot, trigger): - triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'prefix_command') + triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'prefix_command') if triggercommand not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): return diff --git a/sopel_modules/SpiceBot_Logs/Logs_Command.py b/sopel_modules/SpiceBot_Logs/Logs_Command.py index 46f3322..fd2afc2 100644 --- a/sopel_modules/SpiceBot_Logs/Logs_Command.py +++ b/sopel_modules/SpiceBot_Logs/Logs_Command.py @@ -16,7 +16,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 = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') + triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') logtype = spicemanip.main(triggerargs, 1) or None if not logtype: diff --git a/sopel_modules/SpiceBot_Messaging/Messaging.py b/sopel_modules/SpiceBot_Messaging/Messaging.py index 66e81f5..0001948 100644 --- a/sopel_modules/SpiceBot_Messaging/Messaging.py +++ b/sopel_modules/SpiceBot_Messaging/Messaging.py @@ -30,7 +30,7 @@ def bot_command_process(bot, trigger): bot.say("I was unable to process this Bot Nick command due to privilege issues.") return - triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') + triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') if triggercommand in ['say', 'msg']: triggercommand = 'privmsg' diff --git a/sopel_modules/SpiceBot_Update/Update.py b/sopel_modules/SpiceBot_Update/Update.py index d0a4efc..511602d 100644 --- a/sopel_modules/SpiceBot_Update/Update.py +++ b/sopel_modules/SpiceBot_Update/Update.py @@ -34,7 +34,7 @@ def nickname_comand_update(bot, trigger): bot.say("I was unable to process this Bot Nick command due to privilege issues.") return - triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') + triggerargs, triggercommand, command_type = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command') if not len(triggerargs): commandused = 'nodeps' From d5c35103bdccf817a1d9a9eea4bdfcdf074246c2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 09:28:20 -0400 Subject: [PATCH 027/328] dict version --- sopel_modules/SpiceBot/Prerun.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index bbb6f3f..5dbd85f 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -16,7 +16,7 @@ class BotPrerun(): def actual_decorator(function): @functools.wraps(function) def argsbuilder(bot, trigger, *args, **kwargs): - trigger.argcommand, trigger.arglist, trigger.command_type = self.sopel_triggerargs(bot, trigger, command_type) + trigger.sb = self.sopel_triggerargs(bot, trigger, command_type) return function(bot, trigger, *args, **kwargs) return argsbuilder return actual_decorator @@ -29,7 +29,8 @@ class BotPrerun(): else: command = spicemanip.main(triggerargs, 1).lower()[1:] triggerargs = spicemanip.main(triggerargs, '2+', 'list') - return triggerargs, command, command_type + argsdict = {"com": command, "args": triggerargs, "type": command_type} + return argsdict prerun = BotPrerun() From 2d8992c9937ecaf9705605e03b0c432e3f3086f4 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 09:44:29 -0400 Subject: [PATCH 028/328] integrate args system into modules --- sopel_modules/SpiceBot/Prerun.py | 20 ++++---- sopel_modules/SpiceBot/Tools.py | 17 ------- sopel_modules/SpiceBot_AI/AI.py | 25 +++++---- sopel_modules/SpiceBot_BotPrivs/BotPrivs.py | 11 ++-- .../Channels_Command.py | 19 ++++--- .../NickQueryCommand.py | 51 +++++++++---------- .../SpiceBot_CommandsQuery/QueryCommand.py | 47 +++++++++-------- .../SpiceBot_GifSearch/Gif_API_Commands.py | 11 ++-- .../SpiceBot_GifSearch/Gif_Command.py | 6 +-- .../SpiceBot_GifSearch/Gif_Search_Commands | 11 ++-- sopel_modules/SpiceBot_Logs/Logs_Command.py | 5 +- sopel_modules/SpiceBot_Messaging/Messaging.py | 19 +++---- sopel_modules/SpiceBot_Update/Update.py | 9 ++-- 13 files changed, 114 insertions(+), 137 deletions(-) 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) From cfa6f07e7d79a03a9e365d8f755b2d082c180a69 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 10:22:25 -0400 Subject: [PATCH 029/328] attempt && usage --- sopel_modules/SpiceBot/Prerun.py | 33 ++++++++++++++----- sopel_modules/SpiceBot_AI/AI.py | 2 +- sopel_modules/SpiceBot_BotPrivs/BotPrivs.py | 4 +-- .../Channels_Command.py | 2 +- .../NickQueryCommand.py | 2 +- .../SpiceBot_CommandsQuery/QueryCommand.py | 2 +- .../SpiceBot_GifSearch/Gif_API_Commands.py | 2 +- .../SpiceBot_GifSearch/Gif_Command.py | 2 +- .../SpiceBot_GifSearch/Gif_Search_Commands | 2 +- sopel_modules/SpiceBot_Logs/Logs_Command.py | 2 +- sopel_modules/SpiceBot_Messaging/Messaging.py | 6 ++-- sopel_modules/SpiceBot_Update/Update.py | 2 +- 12 files changed, 38 insertions(+), 23 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 794cbdc..3c2c23f 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -12,25 +12,40 @@ class BotPrerun(): def __init__(self): self.dict = {} - def args(self, trigger_command_type='module_command'): + def prerun(self, trigger_command_type='module_command'): def actual_decorator(function): @functools.wraps(function) - def argsbuilder(bot, trigger, *args, **kwargs): - trigger.sb = self.sopel_trigger_args(bot, trigger, trigger_command_type) - return function(bot, trigger, *args, **kwargs) - return argsbuilder + def internal_prerun(bot, trigger, *args, **kwargs): + prerun_split = self.sopel_trigger_args(bot, trigger, trigger_command_type) + for prerun in prerun_split: + trigger.sb = prerun + function(bot, trigger, *args, **kwargs) + return + return internal_prerun return actual_decorator 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') + trigger_args = spicemanip.main(trigger_args, '2+', 'list') else: 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 + trigger_args = spicemanip.main(trigger_args, '1+', 'list') + + # Handle && splittings + trigger_args_list_split = spicemanip.main(trigger_args, "split_&&") + if not len(trigger_args_list_split): + trigger_args_list_split.append([]) + + prerun_split = [] + for trigger_args_list in trigger_args_list_split: + trigger_args_part = spicemanip.main(trigger_args, 'create') + argsdict = {"com": trigger_command, "args": trigger_args_part, "type": trigger_command_type} + prerun_split.append(argsdict) + + return prerun_split prerun = BotPrerun() diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index 1f4f6e9..2712b84 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -10,7 +10,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDSQUERY]) -@SpiceBot.prerun.args('nickname_command') +@SpiceBot.prerun.prerun('nickname_command') @sopel.module.nickname_commands('(.*)') def bot_command_nick(bot, trigger): diff --git a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py index cf462b1..cd9ed10 100644 --- a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py +++ b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py @@ -9,13 +9,13 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot -@SpiceBot.prerun.args('nickname_command') +@SpiceBot.prerun.prerun('nickname_command') @sopel.module.nickname_commands('owners', 'owner') def bot_command_owners(bot, trigger): bot_command_process(bot, trigger) -@SpiceBot.prerun.args('nickname_command') +@SpiceBot.prerun.prerun('nickname_command') @sopel.module.nickname_commands('admins') def bot_command_admins(bot, trigger): bot_command_process(bot, trigger) diff --git a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py index 039113a..7aab13f 100644 --- a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py +++ b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py @@ -10,7 +10,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) -@SpiceBot.prerun.args('nickname_command') +@SpiceBot.prerun.prerun('nickname_command') @sopel.module.nickname_commands('channels', 'channel') def nickname_comand_channels(bot, trigger): diff --git a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py index f6c485e..786dff8 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py @@ -11,7 +11,7 @@ import spicemanip @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY]) -@SpiceBot.prerun.args('nickname_command') +@SpiceBot.prerun.prerun('nickname_command') @sopel.module.nickname_commands('(.*)') def query_detection_nick(bot, trigger): diff --git a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py index 10bf80f..5754413 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py @@ -11,7 +11,7 @@ import spicemanip @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY]) -@SpiceBot.prerun.args('query_command') +@SpiceBot.prerun.prerun('query_command') @sopel.module.rule('^\?(.*)') def query_detection(bot, trigger): diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py b/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py index 941d4fe..c19438f 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py +++ b/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py @@ -12,7 +12,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH]) -@SpiceBot.prerun.args('prefix_command') +@SpiceBot.prerun.prerun('prefix_command') @sopel.module.commands('(.*)') def gifapi_triggers(bot, trigger): diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_Command.py b/sopel_modules/SpiceBot_GifSearch/Gif_Command.py index bf306c4..3ee6481 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_Command.py +++ b/sopel_modules/SpiceBot_GifSearch/Gif_Command.py @@ -12,7 +12,7 @@ import spicemanip @SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH]) -@SpiceBot.prerun.args('prefix_command') +@SpiceBot.prerun.prerun('prefix_command') @module.commands('gif') def gif_trigger(bot, trigger): diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands b/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands index 941d4fe..c19438f 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands +++ b/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands @@ -12,7 +12,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH]) -@SpiceBot.prerun.args('prefix_command') +@SpiceBot.prerun.prerun('prefix_command') @sopel.module.commands('(.*)') def gifapi_triggers(bot, trigger): diff --git a/sopel_modules/SpiceBot_Logs/Logs_Command.py b/sopel_modules/SpiceBot_Logs/Logs_Command.py index bdb17e6..581860f 100644 --- a/sopel_modules/SpiceBot_Logs/Logs_Command.py +++ b/sopel_modules/SpiceBot_Logs/Logs_Command.py @@ -9,7 +9,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_LOGS]) -@SpiceBot.prerun.args('nickname_command') +@SpiceBot.prerun.prerun('nickname_command') @sopel.module.nickname_commands('logs', 'debug') def bot_command_logs(bot, trigger): diff --git a/sopel_modules/SpiceBot_Messaging/Messaging.py b/sopel_modules/SpiceBot_Messaging/Messaging.py index e0ce5e1..1d5200d 100644 --- a/sopel_modules/SpiceBot_Messaging/Messaging.py +++ b/sopel_modules/SpiceBot_Messaging/Messaging.py @@ -9,19 +9,19 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot -@SpiceBot.prerun.args('nickname_command') +@SpiceBot.prerun.prerun('nickname_command') @sopel.module.nickname_commands('action') def bot_command_action(bot, trigger): bot_command_process(bot, trigger) -@SpiceBot.prerun.args('nickname_command') +@SpiceBot.prerun.prerun('nickname_command') @sopel.module.nickname_commands('notice') def bot_command_notice(bot, trigger): bot_command_process(bot, trigger) -@SpiceBot.prerun.args('nickname_command') +@SpiceBot.prerun.prerun('nickname_command') @sopel.module.nickname_commands('privmsg', 'say', 'msg') def bot_command_privmsg(bot, trigger): bot_command_process(bot, trigger) diff --git a/sopel_modules/SpiceBot_Update/Update.py b/sopel_modules/SpiceBot_Update/Update.py index d56ba0d..72cbdfe 100644 --- a/sopel_modules/SpiceBot_Update/Update.py +++ b/sopel_modules/SpiceBot_Update/Update.py @@ -27,7 +27,7 @@ def setup(bot): bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) -@SpiceBot.prerun.args('nickname_command') +@SpiceBot.prerun.prerun('nickname_command') @sopel.module.nickname_commands('update') def nickname_comand_update(bot, trigger): From fe9793a289028d103099eb38072b97d350a85d68 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 10:31:38 -0400 Subject: [PATCH 030/328] split better --- sopel_modules/SpiceBot/Prerun.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 3c2c23f..9389bc6 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -17,8 +17,8 @@ class BotPrerun(): @functools.wraps(function) def internal_prerun(bot, trigger, *args, **kwargs): prerun_split = self.sopel_trigger_args(bot, trigger, trigger_command_type) - for prerun in prerun_split: - trigger.sb = prerun + for argsdict in prerun_split: + trigger.sb = argsdict function(bot, trigger, *args, **kwargs) return return internal_prerun @@ -41,7 +41,7 @@ class BotPrerun(): prerun_split = [] for trigger_args_list in trigger_args_list_split: - trigger_args_part = spicemanip.main(trigger_args, 'create') + trigger_args_part = spicemanip.main(trigger_args_list, 'create') argsdict = {"com": trigger_command, "args": trigger_args_part, "type": trigger_command_type} prerun_split.append(argsdict) From 3c86e3ae25331645547d5a9d75d3d9804487d7ce Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 10:35:27 -0400 Subject: [PATCH 031/328] better handling for split --- sopel_modules/SpiceBot/Prerun.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 9389bc6..72c87dc 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -29,10 +29,10 @@ class BotPrerun(): 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, '2+', 'list') + trigger_args = spicemanip.main(trigger_args, '3+', 'list') else: trigger_command = spicemanip.main(trigger_args, 1).lower()[1:] - trigger_args = spicemanip.main(trigger_args, '1+', 'list') + trigger_args = spicemanip.main(trigger_args, '2+', 'list') # Handle && splittings trigger_args_list_split = spicemanip.main(trigger_args, "split_&&") From 954928f528d19df0bd569ed5e49aefe476701ff5 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 10:39:53 -0400 Subject: [PATCH 032/328] remove sopel name --- sopel_modules/SpiceBot/Prerun.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 72c87dc..a1b6aa9 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -16,7 +16,7 @@ class BotPrerun(): def actual_decorator(function): @functools.wraps(function) def internal_prerun(bot, trigger, *args, **kwargs): - prerun_split = self.sopel_trigger_args(bot, trigger, trigger_command_type) + prerun_split = self.trigger_args(bot, trigger, trigger_command_type) for argsdict in prerun_split: trigger.sb = argsdict function(bot, trigger, *args, **kwargs) @@ -24,7 +24,7 @@ class BotPrerun(): return internal_prerun return actual_decorator - def sopel_trigger_args(self, bot, trigger, trigger_command_type='module_command'): + def 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']: From 8fc5862bb5c4b71797b80958376cb266dcf50c1a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 11:08:13 -0400 Subject: [PATCH 033/328] test functionality split --- sopel_modules/SpiceBot/Prerun.py | 36 ++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index a1b6aa9..2d928a5 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -5,6 +5,7 @@ This is the SpiceBot Prerun system. """ import functools +import copy import spicemanip @@ -16,35 +17,52 @@ class BotPrerun(): def actual_decorator(function): @functools.wraps(function) def internal_prerun(bot, trigger, *args, **kwargs): - prerun_split = self.trigger_args(bot, trigger, trigger_command_type) - for argsdict in prerun_split: + + argsdict_default = {} + argsdict_default["type"] = trigger_command_type + + # Primary command used for trigger, and a list of all words + trigger_args, trigger_command = self.trigger_args(trigger.args[1], trigger_command_type) + argsdict_default["com"] = trigger_command + + # split into && groupings + and_split = self.and_split(trigger_args) + + # Create dict listings for trigger.sb + argsdict_list = self.argsdict_create(argsdict_default, and_split) + + # Run the function for all splits + for argsdict in argsdict_list: trigger.sb = argsdict function(bot, trigger, *args, **kwargs) + return return internal_prerun return actual_decorator - def trigger_args(self, bot, trigger, trigger_command_type='module_command'): - - trigger_args = spicemanip.main(trigger.args[1], 'create') + def trigger_args(self, triggerargs_one, trigger_command_type='module_command'): + trigger_args = spicemanip.main(triggerargs_one, '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: trigger_command = spicemanip.main(trigger_args, 1).lower()[1:] trigger_args = spicemanip.main(trigger_args, '2+', 'list') + return trigger_args, trigger_command - # Handle && splittings + def and_split(self, trigger_args): trigger_args_list_split = spicemanip.main(trigger_args, "split_&&") if not len(trigger_args_list_split): trigger_args_list_split.append([]) + return trigger_args_list_split + def argsdict_list(self, argsdict_default, prerun_and_split): prerun_split = [] - for trigger_args_list in trigger_args_list_split: + for trigger_args_list in prerun_and_split: + argsdict = copy.deepcopy(argsdict_default) trigger_args_part = spicemanip.main(trigger_args_list, 'create') - argsdict = {"com": trigger_command, "args": trigger_args_part, "type": trigger_command_type} + argsdict["args"] = trigger_args_part prerun_split.append(argsdict) - return prerun_split From 7b6dc3c1875d7087a3de6c1820342cedfc869c4e Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 11:30:48 -0400 Subject: [PATCH 034/328] error --- sopel_modules/SpiceBot/Prerun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 2d928a5..e2bbecb 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -29,7 +29,7 @@ class BotPrerun(): and_split = self.and_split(trigger_args) # Create dict listings for trigger.sb - argsdict_list = self.argsdict_create(argsdict_default, and_split) + argsdict_list = self.argsdict_list(argsdict_default, and_split) # Run the function for all splits for argsdict in argsdict_list: From 1298c811fbccf5234e1bfd82be5894f0754ee0a9 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 15:38:43 -0400 Subject: [PATCH 035/328] channel disabling prerun --- sopel_modules/SpiceBot/Commands.py | 8 ++ sopel_modules/SpiceBot/Prerun.py | 123 +++++++++++++++++- sopel_modules/SpiceBot_AI/AI.py | 2 +- sopel_modules/SpiceBot_BotPrivs/BotPrivs.py | 4 +- .../Channels_Command.py | 2 +- .../NickQueryCommand.py | 2 +- .../SpiceBot_CommandsQuery/QueryCommand.py | 2 +- .../SpiceBot_GifSearch/Gif_API_Commands.py | 2 +- .../SpiceBot_GifSearch/Gif_Command.py | 2 +- .../SpiceBot_GifSearch/Gif_Search_Commands | 2 +- sopel_modules/SpiceBot_Logs/Logs_Command.py | 2 +- sopel_modules/SpiceBot_Messaging/Messaging.py | 6 +- sopel_modules/SpiceBot_Update/Update.py | 2 +- 13 files changed, 139 insertions(+), 20 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index dbdc57d..cdaf180 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -27,6 +27,14 @@ class BotCommands(): }, } + def find_command_type(self, command): + for commandstype in self.dict['commands'].keys(): + if commandstype not in ['rule']: + for com in self.dict['commands'][commandstype].keys(): + if com.lower() == command.lower(): + return commandstype + return None + def register(self, bot, command_dict): self.lock.acquire() diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index e2bbecb..c8ad134 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -4,27 +4,47 @@ from __future__ import unicode_literals, absolute_import, division, print_functi This is the SpiceBot Prerun system. """ +from sopel.tools import Identifier + import functools import copy +import datetime import spicemanip +from .Tools import command_permissions_check +from .Commands import commands +from .Database import db as spicedb + class BotPrerun(): def __init__(self): self.dict = {} - def prerun(self, trigger_command_type='module_command'): + def prerun(self, trigger_command_type='module'): def actual_decorator(function): @functools.wraps(function) def internal_prerun(bot, trigger, *args, **kwargs): - argsdict_default = {} - argsdict_default["type"] = trigger_command_type + # Bots can't run commands + if Identifier(trigger.nick) == bot.nick: + return # Primary command used for trigger, and a list of all words trigger_args, trigger_command = self.trigger_args(trigger.args[1], trigger_command_type) + + command_lookup = commands.find_command_type(trigger_command) + + # Argsdict Defaults + argsdict_default = {} + argsdict_default["type"] = trigger_command_type argsdict_default["com"] = trigger_command + if command_lookup and "aliasfor" in commands.dict["commands"][command_lookup].keys(): + realcom = commands.dict["commands"][command_lookup]["aliasfor"] + else: + realcom = trigger_command + argsdict_default["realcom"] = realcom + # split into && groupings and_split = self.and_split(trigger_args) @@ -34,15 +54,19 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: trigger.sb = argsdict - function(bot, trigger, *args, **kwargs) + if len(argsdict["hyphen_args"]): + self.hyphen_arg_handler(bot, trigger, argsdict) + + if self.runstatus(bot, trigger, argsdict): + function(bot, trigger, *args, **kwargs) return return internal_prerun return actual_decorator - def trigger_args(self, triggerargs_one, trigger_command_type='module_command'): + def trigger_args(self, triggerargs_one, trigger_command_type='module'): trigger_args = spicemanip.main(triggerargs_one, 'create') - if trigger_command_type in ['nickname', 'nickname_command', 'nickname_commands']: + if trigger_command_type in ['nickname']: trigger_command = spicemanip.main(trigger_args, 2).lower() trigger_args = spicemanip.main(trigger_args, '3+', 'list') else: @@ -61,9 +85,96 @@ class BotPrerun(): for trigger_args_list in prerun_and_split: argsdict = copy.deepcopy(argsdict_default) trigger_args_part = spicemanip.main(trigger_args_list, 'create') + trigger_args_part, hyphen_args = self.hyphen_args(trigger_args_part) + argsdict["hyphen_args"] = hyphen_args argsdict["args"] = trigger_args_part prerun_split.append(argsdict) return prerun_split + def hyphen_args(self, trigger_args_part): + valid_hyphen_args = [ + 'enable', 'disable' + ] + hyphen_args = [] + trigger_args_unhyphend = [] + for worditem in trigger_args_part: + if str(worditem).startswith("--") and worditem[2:] in valid_hyphen_args: + hyphen_args.append(worditem[2:]) + else: + trigger_args_unhyphend.append(worditem) + return trigger_args_unhyphend, hyphen_args + + def hyphen_arg_handler(self, bot, trigger, argsdict): + + hyphenarg = argsdict["hyphen_args"][0] + + # Commands that cannot run via privmsg + if hyphenarg in ['enable']: + + if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + bot.say("I was unable to disable this command due to privilege issues.") + return + + if trigger.is_privmsg: + bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick) + return + + disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} + + if argsdict["realcom"] not in disabled_list.keys(): + bot.notice(argsdict["com"] + " is already enabled in " + str(trigger.sender), trigger.nick) + return + + del disabled_list[argsdict["realcom"]] + spicedb.set_channel_value(bot, trigger.sender, 'disabled_commands', disabled_list, 'commands') + bot.say(argsdict["com"] + " is now enabled in " + str(trigger.sender)) + return + + elif hyphenarg in ['disable']: + + if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + bot.say("I was unable to disable this command due to privilege issues.") + return + + if trigger.is_privmsg: + bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick) + return + + disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} + + if argsdict["realcom"] in disabled_list.keys(): + bot.notice(argsdict["com"] + " is already disabled in " + str(trigger.sender), trigger.nick) + return + + trailingmessage = spicemanip.main(argsdict["args"], 0) or "No reason given." + timestamp = str(datetime.datetime.utcnow()) + + disabled_list[argsdict["realcom"]] = {"reason": trailingmessage, "timestamp": timestamp, "disabledby": trigger.nick} + spicedb.set_channel_value(bot, trigger.sender, 'disabled_commands', disabled_list, 'commands') + + spicedb.adjust_channel_list(bot, trigger.sender, 'disabled_commands', argsdict["realcom"], 'add', 'commands') + bot.say(argsdict["com"] + " is now disabled in " + str(trigger.sender)) + return + + return + + def runstatus(self, bot, trigger, argsdict): + + # Hyphen args can only be used one per && split + if len(argsdict["hyphen_args"]): + return False + + # don't run commands that are disabled in channels + if not trigger.is_privmsg: + disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} + if argsdict["realcom"] in disabled_list.keys(): + reason = disabled_list["disabled_commands"][argsdict["realcom"]]["reason"] + timestamp = disabled_list["disabled_commands"][argsdict["realcom"]]["timestamp"] + bywhom = disabled_list["disabled_commands"][argsdict["realcom"]]["disabledby"] + bot.notice("The " + str(argsdict["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason), trigger.nick) + return False + + return True + prerun = BotPrerun() diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index 2712b84..e43eb53 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -10,7 +10,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDSQUERY]) -@SpiceBot.prerun.prerun('nickname_command') +@SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('(.*)') def bot_command_nick(bot, trigger): diff --git a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py index cd9ed10..9927b9b 100644 --- a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py +++ b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py @@ -9,13 +9,13 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot -@SpiceBot.prerun.prerun('nickname_command') +@SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('owners', 'owner') def bot_command_owners(bot, trigger): bot_command_process(bot, trigger) -@SpiceBot.prerun.prerun('nickname_command') +@SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('admins') def bot_command_admins(bot, trigger): bot_command_process(bot, trigger) diff --git a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py index 7aab13f..fdc70d7 100644 --- a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py +++ b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py @@ -10,7 +10,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) -@SpiceBot.prerun.prerun('nickname_command') +@SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('channels', 'channel') def nickname_comand_channels(bot, trigger): diff --git a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py index 786dff8..15f3498 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py @@ -11,7 +11,7 @@ import spicemanip @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY]) -@SpiceBot.prerun.prerun('nickname_command') +@SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('(.*)') def query_detection_nick(bot, trigger): diff --git a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py index 5754413..f52b37e 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py @@ -11,7 +11,7 @@ import spicemanip @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY]) -@SpiceBot.prerun.prerun('query_command') +@SpiceBot.prerun.prerun('query') @sopel.module.rule('^\?(.*)') def query_detection(bot, trigger): diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py b/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py index c19438f..929b1b9 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py +++ b/sopel_modules/SpiceBot_GifSearch/Gif_API_Commands.py @@ -12,7 +12,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH]) -@SpiceBot.prerun.prerun('prefix_command') +@SpiceBot.prerun.prerun('prefix') @sopel.module.commands('(.*)') def gifapi_triggers(bot, trigger): diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_Command.py b/sopel_modules/SpiceBot_GifSearch/Gif_Command.py index 3ee6481..841f958 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_Command.py +++ b/sopel_modules/SpiceBot_GifSearch/Gif_Command.py @@ -12,7 +12,7 @@ import spicemanip @SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH]) -@SpiceBot.prerun.prerun('prefix_command') +@SpiceBot.prerun.prerun('prefix') @module.commands('gif') def gif_trigger(bot, trigger): diff --git a/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands b/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands index c19438f..929b1b9 100644 --- a/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands +++ b/sopel_modules/SpiceBot_GifSearch/Gif_Search_Commands @@ -12,7 +12,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH]) -@SpiceBot.prerun.prerun('prefix_command') +@SpiceBot.prerun.prerun('prefix') @sopel.module.commands('(.*)') def gifapi_triggers(bot, trigger): diff --git a/sopel_modules/SpiceBot_Logs/Logs_Command.py b/sopel_modules/SpiceBot_Logs/Logs_Command.py index 581860f..0af1032 100644 --- a/sopel_modules/SpiceBot_Logs/Logs_Command.py +++ b/sopel_modules/SpiceBot_Logs/Logs_Command.py @@ -9,7 +9,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_LOGS]) -@SpiceBot.prerun.prerun('nickname_command') +@SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('logs', 'debug') def bot_command_logs(bot, trigger): diff --git a/sopel_modules/SpiceBot_Messaging/Messaging.py b/sopel_modules/SpiceBot_Messaging/Messaging.py index 1d5200d..e2af152 100644 --- a/sopel_modules/SpiceBot_Messaging/Messaging.py +++ b/sopel_modules/SpiceBot_Messaging/Messaging.py @@ -9,19 +9,19 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot -@SpiceBot.prerun.prerun('nickname_command') +@SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('action') def bot_command_action(bot, trigger): bot_command_process(bot, trigger) -@SpiceBot.prerun.prerun('nickname_command') +@SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('notice') def bot_command_notice(bot, trigger): bot_command_process(bot, trigger) -@SpiceBot.prerun.prerun('nickname_command') +@SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('privmsg', 'say', 'msg') def bot_command_privmsg(bot, trigger): bot_command_process(bot, trigger) diff --git a/sopel_modules/SpiceBot_Update/Update.py b/sopel_modules/SpiceBot_Update/Update.py index 72cbdfe..9f69588 100644 --- a/sopel_modules/SpiceBot_Update/Update.py +++ b/sopel_modules/SpiceBot_Update/Update.py @@ -27,7 +27,7 @@ def setup(bot): bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) -@SpiceBot.prerun.prerun('nickname_command') +@SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('update') def nickname_comand_update(bot, trigger): From 8ab1b69ea4d6f99396c2a571837755e4df1aeafe Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 15:51:14 -0400 Subject: [PATCH 036/328] append issue --- sopel_modules/SpiceBot/Prerun.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index c8ad134..8e5c592 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -58,6 +58,7 @@ class BotPrerun(): if len(argsdict["hyphen_args"]): self.hyphen_arg_handler(bot, trigger, argsdict) + # check if anything prohibits the nick from running the command if self.runstatus(bot, trigger, argsdict): function(bot, trigger, *args, **kwargs) return @@ -80,15 +81,15 @@ class BotPrerun(): trigger_args_list_split.append([]) return trigger_args_list_split - def argsdict_list(self, argsdict_default, prerun_and_split): + def argsdict_list(self, argsdict_default, and_split): prerun_split = [] - for trigger_args_list in prerun_and_split: - argsdict = copy.deepcopy(argsdict_default) + for trigger_args_list in and_split: + argsdict_part = copy.deepcopy(argsdict_default) trigger_args_part = spicemanip.main(trigger_args_list, 'create') trigger_args_part, hyphen_args = self.hyphen_args(trigger_args_part) - argsdict["hyphen_args"] = hyphen_args - argsdict["args"] = trigger_args_part - prerun_split.append(argsdict) + argsdict_part["hyphen_args"] = hyphen_args + argsdict_part["args"] = trigger_args_part + prerun_split.append(argsdict_part) return prerun_split def hyphen_args(self, trigger_args_part): @@ -98,8 +99,10 @@ class BotPrerun(): hyphen_args = [] trigger_args_unhyphend = [] for worditem in trigger_args_part: - if str(worditem).startswith("--") and worditem[2:] in valid_hyphen_args: - hyphen_args.append(worditem[2:]) + if str(worditem).startswith("--"): + hyphencom = worditem[2:] + if hyphencom in valid_hyphen_args: + hyphen_args.append(hyphencom) else: trigger_args_unhyphend.append(worditem) return trigger_args_unhyphend, hyphen_args @@ -168,9 +171,9 @@ class BotPrerun(): if not trigger.is_privmsg: disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} if argsdict["realcom"] in disabled_list.keys(): - reason = disabled_list["disabled_commands"][argsdict["realcom"]]["reason"] - timestamp = disabled_list["disabled_commands"][argsdict["realcom"]]["timestamp"] - bywhom = disabled_list["disabled_commands"][argsdict["realcom"]]["disabledby"] + reason = disabled_list[argsdict["realcom"]]["reason"] + timestamp = disabled_list[argsdict["realcom"]]["timestamp"] + bywhom = disabled_list[argsdict["realcom"]]["disabledby"] bot.notice("The " + str(argsdict["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason), trigger.nick) return False From 1a5ef76dc1facafcdf354be73d08c564459b7325 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 16:04:21 -0400 Subject: [PATCH 037/328] test --- sopel_modules/SpiceBot/Prerun.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 8e5c592..18294a7 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -83,12 +83,14 @@ class BotPrerun(): def argsdict_list(self, argsdict_default, and_split): prerun_split = [] - for trigger_args_list in and_split: + for trigger_args_part in and_split: + argsdict_part = copy.deepcopy(argsdict_default) - trigger_args_part = spicemanip.main(trigger_args_list, 'create') - trigger_args_part, hyphen_args = self.hyphen_args(trigger_args_part) - argsdict_part["hyphen_args"] = hyphen_args - argsdict_part["args"] = trigger_args_part + + trigger_args_part_list = spicemanip.main(trigger_args_part, 'create') + + argsdict_part["args"], argsdict_part["hyphen_args"] = self.hyphen_args(trigger_args_part_list) + prerun_split.append(argsdict_part) return prerun_split From d56d8d92614cd99012035feb443154170f2714c6 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 17:55:48 -0400 Subject: [PATCH 038/328] new attempt --- sopel_modules/SpiceBot/Commands.py | 26 ++++++++++++++++++++++++++ sopel_modules/SpiceBot/Prerun.py | 19 ++++++------------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index cdaf180..89240d9 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -12,6 +12,7 @@ import threading import spicemanip from .Logs import logs +from .Database import db as spicedb class BotCommands(): @@ -25,6 +26,7 @@ class BotCommands(): 'nickname': {}, 'rule': {} }, + 'disabled': {} } def find_command_type(self, command): @@ -35,6 +37,30 @@ class BotCommands(): return commandstype return None + def get_disabled_commands(self, bot, channel): + if not len(list(self.dict['disabled'])): + self.dict['disabled'] = spicedb.get_channel_value(bot, channel, 'disabled_commands', 'commands') or {} + return self.dict['disabled'] + + def check_disabled_commands(self, bot, command, channel): + if command in self.get_disabled_commands(self, bot, channel).keys(): + return True + else: + return False + + def set_command_disabled(self, bot, command, channel, timestamp, reason, bywhom): + if not len(list(self.dict['disabled'])): + self.dict['disabled'] = spicedb.get_channel_value(bot, channel, 'disabled_commands', 'commands') or {} + self.dict['disabled'][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom} + spicedb.set_channel_value(bot, channel, 'disabled_commands', self.dict['disabled'], 'commands') + + def unset_command_disabled(self, bot, command, channel): + if not len(list(self.dict['disabled'])): + self.dict['disabled'] = spicedb.get_channel_value(bot, channel, 'disabled_commands', 'commands') or {} + if command in self.dict['disabled'].keys(): + del self.dict['disabled'][command] + spicedb.set_channel_value(bot, channel, 'disabled_commands', self.dict['disabled'], 'commands') + def register(self, bot, command_dict): self.lock.acquire() diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 18294a7..ad29073 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -53,13 +53,14 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: - trigger.sb = argsdict if len(argsdict["hyphen_args"]): self.hyphen_arg_handler(bot, trigger, argsdict) + argsdict["hyphen_args"] = [] # check if anything prohibits the nick from running the command if self.runstatus(bot, trigger, argsdict): + trigger.sb = argsdict function(bot, trigger, *args, **kwargs) return return internal_prerun @@ -124,14 +125,11 @@ class BotPrerun(): bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick) return - disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} - - if argsdict["realcom"] not in disabled_list.keys(): + if not commands.check_disabled_commands(self, bot, argsdict["realcom"], trigger.sender): bot.notice(argsdict["com"] + " is already enabled in " + str(trigger.sender), trigger.nick) return - del disabled_list[argsdict["realcom"]] - spicedb.set_channel_value(bot, trigger.sender, 'disabled_commands', disabled_list, 'commands') + commands.unset_command_disabled(bot, argsdict["realcom"], trigger.sender) bot.say(argsdict["com"] + " is now enabled in " + str(trigger.sender)) return @@ -145,19 +143,14 @@ class BotPrerun(): bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick) return - disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} - - if argsdict["realcom"] in disabled_list.keys(): + if commands.check_disabled_commands(self, bot, argsdict["realcom"], trigger.sender): bot.notice(argsdict["com"] + " is already disabled in " + str(trigger.sender), trigger.nick) return trailingmessage = spicemanip.main(argsdict["args"], 0) or "No reason given." timestamp = str(datetime.datetime.utcnow()) - disabled_list[argsdict["realcom"]] = {"reason": trailingmessage, "timestamp": timestamp, "disabledby": trigger.nick} - spicedb.set_channel_value(bot, trigger.sender, 'disabled_commands', disabled_list, 'commands') - - spicedb.adjust_channel_list(bot, trigger.sender, 'disabled_commands', argsdict["realcom"], 'add', 'commands') + commands.set_command_disabled(self, bot, argsdict["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) bot.say(argsdict["com"] + " is now disabled in " + str(trigger.sender)) return From 534ccabf1b69ebea256691bdba5c1f7be500f07a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 18:03:06 -0400 Subject: [PATCH 039/328] test --- sopel_modules/SpiceBot/Prerun.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index ad29073..0098a50 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -54,9 +54,8 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: - if len(argsdict["hyphen_args"]): + if argsdict["hyphen_arg"]: self.hyphen_arg_handler(bot, trigger, argsdict) - argsdict["hyphen_args"] = [] # check if anything prohibits the nick from running the command if self.runstatus(bot, trigger, argsdict): @@ -90,7 +89,7 @@ class BotPrerun(): trigger_args_part_list = spicemanip.main(trigger_args_part, 'create') - argsdict_part["args"], argsdict_part["hyphen_args"] = self.hyphen_args(trigger_args_part_list) + argsdict_part["args"], argsdict_part["hyphen_arg"] = self.hyphen_args(trigger_args_part_list) prerun_split.append(argsdict_part) return prerun_split @@ -108,11 +107,15 @@ class BotPrerun(): hyphen_args.append(hyphencom) else: trigger_args_unhyphend.append(worditem) - return trigger_args_unhyphend, hyphen_args + if len(hyphen_args): + hyphenarg = hyphen_args[0] + else: + hyphenarg = None + return trigger_args_unhyphend, hyphenarg def hyphen_arg_handler(self, bot, trigger, argsdict): - hyphenarg = argsdict["hyphen_args"][0] + hyphenarg = argsdict["hyphen_arg"] # Commands that cannot run via privmsg if hyphenarg in ['enable']: @@ -159,7 +162,7 @@ class BotPrerun(): def runstatus(self, bot, trigger, argsdict): # Hyphen args can only be used one per && split - if len(argsdict["hyphen_args"]): + if argsdict["hyphen_arg"]: return False # don't run commands that are disabled in channels From c318ccee6cb57b88cb2f534c028d6d85495fec14 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 18:16:19 -0400 Subject: [PATCH 040/328] plural still there --- sopel_modules/SpiceBot/Prerun.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 0098a50..44ab216 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -115,10 +115,11 @@ class BotPrerun(): def hyphen_arg_handler(self, bot, trigger, argsdict): - hyphenarg = argsdict["hyphen_arg"] + if not argsdict["hyphen_arg"]: + return # Commands that cannot run via privmsg - if hyphenarg in ['enable']: + if argsdict["hyphen_arg"] in ['enable']: if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): bot.say("I was unable to disable this command due to privilege issues.") @@ -136,7 +137,7 @@ class BotPrerun(): bot.say(argsdict["com"] + " is now enabled in " + str(trigger.sender)) return - elif hyphenarg in ['disable']: + elif argsdict["hyphen_arg"] in ['disable']: if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): bot.say("I was unable to disable this command due to privilege issues.") From d66c29fda9ebd4bec3cc2725ca7253b22936328b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 18:23:42 -0400 Subject: [PATCH 041/328] repair self --- sopel_modules/SpiceBot/Prerun.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 44ab216..f37c7f4 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -129,7 +129,7 @@ class BotPrerun(): bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick) return - if not commands.check_disabled_commands(self, bot, argsdict["realcom"], trigger.sender): + if not commands.check_disabled_commands(bot, argsdict["realcom"], trigger.sender): bot.notice(argsdict["com"] + " is already enabled in " + str(trigger.sender), trigger.nick) return @@ -147,14 +147,14 @@ class BotPrerun(): bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick) return - if commands.check_disabled_commands(self, bot, argsdict["realcom"], trigger.sender): + if commands.check_disabled_commands(bot, argsdict["realcom"], trigger.sender): bot.notice(argsdict["com"] + " is already disabled in " + str(trigger.sender), trigger.nick) return trailingmessage = spicemanip.main(argsdict["args"], 0) or "No reason given." timestamp = str(datetime.datetime.utcnow()) - commands.set_command_disabled(self, bot, argsdict["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) + commands.set_command_disabled(bot, argsdict["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) bot.say(argsdict["com"] + " is now disabled in " + str(trigger.sender)) return From 60a7c4cc87af9f489a672d717e33be8edd8a18e3 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 18:36:01 -0400 Subject: [PATCH 042/328] more self error --- sopel_modules/SpiceBot/Commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 89240d9..46aa57d 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -43,7 +43,7 @@ class BotCommands(): return self.dict['disabled'] def check_disabled_commands(self, bot, command, channel): - if command in self.get_disabled_commands(self, bot, channel).keys(): + if command in self.get_disabled_commands(bot, channel).keys(): return True else: return False From ef6b4e1c3ac5ac23013889c2085e59124cfc2544 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 18:54:24 -0400 Subject: [PATCH 043/328] test with removal of jobs --- sopel_modules/SpiceBot/Prerun.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index f37c7f4..b97c971 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -52,15 +52,16 @@ class BotPrerun(): argsdict_list = self.argsdict_list(argsdict_default, and_split) # Run the function for all splits - for argsdict in argsdict_list: + while len(argsdict_list): - if argsdict["hyphen_arg"]: - self.hyphen_arg_handler(bot, trigger, argsdict) + if argsdict_list[0]["hyphen_arg"]: + self.hyphen_arg_handler(bot, trigger, argsdict_list[0]) # check if anything prohibits the nick from running the command - if self.runstatus(bot, trigger, argsdict): - trigger.sb = argsdict + if self.runstatus(bot, trigger, argsdict_list[0]): + trigger.sb = argsdict_list[0] function(bot, trigger, *args, **kwargs) + del argsdict_list[0] return return internal_prerun return actual_decorator From f553641ebc4d393bcb6d261cf2fb7487a7d7ccfa Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 19:03:08 -0400 Subject: [PATCH 044/328] pass --- sopel_modules/SpiceBot/Prerun.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index b97c971..fae6ff1 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -46,19 +46,21 @@ class BotPrerun(): argsdict_default["realcom"] = realcom # split into && groupings - and_split = self.and_split(trigger_args) + and_split = self.trigger_and_split(trigger_args) # Create dict listings for trigger.sb - argsdict_list = self.argsdict_list(argsdict_default, and_split) + argsdict_list = self.trigger_argsdict_list(argsdict_default, and_split) # Run the function for all splits while len(argsdict_list): if argsdict_list[0]["hyphen_arg"]: - self.hyphen_arg_handler(bot, trigger, argsdict_list[0]) + self.trigger_hyphen_arg_handler(bot, trigger, argsdict_list[0]) + del argsdict_list[0] + pass # check if anything prohibits the nick from running the command - if self.runstatus(bot, trigger, argsdict_list[0]): + if self.trigger_runstatus(bot, trigger, argsdict_list[0]): trigger.sb = argsdict_list[0] function(bot, trigger, *args, **kwargs) del argsdict_list[0] @@ -76,13 +78,13 @@ class BotPrerun(): trigger_args = spicemanip.main(trigger_args, '2+', 'list') return trigger_args, trigger_command - def and_split(self, trigger_args): + def trigger_and_split(self, trigger_args): trigger_args_list_split = spicemanip.main(trigger_args, "split_&&") if not len(trigger_args_list_split): trigger_args_list_split.append([]) return trigger_args_list_split - def argsdict_list(self, argsdict_default, and_split): + def trigger_argsdict_list(self, argsdict_default, and_split): prerun_split = [] for trigger_args_part in and_split: @@ -90,12 +92,12 @@ class BotPrerun(): trigger_args_part_list = spicemanip.main(trigger_args_part, 'create') - argsdict_part["args"], argsdict_part["hyphen_arg"] = self.hyphen_args(trigger_args_part_list) + argsdict_part["args"], argsdict_part["hyphen_arg"] = self.trigger_hyphen_args(trigger_args_part_list) prerun_split.append(argsdict_part) return prerun_split - def hyphen_args(self, trigger_args_part): + def trigger_hyphen_args(self, trigger_args_part): valid_hyphen_args = [ 'enable', 'disable' ] @@ -114,7 +116,7 @@ class BotPrerun(): hyphenarg = None return trigger_args_unhyphend, hyphenarg - def hyphen_arg_handler(self, bot, trigger, argsdict): + def trigger_hyphen_arg_handler(self, bot, trigger, argsdict): if not argsdict["hyphen_arg"]: return @@ -161,7 +163,7 @@ class BotPrerun(): return - def runstatus(self, bot, trigger, argsdict): + def trigger_runstatus(self, bot, trigger, argsdict): # Hyphen args can only be used one per && split if argsdict["hyphen_arg"]: From dfba5e8dc2013a2408cd5f659743a5e1625088e8 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 19:04:53 -0400 Subject: [PATCH 045/328] more pass --- sopel_modules/SpiceBot/Prerun.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index fae6ff1..431f37b 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -63,7 +63,10 @@ class BotPrerun(): if self.trigger_runstatus(bot, trigger, argsdict_list[0]): trigger.sb = argsdict_list[0] function(bot, trigger, *args, **kwargs) - del argsdict_list[0] + del argsdict_list[0] + else: + del argsdict_list[0] + pass return return internal_prerun return actual_decorator From 2174cf573220288143475349acba11160bc57619 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 19:10:36 -0400 Subject: [PATCH 046/328] no return --- sopel_modules/SpiceBot/Prerun.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 431f37b..af00485 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -67,7 +67,6 @@ class BotPrerun(): else: del argsdict_list[0] pass - return return internal_prerun return actual_decorator From f42fc295063dde0d7135ed478a94707dfbf5fa4d Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 19:28:16 -0400 Subject: [PATCH 047/328] seperate hyphen arg logic --- sopel_modules/SpiceBot/Prerun.py | 37 ++++++++++++++------------------ 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index af00485..97672f8 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -20,6 +20,18 @@ class BotPrerun(): def __init__(self): self.dict = {} + def hyphenargs(self, trigger_command_type='module'): + def actual_decorator(function): + @functools.wraps(function) + def internal_prerun(bot, trigger, *args, **kwargs): + trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(self, trigger.sb) + if trigger.sb["hyphen_arg"]: + return self.trigger_hyphen_arg_handler(bot, trigger, trigger.sb) + else: + return function(bot, trigger, *args, **kwargs) + return internal_prerun + return actual_decorator + def prerun(self, trigger_command_type='module'): def actual_decorator(function): @functools.wraps(function) @@ -52,21 +64,12 @@ class BotPrerun(): argsdict_list = self.trigger_argsdict_list(argsdict_default, and_split) # Run the function for all splits - while len(argsdict_list): - - if argsdict_list[0]["hyphen_arg"]: - self.trigger_hyphen_arg_handler(bot, trigger, argsdict_list[0]) - del argsdict_list[0] - pass - + for argsdict in argsdict_list: # check if anything prohibits the nick from running the command if self.trigger_runstatus(bot, trigger, argsdict_list[0]): - trigger.sb = argsdict_list[0] + trigger.sb = argsdict function(bot, trigger, *args, **kwargs) - del argsdict_list[0] - else: - del argsdict_list[0] - pass + return return internal_prerun return actual_decorator @@ -89,13 +92,8 @@ class BotPrerun(): def trigger_argsdict_list(self, argsdict_default, and_split): prerun_split = [] for trigger_args_part in and_split: - argsdict_part = copy.deepcopy(argsdict_default) - - trigger_args_part_list = spicemanip.main(trigger_args_part, 'create') - - argsdict_part["args"], argsdict_part["hyphen_arg"] = self.trigger_hyphen_args(trigger_args_part_list) - + argsdict_part["args"] = spicemanip.main(trigger_args_part, 'create') prerun_split.append(argsdict_part) return prerun_split @@ -120,9 +118,6 @@ class BotPrerun(): def trigger_hyphen_arg_handler(self, bot, trigger, argsdict): - if not argsdict["hyphen_arg"]: - return - # Commands that cannot run via privmsg if argsdict["hyphen_arg"] in ['enable']: From 459b9820ac65128e44d0fc485ad6ce09aaead7ee Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 19:43:07 -0400 Subject: [PATCH 048/328] tidy code --- sopel_modules/SpiceBot/Prerun.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 97672f8..6b2a8f9 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -162,10 +162,6 @@ class BotPrerun(): def trigger_runstatus(self, bot, trigger, argsdict): - # Hyphen args can only be used one per && split - if argsdict["hyphen_arg"]: - return False - # don't run commands that are disabled in channels if not trigger.is_privmsg: disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} From c29ae5c1d6cda401cfef82dd95f9b34a0dbc3544 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 19:45:26 -0400 Subject: [PATCH 049/328] no input needed --- sopel_modules/SpiceBot/Prerun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 6b2a8f9..1192554 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -20,7 +20,7 @@ class BotPrerun(): def __init__(self): self.dict = {} - def hyphenargs(self, trigger_command_type='module'): + def hyphenargs(self): def actual_decorator(function): @functools.wraps(function) def internal_prerun(bot, trigger, *args, **kwargs): From 45bd2df646c09c565011c919638dc893b954546f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 19:53:24 -0400 Subject: [PATCH 050/328] self --- sopel_modules/SpiceBot/Prerun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 1192554..f4c67d6 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -24,7 +24,7 @@ class BotPrerun(): def actual_decorator(function): @functools.wraps(function) def internal_prerun(bot, trigger, *args, **kwargs): - trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(self, trigger.sb) + trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb) if trigger.sb["hyphen_arg"]: return self.trigger_hyphen_arg_handler(bot, trigger, trigger.sb) else: From 36cfb11d619ece3baafdb16c3312c1aaab87eab3 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 19:56:56 -0400 Subject: [PATCH 051/328] test --- sopel_modules/SpiceBot/Prerun.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index f4c67d6..51e8ba1 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -65,10 +65,14 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: - # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger, argsdict_list[0]): - trigger.sb = argsdict - function(bot, trigger, *args, **kwargs) + trigger.sb = argsdict + trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb) + if trigger.sb["hyphen_arg"]: + return self.trigger_hyphen_arg_handler(bot, trigger, trigger.sb) + else: + # check if anything prohibits the nick from running the command + if self.trigger_runstatus(bot, trigger, argsdict_list[0]): + function(bot, trigger, *args, **kwargs) return return internal_prerun return actual_decorator From 8f64fb94e3398e3edb4def0539180ac04754f791 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 20:01:26 -0400 Subject: [PATCH 052/328] args processing --- sopel_modules/SpiceBot/Prerun.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 51e8ba1..07ae117 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -20,18 +20,6 @@ class BotPrerun(): def __init__(self): self.dict = {} - def hyphenargs(self): - def actual_decorator(function): - @functools.wraps(function) - def internal_prerun(bot, trigger, *args, **kwargs): - trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb) - if trigger.sb["hyphen_arg"]: - return self.trigger_hyphen_arg_handler(bot, trigger, trigger.sb) - else: - return function(bot, trigger, *args, **kwargs) - return internal_prerun - return actual_decorator - def prerun(self, trigger_command_type='module'): def actual_decorator(function): @functools.wraps(function) @@ -66,9 +54,9 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: trigger.sb = argsdict - trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb) + trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) if trigger.sb["hyphen_arg"]: - return self.trigger_hyphen_arg_handler(bot, trigger, trigger.sb) + self.trigger_hyphen_arg_handler(bot, trigger, trigger.sb) else: # check if anything prohibits the nick from running the command if self.trigger_runstatus(bot, trigger, argsdict_list[0]): From eaec9acfc6f0093a7077493888a9fc1464220c6f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 20:12:17 -0400 Subject: [PATCH 053/328] 0 --- sopel_modules/SpiceBot/Prerun.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 07ae117..a846683 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -56,10 +56,10 @@ class BotPrerun(): trigger.sb = argsdict trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) if trigger.sb["hyphen_arg"]: - self.trigger_hyphen_arg_handler(bot, trigger, trigger.sb) + self.trigger_hyphen_arg_handler(bot, trigger) else: # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger, argsdict_list[0]): + if self.trigger_runstatus(bot, trigger, argsdict): function(bot, trigger, *args, **kwargs) return return internal_prerun @@ -108,10 +108,10 @@ class BotPrerun(): hyphenarg = None return trigger_args_unhyphend, hyphenarg - def trigger_hyphen_arg_handler(self, bot, trigger, argsdict): + def trigger_hyphen_arg_handler(self, bot, trigger): # Commands that cannot run via privmsg - if argsdict["hyphen_arg"] in ['enable']: + if trigger.sb["hyphen_arg"] in ['enable']: if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): bot.say("I was unable to disable this command due to privilege issues.") @@ -121,15 +121,15 @@ class BotPrerun(): bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick) return - if not commands.check_disabled_commands(bot, argsdict["realcom"], trigger.sender): - bot.notice(argsdict["com"] + " is already enabled in " + str(trigger.sender), trigger.nick) + if not commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): + bot.notice(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick) return - commands.unset_command_disabled(bot, argsdict["realcom"], trigger.sender) - bot.say(argsdict["com"] + " is now enabled in " + str(trigger.sender)) + commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender) + bot.say(trigger.sb["com"] + " is now enabled in " + str(trigger.sender)) return - elif argsdict["hyphen_arg"] in ['disable']: + elif trigger.sb["hyphen_arg"] in ['disable']: if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): bot.say("I was unable to disable this command due to privilege issues.") @@ -139,15 +139,15 @@ class BotPrerun(): bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick) return - if commands.check_disabled_commands(bot, argsdict["realcom"], trigger.sender): - bot.notice(argsdict["com"] + " is already disabled in " + str(trigger.sender), trigger.nick) + if commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): + bot.notice(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick) return - trailingmessage = spicemanip.main(argsdict["args"], 0) or "No reason given." + trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given." timestamp = str(datetime.datetime.utcnow()) - commands.set_command_disabled(bot, argsdict["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) - bot.say(argsdict["com"] + " is now disabled in " + str(trigger.sender)) + commands.set_command_disabled(bot, trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) + bot.say(trigger.sb["com"] + " is now disabled in " + str(trigger.sender)) return return From 20eea8f66441583cb52ab6384b4d781ac654c02b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 20:16:41 -0400 Subject: [PATCH 054/328] test --- sopel_modules/SpiceBot/Prerun.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index a846683..d22005e 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -55,12 +55,14 @@ class BotPrerun(): for argsdict in argsdict_list: trigger.sb = argsdict trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) - if trigger.sb["hyphen_arg"]: - self.trigger_hyphen_arg_handler(bot, trigger) - else: - # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger, argsdict): - function(bot, trigger, *args, **kwargs) + # if trigger.sb["hyphen_arg"]: + # self.trigger_hyphen_arg_handler(bot, trigger) + # else: + # # check if anything prohibits the nick from running the command + # if self.trigger_runstatus(bot, trigger, argsdict): + # function(bot, trigger, *args, **kwargs) + if self.trigger_runstatus(bot, trigger, argsdict): + function(bot, trigger, *args, **kwargs) return return internal_prerun return actual_decorator From e9a9c236cbf30bd717b3df1d5cfd86df53581698 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 20:28:01 -0400 Subject: [PATCH 055/328] --check --- sopel_modules/SpiceBot/Prerun.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index d22005e..94287bf 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -55,14 +55,12 @@ class BotPrerun(): for argsdict in argsdict_list: trigger.sb = argsdict trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) - # if trigger.sb["hyphen_arg"]: - # self.trigger_hyphen_arg_handler(bot, trigger) - # else: - # # check if anything prohibits the nick from running the command - # if self.trigger_runstatus(bot, trigger, argsdict): - # function(bot, trigger, *args, **kwargs) - if self.trigger_runstatus(bot, trigger, argsdict): - function(bot, trigger, *args, **kwargs) + if not trigger.sb["hyphen_arg"]: + # check if anything prohibits the nick from running the command + if self.trigger_runstatus(bot, trigger, argsdict): + function(bot, trigger, *args, **kwargs) + else: + self.trigger_hyphen_arg_handler(bot, trigger) return return internal_prerun return actual_decorator @@ -113,7 +111,14 @@ class BotPrerun(): def trigger_hyphen_arg_handler(self, bot, trigger): # Commands that cannot run via privmsg - if trigger.sb["hyphen_arg"] in ['enable']: + if trigger.sb["hyphen_arg"] in ['check']: + if trigger.sb["com"].lower() != trigger.sb["realcom"]: + bot.say(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"]) + else: + bot.say(trigger.sb["com"] + " is a valid command") + return + + elif trigger.sb["hyphen_arg"] in ['enable']: if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): bot.say("I was unable to disable this command due to privilege issues.") From 03a25ed8b202719e2a182dd70d8594d6b46d1978 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 20:30:58 -0400 Subject: [PATCH 056/328] check is valid --- sopel_modules/SpiceBot/Prerun.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 94287bf..a48e7df 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -91,6 +91,7 @@ class BotPrerun(): def trigger_hyphen_args(self, trigger_args_part): valid_hyphen_args = [ + 'check', 'enable', 'disable' ] hyphen_args = [] From 0c48f1a48a3baefc6ac66ea653f372496e51420e Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 20:31:39 -0400 Subject: [PATCH 057/328] better --- sopel_modules/SpiceBot/Prerun.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index a48e7df..2322bd7 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -97,10 +97,8 @@ class BotPrerun(): hyphen_args = [] trigger_args_unhyphend = [] for worditem in trigger_args_part: - if str(worditem).startswith("--"): - hyphencom = worditem[2:] - if hyphencom in valid_hyphen_args: - hyphen_args.append(hyphencom) + if str(worditem).startswith("--") and worditem[2:] in valid_hyphen_args: + hyphen_args.append(worditem[2:]) else: trigger_args_unhyphend.append(worditem) if len(hyphen_args): From 64d2d500385dedd3ce09e756c5495caee25e1ce8 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 20:37:01 -0400 Subject: [PATCH 058/328] test --- sopel_modules/SpiceBot/Prerun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 2322bd7..9a327cc 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -61,7 +61,7 @@ class BotPrerun(): function(bot, trigger, *args, **kwargs) else: self.trigger_hyphen_arg_handler(bot, trigger) - return + return function(bot, trigger, *args, **kwargs) return internal_prerun return actual_decorator From aa66676ee186e0184898a6433686dd951dc68b03 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 21:00:00 -0400 Subject: [PATCH 059/328] test --- sopel_modules/SpiceBot/Prerun.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 9a327cc..78d7271 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -53,15 +53,15 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: - trigger.sb = argsdict + trigger.sb = copy.deepcopy(argsdict) trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) if not trigger.sb["hyphen_arg"]: # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger, argsdict): + if self.trigger_runstatus(bot, trigger): function(bot, trigger, *args, **kwargs) else: self.trigger_hyphen_arg_handler(bot, trigger) - return function(bot, trigger, *args, **kwargs) + return internal_prerun return actual_decorator @@ -115,38 +115,46 @@ class BotPrerun(): bot.say(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"]) else: bot.say(trigger.sb["com"] + " is a valid command") + trigger.sb["hyphen_arg"] = None return elif trigger.sb["hyphen_arg"] in ['enable']: if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): bot.say("I was unable to disable this command due to privilege issues.") + trigger.sb["hyphen_arg"] = None return if trigger.is_privmsg: bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick) + trigger.sb["hyphen_arg"] = None return if not commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): bot.notice(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick) + trigger.sb["hyphen_arg"] = None return commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender) bot.say(trigger.sb["com"] + " is now enabled in " + str(trigger.sender)) + trigger.sb["hyphen_arg"] = None return elif trigger.sb["hyphen_arg"] in ['disable']: if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): bot.say("I was unable to disable this command due to privilege issues.") + trigger.sb["hyphen_arg"] = None return if trigger.is_privmsg: bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick) + trigger.sb["hyphen_arg"] = None return if commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): bot.notice(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick) + trigger.sb["hyphen_arg"] = None return trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given." @@ -154,20 +162,22 @@ class BotPrerun(): commands.set_command_disabled(bot, trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) bot.say(trigger.sb["com"] + " is now disabled in " + str(trigger.sender)) + trigger.sb["hyphen_arg"] = None return + trigger.sb["hyphen_arg"] = None return - def trigger_runstatus(self, bot, trigger, argsdict): + def trigger_runstatus(self, bot, trigger): # don't run commands that are disabled in channels if not trigger.is_privmsg: disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} - if argsdict["realcom"] in disabled_list.keys(): - reason = disabled_list[argsdict["realcom"]]["reason"] - timestamp = disabled_list[argsdict["realcom"]]["timestamp"] - bywhom = disabled_list[argsdict["realcom"]]["disabledby"] - bot.notice("The " + str(argsdict["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason), trigger.nick) + if trigger.sb["realcom"] in disabled_list.keys(): + reason = disabled_list[trigger.sb["realcom"]]["reason"] + timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"] + bywhom = disabled_list[trigger.sb["realcom"]]["disabledby"] + bot.notice("The " + str(trigger.sb["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason), trigger.nick) return False return True From 6f124a4fbd6d787572add0c496fad6bc7d491365 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 21:09:41 -0400 Subject: [PATCH 060/328] test --- sopel_modules/SpiceBot/Prerun.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 78d7271..71a2a57 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -60,7 +60,8 @@ class BotPrerun(): if self.trigger_runstatus(bot, trigger): function(bot, trigger, *args, **kwargs) else: - self.trigger_hyphen_arg_handler(bot, trigger) + bot.say(trigger.sb["hyphen_arg"]) + # self.trigger_hyphen_arg_handler(bot, trigger) return internal_prerun return actual_decorator @@ -115,46 +116,38 @@ class BotPrerun(): bot.say(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"]) else: bot.say(trigger.sb["com"] + " is a valid command") - trigger.sb["hyphen_arg"] = None return elif trigger.sb["hyphen_arg"] in ['enable']: if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): bot.say("I was unable to disable this command due to privilege issues.") - trigger.sb["hyphen_arg"] = None return if trigger.is_privmsg: bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick) - trigger.sb["hyphen_arg"] = None return if not commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): bot.notice(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick) - trigger.sb["hyphen_arg"] = None return commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender) bot.say(trigger.sb["com"] + " is now enabled in " + str(trigger.sender)) - trigger.sb["hyphen_arg"] = None return elif trigger.sb["hyphen_arg"] in ['disable']: if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): bot.say("I was unable to disable this command due to privilege issues.") - trigger.sb["hyphen_arg"] = None return if trigger.is_privmsg: bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick) - trigger.sb["hyphen_arg"] = None return if commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): bot.notice(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick) - trigger.sb["hyphen_arg"] = None return trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given." @@ -162,10 +155,8 @@ class BotPrerun(): commands.set_command_disabled(bot, trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) bot.say(trigger.sb["com"] + " is now disabled in " + str(trigger.sender)) - trigger.sb["hyphen_arg"] = None return - trigger.sb["hyphen_arg"] = None return def trigger_runstatus(self, bot, trigger): From 155f6a8ec182fbca19372fa79c0af38f0459687f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 21:20:39 -0400 Subject: [PATCH 061/328] test uuid system --- sopel_modules/SpiceBot/Prerun.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 71a2a57..8ce34eb 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -9,6 +9,7 @@ from sopel.tools import Identifier import functools import copy import datetime +import uuid import spicemanip from .Tools import command_permissions_check @@ -18,6 +19,8 @@ from .Database import db as spicedb class BotPrerun(): def __init__(self): + self.usedids = [0] + self.utilizedids = [] self.dict = {} def prerun(self, trigger_command_type='module'): @@ -53,15 +56,19 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: + trigger.sb["uuid"] = self.unique_id_create() trigger.sb = copy.deepcopy(argsdict) trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) if not trigger.sb["hyphen_arg"]: # check if anything prohibits the nick from running the command if self.trigger_runstatus(bot, trigger): - function(bot, trigger, *args, **kwargs) + if trigger.sb["uuid"] not in self.utilizedids: + function(bot, trigger, *args, **kwargs) + self.utilizedids.append(trigger.sb["uuid"]) else: - bot.say(trigger.sb["hyphen_arg"]) - # self.trigger_hyphen_arg_handler(bot, trigger) + if trigger.sb["uuid"] not in self.utilizedids: + self.trigger_hyphen_arg_handler(bot, trigger) + self.utilizedids.append(trigger.sb["uuid"]) return internal_prerun return actual_decorator @@ -173,5 +180,12 @@ class BotPrerun(): return True + def unique_id_create(self): + unique_id = 0 + while unique_id in self.usedids: + unique_id = uuid.uuid4() + self.usedids.append(unique_id) + return unique_id + prerun = BotPrerun() From e755983c5135b29e604d59336ad59c2152e2c741 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 21:24:22 -0400 Subject: [PATCH 062/328] order is importatnt --- sopel_modules/SpiceBot/Prerun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 8ce34eb..4676a92 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -56,8 +56,8 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: - trigger.sb["uuid"] = self.unique_id_create() trigger.sb = copy.deepcopy(argsdict) + trigger.sb["uuid"] = self.unique_id_create() trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) if not trigger.sb["hyphen_arg"]: # check if anything prohibits the nick from running the command From 02ae7f75e0a08f8ffbefc9207991231b80628f54 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 21:27:09 -0400 Subject: [PATCH 063/328] uuid method did not work --- sopel_modules/SpiceBot/Prerun.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 4676a92..afbf587 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -9,7 +9,6 @@ from sopel.tools import Identifier import functools import copy import datetime -import uuid import spicemanip from .Tools import command_permissions_check @@ -19,8 +18,6 @@ from .Database import db as spicedb class BotPrerun(): def __init__(self): - self.usedids = [0] - self.utilizedids = [] self.dict = {} def prerun(self, trigger_command_type='module'): @@ -57,18 +54,13 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: trigger.sb = copy.deepcopy(argsdict) - trigger.sb["uuid"] = self.unique_id_create() trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) if not trigger.sb["hyphen_arg"]: # check if anything prohibits the nick from running the command if self.trigger_runstatus(bot, trigger): - if trigger.sb["uuid"] not in self.utilizedids: - function(bot, trigger, *args, **kwargs) - self.utilizedids.append(trigger.sb["uuid"]) + function(bot, trigger, *args, **kwargs) else: - if trigger.sb["uuid"] not in self.utilizedids: - self.trigger_hyphen_arg_handler(bot, trigger) - self.utilizedids.append(trigger.sb["uuid"]) + self.trigger_hyphen_arg_handler(bot, trigger) return internal_prerun return actual_decorator @@ -180,12 +172,5 @@ class BotPrerun(): return True - def unique_id_create(self): - unique_id = 0 - while unique_id in self.usedids: - unique_id = uuid.uuid4() - self.usedids.append(unique_id) - return unique_id - prerun = BotPrerun() From cd737c2a6f1e9424e736948707948d637c380bcf Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 21:34:53 -0400 Subject: [PATCH 064/328] test new alias system --- sopel_modules/SpiceBot/Commands.py | 11 +++++++++++ sopel_modules/SpiceBot/Prerun.py | 7 +------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 46aa57d..5db001b 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -48,6 +48,17 @@ class BotCommands(): else: return False + def get_realcom(self, command, trigger_command_type): + commands_list = dict() + for commandstype in self.dict['commands'][trigger_command_type].keys(): + for com in self.dict['commands'][commandstype].keys(): + if com not in commands_list.keys(): + commands_list[com] = self.dict['commands'][commandstype][com] + realcom = command + if "aliasfor" in commands_list[command['com']].keys(): + realcom = commands_list[command['com']]["aliasfor"] + return realcom + def set_command_disabled(self, bot, command, channel, timestamp, reason, bywhom): if not len(list(self.dict['disabled'])): self.dict['disabled'] = spicedb.get_channel_value(bot, channel, 'disabled_commands', 'commands') or {} diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index afbf587..8728a55 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -32,17 +32,12 @@ class BotPrerun(): # Primary command used for trigger, and a list of all words trigger_args, trigger_command = self.trigger_args(trigger.args[1], trigger_command_type) - command_lookup = commands.find_command_type(trigger_command) - # Argsdict Defaults argsdict_default = {} argsdict_default["type"] = trigger_command_type argsdict_default["com"] = trigger_command - if command_lookup and "aliasfor" in commands.dict["commands"][command_lookup].keys(): - realcom = commands.dict["commands"][command_lookup]["aliasfor"] - else: - realcom = trigger_command + realcom = commands.get_realcom(argsdict_default["com"], trigger_command_type) argsdict_default["realcom"] = realcom # split into && groupings From 9a63f175e14542f2ac77dcde4b5ae2aba38d5f01 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 21:36:09 -0400 Subject: [PATCH 065/328] test --- sopel_modules/SpiceBot/Commands.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 5db001b..d851b87 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -55,8 +55,9 @@ class BotCommands(): if com not in commands_list.keys(): commands_list[com] = self.dict['commands'][commandstype][com] realcom = command - if "aliasfor" in commands_list[command['com']].keys(): - realcom = commands_list[command['com']]["aliasfor"] + if command in commands_list.keys(): + if "aliasfor" in commands_list[command['com']].keys(): + realcom = commands_list[command['com']]["aliasfor"] return realcom def set_command_disabled(self, bot, command, channel, timestamp, reason, bywhom): From 7e1f71175c7dda53e253c983025e0ae5542be2eb Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 21:41:40 -0400 Subject: [PATCH 066/328] realcom retrieval better --- sopel_modules/SpiceBot/Commands.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index d851b87..9d59d72 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -49,15 +49,10 @@ class BotCommands(): return False def get_realcom(self, command, trigger_command_type): - commands_list = dict() - for commandstype in self.dict['commands'][trigger_command_type].keys(): - for com in self.dict['commands'][commandstype].keys(): - if com not in commands_list.keys(): - commands_list[com] = self.dict['commands'][commandstype][com] - realcom = command - if command in commands_list.keys(): - if "aliasfor" in commands_list[command['com']].keys(): - realcom = commands_list[command['com']]["aliasfor"] + commands_list = list(self.dict['commands'][trigger_command_type].keys()) + if command in commands_list: + if "aliasfor" in self.dict['commands'][trigger_command_type][command].keys(): + realcom = self.dict['commands'][trigger_command_type][command] return realcom def set_command_disabled(self, bot, command, channel, timestamp, reason, bywhom): From 02403a274e30be01a6a8645625addcfdf48cecaa Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 23 May 2019 21:44:40 -0400 Subject: [PATCH 067/328] returb --- sopel_modules/SpiceBot/Commands.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 9d59d72..96ac01b 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -49,6 +49,7 @@ class BotCommands(): return False def get_realcom(self, command, trigger_command_type): + realcom = command commands_list = list(self.dict['commands'][trigger_command_type].keys()) if command in commands_list: if "aliasfor" in self.dict['commands'][trigger_command_type][command].keys(): From 58b2bd14c68a532c9ed9ea5bbb43a0bd1f40870a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 08:06:09 -0400 Subject: [PATCH 068/328] prolly wont work --- sopel_modules/SpiceBot/Prerun.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 8728a55..c240727 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -48,14 +48,17 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: - trigger.sb = copy.deepcopy(argsdict) - trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) - if not trigger.sb["hyphen_arg"]: - # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger): - function(bot, trigger, *args, **kwargs) - else: - self.trigger_hyphen_arg_handler(bot, trigger) + @functools.partial(function) + def internal_split(bot, trigger, *args, **kwargs): + trigger.sb = copy.deepcopy(argsdict) + trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) + if not trigger.sb["hyphen_arg"]: + # check if anything prohibits the nick from running the command + if self.trigger_runstatus(bot, trigger): + function(bot, trigger, *args, **kwargs) + else: + self.trigger_hyphen_arg_handler(bot, trigger) + internal_split(bot, trigger, *args, **kwargs) return internal_prerun return actual_decorator From 19d50a5a12e0591a99ad02ed68fe2604485131b4 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 08:19:37 -0400 Subject: [PATCH 069/328] partial --- sopel_modules/SpiceBot/Prerun.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index c240727..fe0c205 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -48,8 +48,7 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: - @functools.partial(function) - def internal_split(bot, trigger, *args, **kwargs): + def newfunc(bot, trigger, *args, **kwargs): trigger.sb = copy.deepcopy(argsdict) trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) if not trigger.sb["hyphen_arg"]: @@ -58,7 +57,7 @@ class BotPrerun(): function(bot, trigger, *args, **kwargs) else: self.trigger_hyphen_arg_handler(bot, trigger) - internal_split(bot, trigger, *args, **kwargs) + functools.partial(newfunc, bot, trigger, *args, **kwargs) return internal_prerun return actual_decorator From d6054779fc7bc80c8e8aee1f7a528c0f1eb8772b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 08:24:30 -0400 Subject: [PATCH 070/328] test --- sopel_modules/SpiceBot/Prerun.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index fe0c205..2369b52 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -48,9 +48,10 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: + trigger.sb = copy.deepcopy(argsdict) + trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) + def newfunc(bot, trigger, *args, **kwargs): - trigger.sb = copy.deepcopy(argsdict) - trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) if not trigger.sb["hyphen_arg"]: # check if anything prohibits the nick from running the command if self.trigger_runstatus(bot, trigger): From 0183d9cdfa62147b50f6a5bc42a88f530238b4f5 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 08:33:57 -0400 Subject: [PATCH 071/328] maybe? --- sopel_modules/SpiceBot/Prerun.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 2369b52..32e79cd 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -58,7 +58,8 @@ class BotPrerun(): function(bot, trigger, *args, **kwargs) else: self.trigger_hyphen_arg_handler(bot, trigger) - functools.partial(newfunc, bot, trigger, *args, **kwargs) + partiter = functools.partial(newfunc) + partiter(bot, trigger, *args, **kwargs) return internal_prerun return actual_decorator From 2c827a2b7afa9d8c45775c324db2f35f29f595a2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 08:50:23 -0400 Subject: [PATCH 072/328] test --- sopel_modules/SpiceBot/Prerun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 32e79cd..a0e10ed 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -59,7 +59,7 @@ class BotPrerun(): else: self.trigger_hyphen_arg_handler(bot, trigger) partiter = functools.partial(newfunc) - partiter(bot, trigger, *args, **kwargs) + partiter() return internal_prerun return actual_decorator From fab9b4a9780fccdfc79087a8061bc7f8f170db48 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 08:58:48 -0400 Subject: [PATCH 073/328] this might be stupid --- sopel_modules/SpiceBot/Prerun.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index a0e10ed..ee5e3c7 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -22,9 +22,9 @@ class BotPrerun(): def prerun(self, trigger_command_type='module'): def actual_decorator(function): - @functools.wraps(function) - def internal_prerun(bot, trigger, *args, **kwargs): + @functools.wraps(function) + def argsdict_creator(bot, trigger, *args, **kwargs): # Bots can't run commands if Identifier(trigger.nick) == bot.nick: return @@ -45,23 +45,26 @@ class BotPrerun(): # Create dict listings for trigger.sb argsdict_list = self.trigger_argsdict_list(argsdict_default, and_split) + return argsdict_list + + @functools.wraps(function) + def internal_prerun(bot, trigger, argsdict_list=[], *args, **kwargs): # Run the function for all splits for argsdict in argsdict_list: trigger.sb = copy.deepcopy(argsdict) trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) - def newfunc(bot, trigger, *args, **kwargs): - if not trigger.sb["hyphen_arg"]: - # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger): - function(bot, trigger, *args, **kwargs) - else: - self.trigger_hyphen_arg_handler(bot, trigger) - partiter = functools.partial(newfunc) - partiter() + if not trigger.sb["hyphen_arg"]: + # check if anything prohibits the nick from running the command + if self.trigger_runstatus(bot, trigger): + function(bot, trigger, *args, **kwargs) + else: + self.trigger_hyphen_arg_handler(bot, trigger) + + argsdictlist = functools.partial(argsdict_creator)() + functools.partial(internal_prerun)(argsdict_list=argsdictlist) - return internal_prerun return actual_decorator def trigger_args(self, triggerargs_one, trigger_command_type='module'): From 79262479a9c09781474c385f2a705f180980d5df Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 09:12:13 -0400 Subject: [PATCH 074/328] partial that sorta works --- sopel_modules/SpiceBot/Prerun.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index ee5e3c7..48fd2a8 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -22,9 +22,9 @@ class BotPrerun(): def prerun(self, trigger_command_type='module'): def actual_decorator(function): - @functools.wraps(function) - def argsdict_creator(bot, trigger, *args, **kwargs): + def internal_prerun(bot, trigger, *args, **kwargs): + # Bots can't run commands if Identifier(trigger.nick) == bot.nick: return @@ -45,26 +45,22 @@ class BotPrerun(): # Create dict listings for trigger.sb argsdict_list = self.trigger_argsdict_list(argsdict_default, and_split) - return argsdict_list - - @functools.wraps(function) - def internal_prerun(bot, trigger, argsdict_list=[], *args, **kwargs): # Run the function for all splits for argsdict in argsdict_list: trigger.sb = copy.deepcopy(argsdict) trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) - if not trigger.sb["hyphen_arg"]: - # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger): - function(bot, trigger, *args, **kwargs) - else: - self.trigger_hyphen_arg_handler(bot, trigger) - - argsdictlist = functools.partial(argsdict_creator)() - functools.partial(internal_prerun)(argsdict_list=argsdictlist) + def newfunc(bot, trigger, *args, **kwargs): + if not trigger.sb["hyphen_arg"]: + # check if anything prohibits the nick from running the command + if self.trigger_runstatus(bot, trigger): + function(bot, trigger, *args, **kwargs) + else: + self.trigger_hyphen_arg_handler(bot, trigger) + functools.partial(newfunc)(bot, trigger, *args, **kwargs) + return internal_prerun return actual_decorator def trigger_args(self, triggerargs_one, trigger_command_type='module'): From b2066c2c938552dc5052c72b5bcf9e2e0a250bcf Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 09:20:57 -0400 Subject: [PATCH 075/328] mayhaps --- sopel_modules/SpiceBot/Prerun.py | 37 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 48fd2a8..ff1b1ea 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -23,11 +23,7 @@ class BotPrerun(): def prerun(self, trigger_command_type='module'): def actual_decorator(function): @functools.wraps(function) - def internal_prerun(bot, trigger, *args, **kwargs): - - # Bots can't run commands - if Identifier(trigger.nick) == bot.nick: - return + def prerun_gen(bot, trigger, *args, **kwargs): # Primary command used for trigger, and a list of all words trigger_args, trigger_command = self.trigger_args(trigger.args[1], trigger_command_type) @@ -45,22 +41,23 @@ class BotPrerun(): # Create dict listings for trigger.sb argsdict_list = self.trigger_argsdict_list(argsdict_default, and_split) + return argsdict_list - # Run the function for all splits - for argsdict in argsdict_list: + argsdictlist = prerun_gen + # Run the function for all splits + for argsdict in argsdictlist: + + @functools.wraps(function) + def internal_prerun(bot, trigger, *args, **kwargs): trigger.sb = copy.deepcopy(argsdict) trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) - - def newfunc(bot, trigger, *args, **kwargs): - if not trigger.sb["hyphen_arg"]: - # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger): - function(bot, trigger, *args, **kwargs) - else: - self.trigger_hyphen_arg_handler(bot, trigger) - functools.partial(newfunc)(bot, trigger, *args, **kwargs) - - return internal_prerun + if not trigger.sb["hyphen_arg"]: + # check if anything prohibits the nick from running the command + if self.trigger_runstatus(bot, trigger): + function(bot, trigger, *args, **kwargs) + else: + self.trigger_hyphen_arg_handler(bot, trigger) + internal_prerun return actual_decorator def trigger_args(self, triggerargs_one, trigger_command_type='module'): @@ -158,6 +155,10 @@ class BotPrerun(): def trigger_runstatus(self, bot, trigger): + # Bots can't run commands + if Identifier(trigger.nick) == bot.nick: + return False + # don't run commands that are disabled in channels if not trigger.is_privmsg: disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} From af8ee26625bbf647a421a71d3701ebe0d0b0350f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 09:31:34 -0400 Subject: [PATCH 076/328] revert --- sopel_modules/SpiceBot/Prerun.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index ff1b1ea..23c21b1 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -22,8 +22,9 @@ class BotPrerun(): def prerun(self, trigger_command_type='module'): def actual_decorator(function): + @functools.wraps(function) - def prerun_gen(bot, trigger, *args, **kwargs): + def internal_prerun(bot, trigger, *args, **kwargs): # Primary command used for trigger, and a list of all words trigger_args, trigger_command = self.trigger_args(trigger.args[1], trigger_command_type) @@ -41,23 +42,20 @@ class BotPrerun(): # Create dict listings for trigger.sb argsdict_list = self.trigger_argsdict_list(argsdict_default, and_split) - return argsdict_list - argsdictlist = prerun_gen - # Run the function for all splits - for argsdict in argsdictlist: - - @functools.wraps(function) - def internal_prerun(bot, trigger, *args, **kwargs): + # Run the function for all splits + for argsdict in argsdict_list: trigger.sb = copy.deepcopy(argsdict) trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) + if not trigger.sb["hyphen_arg"]: # check if anything prohibits the nick from running the command if self.trigger_runstatus(bot, trigger): function(bot, trigger, *args, **kwargs) else: self.trigger_hyphen_arg_handler(bot, trigger) - internal_prerun + + return internal_prerun return actual_decorator def trigger_args(self, triggerargs_one, trigger_command_type='module'): From 3983666517c429507c1a50020a55b2f51d26dd5b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 10:04:45 -0400 Subject: [PATCH 077/328] prerun without && split --- sopel_modules/SpiceBot/Prerun.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 23c21b1..3a7acf5 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -21,6 +21,27 @@ class BotPrerun(): self.dict = {} def prerun(self, trigger_command_type='module'): + def actual_decorator(function): + + @functools.wraps(function) + def internal_prerun(bot, trigger, *args, **kwargs): + trigger.sb = {} + # Primary command used for trigger, and a list of all words + trigger.sb["args"], trigger.sb["com"] = self.trigger_args(trigger.args[1], trigger_command_type) + trigger.sb["type"] = trigger_command_type + realcom = commands.get_realcom(trigger.sb["com"], trigger_command_type) + trigger.sb["realcom"] = realcom + trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) + if not trigger.sb["hyphen_arg"]: + # check if anything prohibits the nick from running the command + if self.trigger_runstatus(bot, trigger): + function(bot, trigger, *args, **kwargs) + else: + self.trigger_hyphen_arg_handler(bot, trigger) + return internal_prerun + return actual_decorator + + def prerun_old(self, trigger_command_type='module'): def actual_decorator(function): @functools.wraps(function) @@ -46,14 +67,7 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: trigger.sb = copy.deepcopy(argsdict) - trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) - - if not trigger.sb["hyphen_arg"]: - # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger): - function(bot, trigger, *args, **kwargs) - else: - self.trigger_hyphen_arg_handler(bot, trigger) + function(bot, trigger, *args, **kwargs) return internal_prerun return actual_decorator From 484b2508247ad3b69091f9699c83533e4ec62611 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 10:13:47 -0400 Subject: [PATCH 078/328] no hyphenargs --- sopel_modules/SpiceBot/Prerun.py | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 3a7acf5..f164949 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -21,27 +21,6 @@ class BotPrerun(): self.dict = {} def prerun(self, trigger_command_type='module'): - def actual_decorator(function): - - @functools.wraps(function) - def internal_prerun(bot, trigger, *args, **kwargs): - trigger.sb = {} - # Primary command used for trigger, and a list of all words - trigger.sb["args"], trigger.sb["com"] = self.trigger_args(trigger.args[1], trigger_command_type) - trigger.sb["type"] = trigger_command_type - realcom = commands.get_realcom(trigger.sb["com"], trigger_command_type) - trigger.sb["realcom"] = realcom - trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) - if not trigger.sb["hyphen_arg"]: - # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger): - function(bot, trigger, *args, **kwargs) - else: - self.trigger_hyphen_arg_handler(bot, trigger) - return internal_prerun - return actual_decorator - - def prerun_old(self, trigger_command_type='module'): def actual_decorator(function): @functools.wraps(function) @@ -67,7 +46,10 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: trigger.sb = copy.deepcopy(argsdict) - function(bot, trigger, *args, **kwargs) + + # check if anything prohibits the nick from running the command + if self.trigger_runstatus(bot, trigger): + function(bot, trigger, *args, **kwargs) return internal_prerun return actual_decorator From 2b78d9a829bf587c847d25170253713ad39565b3 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 10:16:52 -0400 Subject: [PATCH 079/328] no hyphenargs --- sopel_modules/SpiceBot/Prerun.py | 108 +++++++++++++++++++------------ 1 file changed, 65 insertions(+), 43 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 3a7acf5..7255d44 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -21,27 +21,6 @@ class BotPrerun(): self.dict = {} def prerun(self, trigger_command_type='module'): - def actual_decorator(function): - - @functools.wraps(function) - def internal_prerun(bot, trigger, *args, **kwargs): - trigger.sb = {} - # Primary command used for trigger, and a list of all words - trigger.sb["args"], trigger.sb["com"] = self.trigger_args(trigger.args[1], trigger_command_type) - trigger.sb["type"] = trigger_command_type - realcom = commands.get_realcom(trigger.sb["com"], trigger_command_type) - trigger.sb["realcom"] = realcom - trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) - if not trigger.sb["hyphen_arg"]: - # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger): - function(bot, trigger, *args, **kwargs) - else: - self.trigger_hyphen_arg_handler(bot, trigger) - return internal_prerun - return actual_decorator - - def prerun_old(self, trigger_command_type='module'): def actual_decorator(function): @functools.wraps(function) @@ -67,7 +46,10 @@ class BotPrerun(): # Run the function for all splits for argsdict in argsdict_list: trigger.sb = copy.deepcopy(argsdict) - function(bot, trigger, *args, **kwargs) + + # check if anything prohibits the nick from running the command + if self.trigger_runstatus(bot, trigger): + function(bot, trigger, *args, **kwargs) return internal_prerun return actual_decorator @@ -96,6 +78,67 @@ class BotPrerun(): prerun_split.append(argsdict_part) return prerun_split + def trigger_runstatus(self, bot, trigger): + + # Bots can't run commands + if Identifier(trigger.nick) == bot.nick: + return False + + # don't run commands that are disabled in channels + if not trigger.is_privmsg: + disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} + if trigger.sb["realcom"] in disabled_list.keys(): + reason = disabled_list[trigger.sb["realcom"]]["reason"] + timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"] + bywhom = disabled_list[trigger.sb["realcom"]]["disabledby"] + bot.notice("The " + str(trigger.sb["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason), trigger.nick) + return False + + return True + + +prerun = BotPrerun() + + +class defunct(): + def prerun(self, trigger_command_type='module'): + def actual_decorator(function): + + @functools.wraps(function) + def internal_prerun(bot, trigger, *args, **kwargs): + + # Primary command used for trigger, and a list of all words + trigger_args, trigger_command = self.trigger_args(trigger.args[1], trigger_command_type) + + # Argsdict Defaults + argsdict_default = {} + argsdict_default["type"] = trigger_command_type + argsdict_default["com"] = trigger_command + + realcom = commands.get_realcom(argsdict_default["com"], trigger_command_type) + argsdict_default["realcom"] = realcom + + # split into && groupings + and_split = self.trigger_and_split(trigger_args) + + # Create dict listings for trigger.sb + argsdict_list = self.trigger_argsdict_list(argsdict_default, and_split) + + # Run the function for all splits + for argsdict in argsdict_list: + trigger.sb = copy.deepcopy(argsdict) + trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) + + if not trigger.sb["hyphen_arg"]: + # check if anything prohibits the nick from running the command + if self.trigger_runstatus(bot, trigger): + function(bot, trigger, *args, **kwargs) + else: + self.trigger_hyphen_arg_handler(bot, trigger) + + return internal_prerun + return actual_decorator + def trigger_hyphen_args(self, trigger_args_part): valid_hyphen_args = [ 'check', @@ -164,24 +207,3 @@ class BotPrerun(): return return - - def trigger_runstatus(self, bot, trigger): - - # Bots can't run commands - if Identifier(trigger.nick) == bot.nick: - return False - - # don't run commands that are disabled in channels - if not trigger.is_privmsg: - disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} - if trigger.sb["realcom"] in disabled_list.keys(): - reason = disabled_list[trigger.sb["realcom"]]["reason"] - timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"] - bywhom = disabled_list[trigger.sb["realcom"]]["disabledby"] - bot.notice("The " + str(trigger.sb["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason), trigger.nick) - return False - - return True - - -prerun = BotPrerun() From 3ed588c756a3c7b3a5d861d813bef9751139c289 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 10:25:26 -0400 Subject: [PATCH 080/328] test --- sopel_modules/SpiceBot/Prerun.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 7255d44..b14d98b 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -20,6 +20,15 @@ class BotPrerun(): def __init__(self): self.dict = {} + def hyphenargs(self, trigger_command_type='module'): + def actual_decorator(function): + @functools.wraps(function) + def internal_prerun(bot, trigger, *args, **kwargs): + bot.say("here") + return function(bot, trigger, *args, **kwargs) + return internal_prerun + return actual_decorator + def prerun(self, trigger_command_type='module'): def actual_decorator(function): From c1538ea787a2ead01bc259ca1c092adcc21acfbd Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 10:25:41 -0400 Subject: [PATCH 081/328] test --- sopel_modules/SpiceBot/Prerun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index b14d98b..40fef41 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -20,7 +20,7 @@ class BotPrerun(): def __init__(self): self.dict = {} - def hyphenargs(self, trigger_command_type='module'): + def hyphenargs(self): def actual_decorator(function): @functools.wraps(function) def internal_prerun(bot, trigger, *args, **kwargs): From 18fa151bec4461387022b126f17cc4da4cabca89 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 10:43:46 -0400 Subject: [PATCH 082/328] test new hyphen args logic --- sopel_modules/SpiceBot/Prerun.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 40fef41..d40bb8d 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -24,8 +24,13 @@ class BotPrerun(): def actual_decorator(function): @functools.wraps(function) def internal_prerun(bot, trigger, *args, **kwargs): - bot.say("here") - return function(bot, trigger, *args, **kwargs) + trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) + if not trigger.sb["hyphen_arg"]: + # check if anything prohibits the nick from running the command + if self.trigger_runstatus(bot, trigger): + return function(bot, trigger, *args, **kwargs) + else: + return self.trigger_hyphen_arg_handler(bot, trigger) return internal_prerun return actual_decorator From 2ab6b0f287b9135c0b272ba401e76912f262f495 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 11:30:10 -0400 Subject: [PATCH 083/328] really? --- sopel_modules/SpiceBot/Prerun.py | 99 +++++++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 13 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index d40bb8d..0ed7a77 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -20,19 +20,7 @@ class BotPrerun(): def __init__(self): self.dict = {} - def hyphenargs(self): - def actual_decorator(function): - @functools.wraps(function) - def internal_prerun(bot, trigger, *args, **kwargs): - trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) - if not trigger.sb["hyphen_arg"]: - # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger): - return function(bot, trigger, *args, **kwargs) - else: - return self.trigger_hyphen_arg_handler(bot, trigger) - return internal_prerun - return actual_decorator + """Command Splitting""" def prerun(self, trigger_command_type='module'): def actual_decorator(function): @@ -110,6 +98,91 @@ class BotPrerun(): return True + """Hyphenargs""" + + def hyphenargs(self): + def actual_decorator(function): + @functools.wraps(function) + def internal_prerun(bot, trigger, *args, **kwargs): + trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) + if not trigger.sb["hyphen_arg"]: + # check if anything prohibits the nick from running the command + if self.trigger_runstatus(bot, trigger): + return function(bot, trigger, *args, **kwargs) + else: + return self.trigger_hyphen_arg_handler(bot, trigger) + return internal_prerun + return actual_decorator + + def trigger_hyphen_args(self, trigger_args_part): + valid_hyphen_args = [ + 'check', + 'enable', 'disable' + ] + hyphen_args = [] + trigger_args_unhyphend = [] + for worditem in trigger_args_part: + if str(worditem).startswith("--") and worditem[2:] in valid_hyphen_args: + hyphen_args.append(worditem[2:]) + else: + trigger_args_unhyphend.append(worditem) + if len(hyphen_args): + hyphenarg = hyphen_args[0] + else: + hyphenarg = None + return trigger_args_unhyphend, hyphenarg + + def trigger_hyphen_arg_handler(self, bot, trigger): + + # Commands that cannot run via privmsg + if trigger.sb["hyphen_arg"] in ['check']: + if trigger.sb["com"].lower() != trigger.sb["realcom"]: + bot.say(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"]) + else: + bot.say(trigger.sb["com"] + " is a valid command") + return + + elif trigger.sb["hyphen_arg"] in ['enable']: + + if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + bot.say("I was unable to disable this command due to privilege issues.") + return + + if trigger.is_privmsg: + bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick) + return + + if not commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): + bot.notice(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick) + return + + commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender) + bot.say(trigger.sb["com"] + " is now enabled in " + str(trigger.sender)) + return + + elif trigger.sb["hyphen_arg"] in ['disable']: + + if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + bot.say("I was unable to disable this command due to privilege issues.") + return + + if trigger.is_privmsg: + bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick) + return + + if commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): + bot.notice(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick) + return + + trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given." + timestamp = str(datetime.datetime.utcnow()) + + commands.set_command_disabled(bot, trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) + bot.say(trigger.sb["com"] + " is now disabled in " + str(trigger.sender)) + return + + return + prerun = BotPrerun() From a0216e81fb2ebe905e16ff1fa39f371c4165c6ed Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 11:34:45 -0400 Subject: [PATCH 084/328] bad paste tabbing --- sopel_modules/SpiceBot/Prerun.py | 156 +++++++++++++++---------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 0ed7a77..9f2f4f1 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -98,91 +98,91 @@ class BotPrerun(): return True - """Hyphenargs""" + """Hyphenargs""" - def hyphenargs(self): - def actual_decorator(function): - @functools.wraps(function) - def internal_prerun(bot, trigger, *args, **kwargs): - trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) - if not trigger.sb["hyphen_arg"]: - # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger): - return function(bot, trigger, *args, **kwargs) - else: - return self.trigger_hyphen_arg_handler(bot, trigger) - return internal_prerun - return actual_decorator - - def trigger_hyphen_args(self, trigger_args_part): - valid_hyphen_args = [ - 'check', - 'enable', 'disable' - ] - hyphen_args = [] - trigger_args_unhyphend = [] - for worditem in trigger_args_part: - if str(worditem).startswith("--") and worditem[2:] in valid_hyphen_args: - hyphen_args.append(worditem[2:]) + def hyphenargs(self): + def actual_decorator(function): + @functools.wraps(function) + def internal_prerun(bot, trigger, *args, **kwargs): + trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) + if not trigger.sb["hyphen_arg"]: + # check if anything prohibits the nick from running the command + if self.trigger_runstatus(bot, trigger): + return function(bot, trigger, *args, **kwargs) else: - trigger_args_unhyphend.append(worditem) - if len(hyphen_args): - hyphenarg = hyphen_args[0] + return self.trigger_hyphen_arg_handler(bot, trigger) + return internal_prerun + return actual_decorator + + def trigger_hyphen_args(self, trigger_args_part): + valid_hyphen_args = [ + 'check', + 'enable', 'disable' + ] + hyphen_args = [] + trigger_args_unhyphend = [] + for worditem in trigger_args_part: + if str(worditem).startswith("--") and worditem[2:] in valid_hyphen_args: + hyphen_args.append(worditem[2:]) else: - hyphenarg = None - return trigger_args_unhyphend, hyphenarg + trigger_args_unhyphend.append(worditem) + if len(hyphen_args): + hyphenarg = hyphen_args[0] + else: + hyphenarg = None + return trigger_args_unhyphend, hyphenarg - def trigger_hyphen_arg_handler(self, bot, trigger): - - # Commands that cannot run via privmsg - if trigger.sb["hyphen_arg"] in ['check']: - if trigger.sb["com"].lower() != trigger.sb["realcom"]: - bot.say(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"]) - else: - bot.say(trigger.sb["com"] + " is a valid command") - return - - elif trigger.sb["hyphen_arg"] in ['enable']: - - if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): - bot.say("I was unable to disable this command due to privilege issues.") - return - - if trigger.is_privmsg: - bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick) - return - - if not commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): - bot.notice(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick) - return - - commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender) - bot.say(trigger.sb["com"] + " is now enabled in " + str(trigger.sender)) - return - - elif trigger.sb["hyphen_arg"] in ['disable']: - - if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): - bot.say("I was unable to disable this command due to privilege issues.") - return - - if trigger.is_privmsg: - bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick) - return - - if commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): - bot.notice(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick) - return - - trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given." - timestamp = str(datetime.datetime.utcnow()) - - commands.set_command_disabled(bot, trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) - bot.say(trigger.sb["com"] + " is now disabled in " + str(trigger.sender)) - return + def trigger_hyphen_arg_handler(self, bot, trigger): + # Commands that cannot run via privmsg + if trigger.sb["hyphen_arg"] in ['check']: + if trigger.sb["com"].lower() != trigger.sb["realcom"]: + bot.say(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"]) + else: + bot.say(trigger.sb["com"] + " is a valid command") return + elif trigger.sb["hyphen_arg"] in ['enable']: + + if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + bot.say("I was unable to disable this command due to privilege issues.") + return + + if trigger.is_privmsg: + bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick) + return + + if not commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): + bot.notice(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick) + return + + commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender) + bot.say(trigger.sb["com"] + " is now enabled in " + str(trigger.sender)) + return + + elif trigger.sb["hyphen_arg"] in ['disable']: + + if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + bot.say("I was unable to disable this command due to privilege issues.") + return + + if trigger.is_privmsg: + bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick) + return + + if commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): + bot.notice(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick) + return + + trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given." + timestamp = str(datetime.datetime.utcnow()) + + commands.set_command_disabled(bot, trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) + bot.say(trigger.sb["com"] + " is now disabled in " + str(trigger.sender)) + return + + return + prerun = BotPrerun() From bb261643722660f8ff6e67ff5b9c826c3e180181 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 11:56:53 -0400 Subject: [PATCH 085/328] -a admin switch --- sopel_modules/SpiceBot/Prerun.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 9f2f4f1..bcf28bf 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -77,6 +77,11 @@ class BotPrerun(): for trigger_args_part in and_split: argsdict_part = copy.deepcopy(argsdict_default) argsdict_part["args"] = spicemanip.main(trigger_args_part, 'create') + if len(argsdict_part["args"]) and argsdict_part["args"][0] == "-a": + argsdict_part["adminswitch"] = True + argsdict_part["args"] = spicemanip.main(argsdict_part["args"], '2+', 'list') + else: + argsdict_part["adminswitch"] = False prerun_split.append(argsdict_part) return prerun_split @@ -86,6 +91,14 @@ class BotPrerun(): if Identifier(trigger.nick) == bot.nick: return False + # Allow permissions for enabling and disabling commands via hyphenargs + if trigger.sb["adminswitch"]: + if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + return True + else: + bot.notice("The admin switch (-a) is for use by authorized nicks ONLY.") + return False + # don't run commands that are disabled in channels if not trigger.is_privmsg: disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} @@ -93,11 +106,17 @@ class BotPrerun(): reason = disabled_list[trigger.sb["realcom"]]["reason"] timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"] bywhom = disabled_list[trigger.sb["realcom"]]["disabledby"] - bot.notice("The " + str(trigger.sb["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason), trigger.nick) - return False + return self.trigger_cant_run(bot, trigger, "The " + str(trigger.sb["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)) return True + def trigger_cant_run(bot, trigger, message=None): + if message: + bot.notice(message, trigger.nick) + if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + bot.notice("You however are authorized to bypass this warning with the (-a) admin switch.", trigger.nick) + return False + """Hyphenargs""" def hyphenargs(self): From 63856bc1193005d7011d6c5cbca035690af73cc7 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 12:01:49 -0400 Subject: [PATCH 086/328] self --- sopel_modules/SpiceBot/Prerun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index bcf28bf..15807c5 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -110,7 +110,7 @@ class BotPrerun(): return True - def trigger_cant_run(bot, trigger, message=None): + def trigger_cant_run(self, bot, trigger, message=None): if message: bot.notice(message, trigger.nick) if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): From 2968649e16caf9415906e88eb6ffadd99e0c3c7a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 12:13:48 -0400 Subject: [PATCH 087/328] test this logic --- sopel_modules/SpiceBot/Prerun.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 15807c5..3ed5bca 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -106,11 +106,14 @@ class BotPrerun(): reason = disabled_list[trigger.sb["realcom"]]["reason"] timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"] bywhom = disabled_list[trigger.sb["realcom"]]["disabledby"] - return self.trigger_cant_run(bot, trigger, "The " + str(trigger.sb["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)) + bot.notice("The " + str(trigger.sb["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason), trigger.nick) + if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + bot.notice("You however are authorized to bypass this warning with the (-a) admin switch.", trigger.nick) + return False return True - def trigger_cant_run(self, bot, trigger, message=None): + def trigger_cant_run(bot, trigger, message=None): if message: bot.notice(message, trigger.nick) if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): From c679476c1273358ef44c97fc5b55918bc32a8606 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 12:21:12 -0400 Subject: [PATCH 088/328] remove double check --- sopel_modules/SpiceBot/Prerun.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 3ed5bca..dfaf1b8 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -106,14 +106,12 @@ class BotPrerun(): reason = disabled_list[trigger.sb["realcom"]]["reason"] timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"] bywhom = disabled_list[trigger.sb["realcom"]]["disabledby"] - bot.notice("The " + str(trigger.sb["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason), trigger.nick) - if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): - bot.notice("You however are authorized to bypass this warning with the (-a) admin switch.", trigger.nick) - return False + message = "The " + str(trigger.sb["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) + return self.trigger_cant_run(bot, trigger, message) return True - def trigger_cant_run(bot, trigger, message=None): + def trigger_cant_run(self, bot, trigger, message=None): if message: bot.notice(message, trigger.nick) if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): @@ -128,9 +126,7 @@ class BotPrerun(): def internal_prerun(bot, trigger, *args, **kwargs): trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) if not trigger.sb["hyphen_arg"]: - # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger): - return function(bot, trigger, *args, **kwargs) + return function(bot, trigger, *args, **kwargs) else: return self.trigger_hyphen_arg_handler(bot, trigger) return internal_prerun From d06342d96f2490fb581ab57f307e176d6a181837 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 24 May 2019 13:20:39 -0400 Subject: [PATCH 089/328] owner test --- sopel_modules/SpiceBot/Prerun.py | 123 ++++--------------------------- 1 file changed, 14 insertions(+), 109 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index dfaf1b8..ed7c2c0 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -118,6 +118,11 @@ class BotPrerun(): bot.notice("You however are authorized to bypass this warning with the (-a) admin switch.", trigger.nick) return False + +prerun = BotPrerun() + + +class defunct(): """Hyphenargs""" def hyphenargs(self): @@ -202,113 +207,13 @@ class BotPrerun(): return -prerun = BotPrerun() - - -class defunct(): - def prerun(self, trigger_command_type='module'): - def actual_decorator(function): - - @functools.wraps(function) - def internal_prerun(bot, trigger, *args, **kwargs): - - # Primary command used for trigger, and a list of all words - trigger_args, trigger_command = self.trigger_args(trigger.args[1], trigger_command_type) - - # Argsdict Defaults - argsdict_default = {} - argsdict_default["type"] = trigger_command_type - argsdict_default["com"] = trigger_command - - realcom = commands.get_realcom(argsdict_default["com"], trigger_command_type) - argsdict_default["realcom"] = realcom - - # split into && groupings - and_split = self.trigger_and_split(trigger_args) - - # Create dict listings for trigger.sb - argsdict_list = self.trigger_argsdict_list(argsdict_default, and_split) - - # Run the function for all splits - for argsdict in argsdict_list: - trigger.sb = copy.deepcopy(argsdict) - trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) - - if not trigger.sb["hyphen_arg"]: - # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger): - function(bot, trigger, *args, **kwargs) - else: - self.trigger_hyphen_arg_handler(bot, trigger) - - return internal_prerun - return actual_decorator - - def trigger_hyphen_args(self, trigger_args_part): - valid_hyphen_args = [ - 'check', - 'enable', 'disable' - ] - hyphen_args = [] - trigger_args_unhyphend = [] - for worditem in trigger_args_part: - if str(worditem).startswith("--") and worditem[2:] in valid_hyphen_args: - hyphen_args.append(worditem[2:]) +def require_owner(): + def actual_decorator(function): + @functools.wraps(function) + def guarded(bot, trigger, *args, **kwargs): + if not trigger.owner: + bot.say(trigger.nick + " is not the owner") else: - trigger_args_unhyphend.append(worditem) - if len(hyphen_args): - hyphenarg = hyphen_args[0] - else: - hyphenarg = None - return trigger_args_unhyphend, hyphenarg - - def trigger_hyphen_arg_handler(self, bot, trigger): - - # Commands that cannot run via privmsg - if trigger.sb["hyphen_arg"] in ['check']: - if trigger.sb["com"].lower() != trigger.sb["realcom"]: - bot.say(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"]) - else: - bot.say(trigger.sb["com"] + " is a valid command") - return - - elif trigger.sb["hyphen_arg"] in ['enable']: - - if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): - bot.say("I was unable to disable this command due to privilege issues.") - return - - if trigger.is_privmsg: - bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick) - return - - if not commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): - bot.notice(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick) - return - - commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender) - bot.say(trigger.sb["com"] + " is now enabled in " + str(trigger.sender)) - return - - elif trigger.sb["hyphen_arg"] in ['disable']: - - if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): - bot.say("I was unable to disable this command due to privilege issues.") - return - - if trigger.is_privmsg: - bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick) - return - - if commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): - bot.notice(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick) - return - - trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given." - timestamp = str(datetime.datetime.utcnow()) - - commands.set_command_disabled(bot, trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) - bot.say(trigger.sb["com"] + " is now disabled in " + str(trigger.sender)) - return - - return + return function(bot, trigger, *args, **kwargs) + return guarded + return actual_decorator From bd4aebfd43e41c46ca7f8d7ea4949e278238a006 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 26 May 2019 14:11:16 -0400 Subject: [PATCH 090/328] more testing,, garrr --- sopel_modules/SpiceBot/Prerun.py | 79 ++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index ed7c2c0..21e7f43 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -49,9 +49,13 @@ class BotPrerun(): for argsdict in argsdict_list: trigger.sb = copy.deepcopy(argsdict) - # check if anything prohibits the nick from running the command - if self.trigger_runstatus(bot, trigger): - function(bot, trigger, *args, **kwargs) + trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) + if not trigger.sb["hyphen_arg"]: + # check if anything prohibits the nick from running the command + if self.trigger_runstatus(bot, trigger): + function(bot, trigger, *args, **kwargs) + else: + self.trigger_hyphen_arg_handler(bot, trigger) return internal_prerun return actual_decorator @@ -118,6 +122,75 @@ class BotPrerun(): bot.notice("You however are authorized to bypass this warning with the (-a) admin switch.", trigger.nick) return False + def trigger_hyphen_args(self, trigger_args_part): + valid_hyphen_args = [ + 'check', + 'enable', 'disable' + ] + hyphen_args = [] + trigger_args_unhyphend = [] + for worditem in trigger_args_part: + if str(worditem).startswith("--") and worditem[2:] in valid_hyphen_args: + hyphen_args.append(worditem[2:]) + else: + trigger_args_unhyphend.append(worditem) + if len(hyphen_args): + hyphenarg = hyphen_args[0] + else: + hyphenarg = None + return trigger_args_unhyphend, hyphenarg + + def trigger_hyphen_arg_handler(self, bot, trigger): + + # Commands that cannot run via privmsg + if trigger.sb["hyphen_arg"] in ['check']: + if trigger.sb["com"].lower() != trigger.sb["realcom"]: + bot.say(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"]) + else: + bot.say(trigger.sb["com"] + " is a valid command") + return + + elif trigger.sb["hyphen_arg"] in ['enable']: + + if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + bot.say("I was unable to disable this command due to privilege issues.") + return + + if trigger.is_privmsg: + bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick) + return + + if not commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): + bot.notice(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick) + return + + commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender) + bot.say(trigger.sb["com"] + " is now enabled in " + str(trigger.sender)) + return + + elif trigger.sb["hyphen_arg"] in ['disable']: + + if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + bot.say("I was unable to disable this command due to privilege issues.") + return + + if trigger.is_privmsg: + bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick) + return + + if commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): + bot.notice(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick) + return + + trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given." + timestamp = str(datetime.datetime.utcnow()) + + commands.set_command_disabled(bot, trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) + bot.say(trigger.sb["com"] + " is now disabled in " + str(trigger.sender)) + return + + return + prerun = BotPrerun() From 95d6a33194d10830a633c6f4e833443fa6381d4a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 26 May 2019 14:33:04 -0400 Subject: [PATCH 091/328] add return line --- sopel_modules/SpiceBot/Prerun.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 21e7f43..0fbf133 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -56,6 +56,7 @@ class BotPrerun(): function(bot, trigger, *args, **kwargs) else: self.trigger_hyphen_arg_handler(bot, trigger) + return return internal_prerun return actual_decorator From d55c97a1980d7e31df5469c577abd0dc5192ac69 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 28 May 2019 09:02:29 -0400 Subject: [PATCH 092/328] error handling --- sopel_modules/SpiceBot/Commands.py | 14 +++-- sopel_modules/SpiceBot/Prerun.py | 97 ------------------------------ 2 files changed, 10 insertions(+), 101 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 96ac01b..ba8a456 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -50,10 +50,16 @@ class BotCommands(): def get_realcom(self, command, trigger_command_type): realcom = command - commands_list = list(self.dict['commands'][trigger_command_type].keys()) - if command in commands_list: - if "aliasfor" in self.dict['commands'][trigger_command_type][command].keys(): - realcom = self.dict['commands'][trigger_command_type][command] + + if trigger_command_type not in self.dict['commands'].keys(): + return realcom + + if command not in self.dict['commands'][trigger_command_type].keys(): + return realcom + + if "aliasfor" in self.dict['commands'][trigger_command_type][command].keys(): + realcom = self.dict['commands'][trigger_command_type][command] + return realcom def set_command_disabled(self, bot, command, channel, timestamp, reason, bywhom): diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 0fbf133..8cea340 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -194,100 +194,3 @@ class BotPrerun(): prerun = BotPrerun() - - -class defunct(): - """Hyphenargs""" - - def hyphenargs(self): - def actual_decorator(function): - @functools.wraps(function) - def internal_prerun(bot, trigger, *args, **kwargs): - trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"]) - if not trigger.sb["hyphen_arg"]: - return function(bot, trigger, *args, **kwargs) - else: - return self.trigger_hyphen_arg_handler(bot, trigger) - return internal_prerun - return actual_decorator - - def trigger_hyphen_args(self, trigger_args_part): - valid_hyphen_args = [ - 'check', - 'enable', 'disable' - ] - hyphen_args = [] - trigger_args_unhyphend = [] - for worditem in trigger_args_part: - if str(worditem).startswith("--") and worditem[2:] in valid_hyphen_args: - hyphen_args.append(worditem[2:]) - else: - trigger_args_unhyphend.append(worditem) - if len(hyphen_args): - hyphenarg = hyphen_args[0] - else: - hyphenarg = None - return trigger_args_unhyphend, hyphenarg - - def trigger_hyphen_arg_handler(self, bot, trigger): - - # Commands that cannot run via privmsg - if trigger.sb["hyphen_arg"] in ['check']: - if trigger.sb["com"].lower() != trigger.sb["realcom"]: - bot.say(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"]) - else: - bot.say(trigger.sb["com"] + " is a valid command") - return - - elif trigger.sb["hyphen_arg"] in ['enable']: - - if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): - bot.say("I was unable to disable this command due to privilege issues.") - return - - if trigger.is_privmsg: - bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick) - return - - if not commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): - bot.notice(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick) - return - - commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender) - bot.say(trigger.sb["com"] + " is now enabled in " + str(trigger.sender)) - return - - elif trigger.sb["hyphen_arg"] in ['disable']: - - if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): - bot.say("I was unable to disable this command due to privilege issues.") - return - - if trigger.is_privmsg: - bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick) - return - - if commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): - bot.notice(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick) - return - - trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given." - timestamp = str(datetime.datetime.utcnow()) - - commands.set_command_disabled(bot, trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) - bot.say(trigger.sb["com"] + " is now disabled in " + str(trigger.sender)) - return - - return - - -def require_owner(): - def actual_decorator(function): - @functools.wraps(function) - def guarded(bot, trigger, *args, **kwargs): - if not trigger.owner: - bot.say(trigger.nick + " is not the owner") - else: - return function(bot, trigger, *args, **kwargs) - return guarded - return actual_decorator From 8e5df0d5d75f44697c69f053ea4133911fa432ff Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 06:33:30 -0400 Subject: [PATCH 093/328] database updates --- .../Databaseaddons.py | 127 +++++++++++++++++- 1 file changed, 120 insertions(+), 7 deletions(-) diff --git a/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py b/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py index fe360d3..8cf4cb7 100644 --- a/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py +++ b/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py @@ -5,25 +5,49 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi # sopel imports import sopel.module from sopel.tools import Identifier -from sopel.db import SopelDB, NickValues, ChannelValues +import sopel.db +from sopel.db import SopelDB, NickValues, ChannelValues, _deserialize +from sqlalchemy import Column, String from sqlalchemy.exc import SQLAlchemyError +from sqlalchemy.ext.declarative import declarative_base import json import sopel_modules.SpiceBot as SpiceBot +BASE = declarative_base() + def setup(bot): # Inject Database Functions SpiceBot.logs.log('SpiceBot_Databaseaddons', "Implanting Database functions into bot") - SopelDB.delete_nick_value = SopelDBCache.delete_nick_value - SopelDB.adjust_nick_value = SopelDBCache.adjust_nick_value - SopelDB.delete_channel_value = SopelDBCache.delete_channel_value - SopelDB.adjust_channel_value = SopelDBCache.adjust_channel_value + sopel.db.PluginValues = PluginValues + + SopelDB.delete_nick_value = SopelDBAddon.delete_nick_value + SopelDB.adjust_nick_value = SopelDBAddon.adjust_nick_value + + SopelDB.delete_channel_value = SopelDBAddon.delete_channel_value + SopelDB.adjust_channel_value = SopelDBAddon.adjust_channel_value + + SopelDB.adjust_plugin_value = SopelDBAddon.adjust_plugin_value + SopelDB.delete_plugin_value = SopelDBAddon.delete_plugin_value + SopelDB.get_plugin_value = SopelDBAddon.get_plugin_value + SopelDB.set_plugin_value = SopelDBAddon.set_plugin_value -class SopelDBCache: +# TODO use this as a template for dynamic tablenames +class PluginValues(BASE): + """ + PluginValues SQLAlchemy Class + """ + __tablename__ = 'plugin_values' + plugin = Column(String(255), primary_key=True) + key = Column(String(255), primary_key=True) + value = Column(String(255)) + + +class SopelDBAddon: """Nicks""" @@ -84,7 +108,7 @@ class SopelDBCache: .filter(ChannelValues.channel == channel)\ .filter(ChannelValues.key == key) \ .one_or_none() - # ChannelValue exists, update + # ChannelValue exists, delete if result: session.delete(result) session.commit() @@ -118,3 +142,92 @@ class SopelDBCache: raise finally: session.close() + + # PLUGIN FUNCTIONS + + def set_plugin_value(self, plugin, key, value): + """Sets the value for a given key to be associated with the plugin.""" + plugin = Identifier(plugin).lower() + value = json.dumps(value, ensure_ascii=False) + session = self.ssession() + try: + result = session.query(PluginValues) \ + .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.key == key) \ + .one_or_none() + # PluginValues exists, update + if result: + result.value = value + session.commit() + # DNE - Insert + else: + new_pluginvalue = PluginValues(plugin=plugin, key=key, value=value) + session.add(new_pluginvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def get_plugin_value(self, plugin, key): + """Retrieves the value for a given key associated with a plugin.""" + plugin = Identifier(plugin).lower() + session = self.ssession() + try: + result = session.query(PluginValues) \ + .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.key == key) \ + .one_or_none() + if result is not None: + result = result.value + return _deserialize(result) + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def adjust_plugin_value(self, plugin, key, value): + """Sets the value for a given key to be associated with the plugin.""" + plugin = Identifier(plugin).lower() + value = json.dumps(value, ensure_ascii=False) + session = self.ssession() + try: + result = session.query(PluginValues) \ + .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.key == key) \ + .one_or_none() + # ChannelValue exists, update + if result: + result.value = result.value + value + session.commit() + # DNE - Insert + else: + new_pluginvalue = PluginValues(plugin=plugin, key=key, value=value) + session.add(new_pluginvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def delete_plugin_value(self, plugin, key): + """Deletes the value for a given key to be associated with the plugin.""" + plugin = Identifier(plugin).lower() + session = self.ssession() + try: + result = session.query(PluginValues) \ + .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.key == key) \ + .one_or_none() + # PluginValues exists, delete + if result: + session.delete(result) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() From 9f2446b5c99f822acce8853bfa359b1910004e9f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 09:39:59 -0400 Subject: [PATCH 094/328] Add a way to read the bot's config without the bot --- sopel_modules/SpiceBot/Config.py | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 sopel_modules/SpiceBot/Config.py diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py new file mode 100644 index 0000000..9c35d9d --- /dev/null +++ b/sopel_modules/SpiceBot/Config.py @@ -0,0 +1,41 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +"""A way to read the bot's config without bot""" + +from sopel.cli.run import build_parser, get_configuration + +import sys +import configparser + + +class BotConfig(): + + def __init__(self): + self.dict = {} + self.config = self.load_config() + self.config_dict = self.config_file_to_dict() + + def load_config(self): + if len(sys.argv[1:]): + argv = [] + else: + argv = sys.argv[1:] + parser = build_parser() + opts = parser.parse_args(argv) + config_module = get_configuration(opts) + return config_module + + def config_file_to_dict(self): + configdict = dict() + config = configparser.ConfigParser() + config.read(self.config.filename) + for each_section in config.sections(): + if each_section not in configdict.keys(): + configdict[each_section] = dict() + for (each_key, each_val) in config.items(each_section): + if each_key not in configdict[each_section].keys(): + configdict[each_section][each_key] = each_val + return configdict + + +db = BotConfig() From 52cd26e8b1ca2dd76dbbacf98b16cda221dd0756 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 09:50:02 -0400 Subject: [PATCH 095/328] init --- sopel_modules/SpiceBot/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index f2496fc..93f67c6 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -6,6 +6,7 @@ These are the core SpiceBot Classes This module contains references only for other modules to utilize. """ +from .Config import * from .Tools import * from .Logs import * from .Commands import * From 2e518d3343edd07a72c1bd3c7953cb3303965ff0 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 09:55:16 -0400 Subject: [PATCH 096/328] changes --- sopel_modules/SpiceBot/Commands.py | 12 ++++++------ sopel_modules/SpiceBot/Config.py | 2 +- sopel_modules/SpiceBot/Database.py | 3 ++- sopel_modules/SpiceBot/Events.py | 4 ++++ sopel_modules/SpiceBot/Prerun.py | 4 ++-- .../SpiceBot_Database_Addons/Databaseaddons.py | 5 ++--- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index ba8a456..368e80c 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -12,7 +12,7 @@ import threading import spicemanip from .Logs import logs -from .Database import db as spicedb +from .Database import botdb class BotCommands(): @@ -39,7 +39,7 @@ class BotCommands(): def get_disabled_commands(self, bot, channel): if not len(list(self.dict['disabled'])): - self.dict['disabled'] = spicedb.get_channel_value(bot, channel, 'disabled_commands', 'commands') or {} + self.dict['disabled'] = botdb.get_channel_value(bot, channel, 'disabled_commands', 'commands') or {} return self.dict['disabled'] def check_disabled_commands(self, bot, command, channel): @@ -64,16 +64,16 @@ class BotCommands(): def set_command_disabled(self, bot, command, channel, timestamp, reason, bywhom): if not len(list(self.dict['disabled'])): - self.dict['disabled'] = spicedb.get_channel_value(bot, channel, 'disabled_commands', 'commands') or {} + self.dict['disabled'] = botdb.get_channel_value(bot, channel, 'disabled_commands', 'commands') or {} self.dict['disabled'][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom} - spicedb.set_channel_value(bot, channel, 'disabled_commands', self.dict['disabled'], 'commands') + botdb.set_channel_value(bot, channel, 'disabled_commands', self.dict['disabled'], 'commands') def unset_command_disabled(self, bot, command, channel): if not len(list(self.dict['disabled'])): - self.dict['disabled'] = spicedb.get_channel_value(bot, channel, 'disabled_commands', 'commands') or {} + self.dict['disabled'] = botdb.get_channel_value(bot, channel, 'disabled_commands', 'commands') or {} if command in self.dict['disabled'].keys(): del self.dict['disabled'][command] - spicedb.set_channel_value(bot, channel, 'disabled_commands', self.dict['disabled'], 'commands') + botdb.set_channel_value(bot, channel, 'disabled_commands', self.dict['disabled'], 'commands') def register(self, bot, command_dict): diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 9c35d9d..0245fea 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -38,4 +38,4 @@ class BotConfig(): return configdict -db = BotConfig() +botconfig = BotConfig() diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index c03364d..d5424e6 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -14,6 +14,7 @@ class BotDatabase(): def __init__(self): self.lock = threading.Lock() + self.db = None self.dict = { "nicks": {}, "channels": {}, @@ -246,4 +247,4 @@ class BotDatabase(): self.lock.release() -db = BotDatabase() +botdb = BotDatabase() diff --git a/sopel_modules/SpiceBot/Events.py b/sopel_modules/SpiceBot/Events.py index b228352..a6e1e5b 100644 --- a/sopel_modules/SpiceBot/Events.py +++ b/sopel_modules/SpiceBot/Events.py @@ -14,6 +14,10 @@ import threading from .Logs import logs +# TODO +# full_message = ':{} PRIVMSG {} :{}'.format(hostmask, sender, msg) + + class BotEvents(object): """A dynamic listing of all the notable Bot numeric events. diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 8cea340..6f4a137 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -13,7 +13,7 @@ import spicemanip from .Tools import command_permissions_check from .Commands import commands -from .Database import db as spicedb +from .Database import botdb class BotPrerun(): @@ -106,7 +106,7 @@ class BotPrerun(): # don't run commands that are disabled in channels if not trigger.is_privmsg: - disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} + disabled_list = botdb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} if trigger.sb["realcom"] in disabled_list.keys(): reason = disabled_list[trigger.sb["realcom"]]["reason"] timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"] diff --git a/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py b/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py index 8cf4cb7..1d919e5 100644 --- a/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py +++ b/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py @@ -30,13 +30,12 @@ def setup(bot): SopelDB.delete_channel_value = SopelDBAddon.delete_channel_value SopelDB.adjust_channel_value = SopelDBAddon.adjust_channel_value - SopelDB.adjust_plugin_value = SopelDBAddon.adjust_plugin_value - SopelDB.delete_plugin_value = SopelDBAddon.delete_plugin_value SopelDB.get_plugin_value = SopelDBAddon.get_plugin_value SopelDB.set_plugin_value = SopelDBAddon.set_plugin_value + SopelDB.delete_plugin_value = SopelDBAddon.delete_plugin_value + SopelDB.adjust_plugin_value = SopelDBAddon.adjust_plugin_value -# TODO use this as a template for dynamic tablenames class PluginValues(BASE): """ PluginValues SQLAlchemy Class From 9728682c3834a135850f0353ceb8b1269bd1068a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 09:57:29 -0400 Subject: [PATCH 097/328] be consistant with sopel --- sopel_modules/SpiceBot/Config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 0245fea..8ee60f8 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -17,7 +17,7 @@ class BotConfig(): def load_config(self): if len(sys.argv[1:]): - argv = [] + argv = ['legacy'] else: argv = sys.argv[1:] parser = build_parser() From 59260fa977c5fc9865375a37337cd8c8eb2abb68 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 10:17:07 -0400 Subject: [PATCH 098/328] not --- sopel_modules/SpiceBot/Config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 8ee60f8..c1e01c7 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -16,7 +16,7 @@ class BotConfig(): self.config_dict = self.config_file_to_dict() def load_config(self): - if len(sys.argv[1:]): + if not len(sys.argv[1:]): argv = ['legacy'] else: argv = sys.argv[1:] From 155afcb25ef9d23e3e7ff30a52421debe919029d Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 10:27:26 -0400 Subject: [PATCH 099/328] test --- sopel_modules/SpiceBot/Config.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index c1e01c7..6e28674 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -13,9 +13,10 @@ class BotConfig(): def __init__(self): self.dict = {} self.config = self.load_config() - self.config_dict = self.config_file_to_dict() def load_config(self): + + # Load config if not len(sys.argv[1:]): argv = ['legacy'] else: @@ -23,19 +24,18 @@ class BotConfig(): parser = build_parser() opts = parser.parse_args(argv) config_module = get_configuration(opts) - return config_module - def config_file_to_dict(self): - configdict = dict() + # load dict config = configparser.ConfigParser() config.read(self.config.filename) for each_section in config.sections(): - if each_section not in configdict.keys(): - configdict[each_section] = dict() + if each_section not in self.dict.keys(): + self.dict[each_section] = dict() for (each_key, each_val) in config.items(each_section): - if each_key not in configdict[each_section].keys(): - configdict[each_section][each_key] = each_val - return configdict + if each_key not in self.dict[each_section].keys(): + self.dict[each_section][each_key] = each_val + + return config_module botconfig = BotConfig() From 64be7e4a6f91fbcdf2684826e34449e0baeb48f1 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 10:29:31 -0400 Subject: [PATCH 100/328] fix --- sopel_modules/SpiceBot/Config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 6e28674..bddaaa4 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -17,17 +17,17 @@ class BotConfig(): def load_config(self): # Load config + parser = build_parser() if not len(sys.argv[1:]): argv = ['legacy'] else: argv = sys.argv[1:] - parser = build_parser() opts = parser.parse_args(argv) config_module = get_configuration(opts) # load dict config = configparser.ConfigParser() - config.read(self.config.filename) + config.read(config_module.filename) for each_section in config.sections(): if each_section not in self.dict.keys(): self.dict[each_section] = dict() From 20c03fcab215d204ad65f32fb8944e5b1b87748a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 10:31:59 -0400 Subject: [PATCH 101/328] filename --- sopel_modules/SpiceBot/Config.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index bddaaa4..ac0e3d9 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -12,6 +12,7 @@ class BotConfig(): def __init__(self): self.dict = {} + self.filename = None self.config = self.load_config() def load_config(self): @@ -25,17 +26,25 @@ class BotConfig(): opts = parser.parse_args(argv) config_module = get_configuration(opts) - # load dict - config = configparser.ConfigParser() - config.read(config_module.filename) - for each_section in config.sections(): - if each_section not in self.dict.keys(): - self.dict[each_section] = dict() - for (each_key, each_val) in config.items(each_section): - if each_key not in self.dict[each_section].keys(): - self.dict[each_section][each_key] = each_val + # Filename + self.filename = config_module.filename + + # load as dict + self.dict = self.config_file_to_dict() return config_module + def config_file_to_dict(self): + configdict = dict() + config = configparser.ConfigParser() + config.read(self.filename) + for each_section in config.sections(): + if each_section not in configdict.keys(): + configdict[each_section] = dict() + for (each_key, each_val) in config.items(each_section): + if each_key not in configdict[each_section].keys(): + configdict[each_section][each_key] = each_val + return configdict + botconfig = BotConfig() From 8c322c21832ba73eead9e929ef41807dbae8b137 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 10:40:36 -0400 Subject: [PATCH 102/328] test --- sopel_modules/SpiceBot/Config.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index ac0e3d9..894f62a 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -12,8 +12,9 @@ class BotConfig(): def __init__(self): self.dict = {} + self.config = None self.filename = None - self.config = self.load_config() + self.load_config() def load_config(self): @@ -24,16 +25,14 @@ class BotConfig(): else: argv = sys.argv[1:] opts = parser.parse_args(argv) - config_module = get_configuration(opts) + self.config = get_configuration(opts) # Filename - self.filename = config_module.filename + self.filename = self.config.filename # load as dict self.dict = self.config_file_to_dict() - return config_module - def config_file_to_dict(self): configdict = dict() config = configparser.ConfigParser() From 105718b0566cf10e56e62677e5867bc76e67e3d2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 10:50:09 -0400 Subject: [PATCH 103/328] simpler --- sopel_modules/SpiceBot/Config.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 894f62a..8cf5acf 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -12,11 +12,6 @@ class BotConfig(): def __init__(self): self.dict = {} - self.config = None - self.filename = None - self.load_config() - - def load_config(self): # Load config parser = build_parser() @@ -31,19 +26,14 @@ class BotConfig(): self.filename = self.config.filename # load as dict - self.dict = self.config_file_to_dict() - - def config_file_to_dict(self): - configdict = dict() config = configparser.ConfigParser() config.read(self.filename) for each_section in config.sections(): - if each_section not in configdict.keys(): - configdict[each_section] = dict() - for (each_key, each_val) in config.items(each_section): - if each_key not in configdict[each_section].keys(): - configdict[each_section][each_key] = each_val - return configdict + if each_section not in self.dict.keys(): + self.dict[each_section] = dict() + for (each_key, each_val) in config.items(each_section): + if each_key not in self.dict[each_section].keys(): + self.dict[each_section][each_key] = each_val botconfig = BotConfig() From 87e184131adb7a088f71a1366f0cd3425537e715 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 10:59:15 -0400 Subject: [PATCH 104/328] test getattr --- sopel_modules/SpiceBot/Config.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 8cf5acf..0c66dc1 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -29,11 +29,19 @@ class BotConfig(): config = configparser.ConfigParser() config.read(self.filename) for each_section in config.sections(): - if each_section not in self.dict.keys(): - self.dict[each_section] = dict() + if each_section.lower() not in self.dict.keys(): + self.dict[each_section.lower()] = dict() for (each_key, each_val) in config.items(each_section): - if each_key not in self.dict[each_section].keys(): - self.dict[each_section][each_key] = each_val + if each_key.lower() not in self.dict[each_section.lower()].keys(): + self.dict[each_section.lower()][each_key.lower()] = each_val + + def __getattr__(self, name): + ''' will only get called for undefined attributes ''' + """We will try to find a core value, or return None""" + if name.lower() in self.dict["core"].keys(): + return self.dict["core"][str(name).lower()] + else: + return None botconfig = BotConfig() From 3b41f58d902209a86a750f94f783916ef4a839f7 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 11:29:43 -0400 Subject: [PATCH 105/328] database update --- sopel_modules/SpiceBot/Commands.py | 2 +- sopel_modules/SpiceBot/Config.py | 2 +- sopel_modules/SpiceBot/Database.py | 192 +++++++++++++++++++++++------ sopel_modules/SpiceBot/Prerun.py | 4 +- 4 files changed, 156 insertions(+), 44 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 368e80c..2f00517 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -12,7 +12,7 @@ import threading import spicemanip from .Logs import logs -from .Database import botdb +from .Database import db as botdb class BotCommands(): diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 0c66dc1..6d6508c 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -44,4 +44,4 @@ class BotConfig(): return None -botconfig = BotConfig() +config = BotConfig() diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index d5424e6..6edec2f 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -4,9 +4,11 @@ from __future__ import unicode_literals, absolute_import, division, print_functi This is the SpiceBot Database """ +from sopel.db import SopelDB from sopel.tools import Identifier import threading +from .Config import config as botconfig class BotDatabase(): @@ -14,7 +16,7 @@ class BotDatabase(): def __init__(self): self.lock = threading.Lock() - self.db = None + self.db = SopelDB(botconfig.config) self.dict = { "nicks": {}, "channels": {}, @@ -22,18 +24,18 @@ class BotDatabase(): """Nick""" - def get_nick_value(self, bot, nick, key, sorting_key='unsorted'): + def get_nick_value(self, nick, key, sorting_key='unsorted'): self.lock.acquire() nick = Identifier(nick) - nick_id = bot.db.get_nick_id(nick, create=True) + nick_id = self.db.get_nick_id(nick, create=True) if nick_id not in self.dict["nicks"].keys(): self.dict["nicks"][nick_id] = {} if sorting_key not in self.dict["nicks"][nick_id].keys(): - self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + self.dict["nicks"][nick_id][sorting_key] = self.db.get_nick_value(nick, sorting_key) or dict() self.lock.release() @@ -42,55 +44,55 @@ class BotDatabase(): else: return self.dict["nicks"][nick_id][sorting_key][key] - def set_nick_value(self, bot, nick, key, value, sorting_key='unsorted'): + def set_nick_value(self, nick, key, value, sorting_key='unsorted'): self.lock.acquire() nick = Identifier(nick) - nick_id = bot.db.get_nick_id(nick, create=True) + nick_id = self.db.get_nick_id(nick, create=True) if nick_id not in self.dict["nicks"].keys(): self.dict["nicks"][nick_id] = {} if sorting_key not in self.dict["nicks"][nick_id].keys(): - self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + self.dict["nicks"][nick_id][sorting_key] = self.db.get_nick_value(nick, sorting_key) or dict() self.dict["nicks"][nick_id][sorting_key][key] = value - bot.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) + self.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) self.lock.release() - def delete_nick_value(self, bot, nick, key, sorting_key='unsorted'): + def delete_nick_value(self, nick, key, sorting_key='unsorted'): self.lock.acquire() nick = Identifier(nick) - nick_id = bot.db.get_nick_id(nick, create=True) + nick_id = self.db.get_nick_id(nick, create=True) if nick_id not in self.dict["nicks"].keys(): self.dict["nicks"][nick_id] = {} if sorting_key not in self.dict["nicks"][nick_id].keys(): - self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + self.dict["nicks"][nick_id][sorting_key] = self.db.get_nick_value(nick, sorting_key) or dict() del self.dict["nicks"][nick_id][sorting_key][key] - bot.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) + self.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) self.lock.release() - def adjust_nick_value(self, bot, nick, key, value, sorting_key='unsorted'): + def adjust_nick_value(self, nick, key, value, sorting_key='unsorted'): self.lock.acquire() nick = Identifier(nick) - nick_id = bot.db.get_nick_id(nick, create=True) + nick_id = self.db.get_nick_id(nick, create=True) if nick_id not in self.dict["nicks"].keys(): self.dict["nicks"][nick_id] = {} if sorting_key not in self.dict["nicks"][nick_id].keys(): - self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + self.dict["nicks"][nick_id][sorting_key] = self.db.get_nick_value(nick, sorting_key) or dict() if key not in self.dict["nicks"][nick_id][sorting_key].keys(): oldvalue = [] @@ -101,11 +103,11 @@ class BotDatabase(): self.dict["nicks"][nick_id][sorting_key][key] = value else: self.dict["nicks"][nick_id][sorting_key][key] = oldvalue + value - bot.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) + self.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) self.lock.release() - def adjust_nick_list(self, bot, nick, key, entries, adjustmentdirection, sorting_key='unsorted'): + def adjust_nick_list(self, nick, key, entries, adjustmentdirection, sorting_key='unsorted'): self.lock.acquire() @@ -113,13 +115,13 @@ class BotDatabase(): entries = [entries] nick = Identifier(nick) - nick_id = bot.db.get_nick_id(nick, create=True) + nick_id = self.db.get_nick_id(nick, create=True) if nick_id not in self.dict["nicks"].keys(): self.dict["nicks"][nick_id] = {} if sorting_key not in self.dict["nicks"][nick_id].keys(): - self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict() + self.dict["nicks"][nick_id][sorting_key] = self.db.get_nick_value(nick, sorting_key) or dict() if key not in self.dict["nicks"][nick_id][sorting_key].keys(): self.dict["nicks"][nick_id][sorting_key][key] = [] @@ -132,23 +134,23 @@ class BotDatabase(): for entry in entries: while entry in self.dict["nicks"][nick_id][sorting_key][key]: self.dict["nicks"][nick_id][sorting_key][key].remove(entry) - bot.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) + self.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) self.lock.release() """Channels""" - def get_channel_value(self, bot, channel, key, sorting_key='unsorted'): + def get_channel_value(self, channel, key, sorting_key='unsorted'): self.lock.acquire() - channel = Identifier(channel) + channel = Identifier(channel).lower().lower() if channel not in self.dict["channels"].keys(): self.dict["channels"][channel] = {} if sorting_key not in self.dict["channels"][channel].keys(): - self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + self.dict["channels"][channel][sorting_key] = self.db.get_channel_value(channel, sorting_key) or dict() self.lock.release() @@ -157,51 +159,51 @@ class BotDatabase(): else: return self.dict["channels"][channel][sorting_key][key] - def set_channel_value(self, bot, channel, key, value, sorting_key='unsorted'): + def set_channel_value(self, channel, key, value, sorting_key='unsorted'): self.lock.acquire() - channel = Identifier(channel) + channel = Identifier(channel).lower() if channel not in self.dict["channels"].keys(): self.dict["channels"][channel] = {} if sorting_key not in self.dict["channels"][channel].keys(): - self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + self.dict["channels"][channel][sorting_key] = self.db.get_channel_value(channel, sorting_key) or dict() self.dict["channels"][channel][sorting_key][key] = value - bot.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) + self.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) self.lock.release() - def delete_channel_value(self, bot, channel, key, sorting_key='unsorted'): + def delete_channel_value(self, channel, key, sorting_key='unsorted'): self.lock.acquire() - channel = Identifier(channel) + channel = Identifier(channel).lower() if channel not in self.dict["channels"].keys(): self.dict["channels"][channel] = {} if sorting_key not in self.dict["channels"][channel].keys(): - self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + self.dict["channels"][channel][sorting_key] = self.db.get_channel_value(channel, sorting_key) or dict() del self.dict["channels"][channel][sorting_key][key] - bot.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) + self.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) self.lock.release() - def adjust_channel_value(self, bot, channel, key, value, sorting_key='unsorted'): + def adjust_channel_value(self, channel, key, value, sorting_key='unsorted'): self.lock.acquire() - channel = Identifier(channel) + channel = Identifier(channel).lower() if channel not in self.dict["channels"].keys(): self.dict["channels"][channel] = {} if sorting_key not in self.dict["channels"][channel].keys(): - self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + self.dict["channels"][channel][sorting_key] = self.db.get_channel_value(channel, sorting_key) or dict() if key not in self.dict["channels"][channel][sorting_key].keys(): oldvalue = None @@ -212,24 +214,24 @@ class BotDatabase(): self.dict["channels"][channel][sorting_key][key] = value else: self.dict["channels"][channel][sorting_key][key] = oldvalue + value - bot.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) + self.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) self.lock.release() - def adjust_channel_list(self, bot, channel, key, entries, adjustmentdirection, sorting_key='unsorted'): + def adjust_channel_list(self, channel, key, entries, adjustmentdirection, sorting_key='unsorted'): self.lock.acquire() if not isinstance(entries, list): entries = [entries] - channel = Identifier(channel) + channel = Identifier(channel).lower() if channel not in self.dict["channels"].keys(): self.dict["channels"][channel] = {} if sorting_key not in self.dict["channels"][channel].keys(): - self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict() + self.dict["channels"][channel][sorting_key] = self.db.get_channel_value(channel, sorting_key) or dict() if key not in self.dict["channels"][channel][sorting_key].keys(): self.dict["channels"][channel][sorting_key][key] = [] @@ -242,9 +244,119 @@ class BotDatabase(): for entry in entries: while entry in self.dict["channels"][channel][sorting_key][key]: self.dict["channels"][channel][sorting_key][key].remove(entry) - bot.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) + self.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) + + self.lock.release() + + """Plugins""" + + def get_plugin_value(self, plugin, key, sorting_key='unsorted'): + + self.lock.acquire() + + plugin = plugin.lower() + + if plugin not in self.dict["plugins"].keys(): + self.dict["plugins"][plugin] = {} + + if sorting_key not in self.dict["plugins"][plugin].keys(): + self.dict["plugins"][plugin][sorting_key] = self.db.get_plugin_value(plugin, sorting_key) or dict() + + self.lock.release() + + if key not in self.dict["plugins"][plugin][sorting_key].keys(): + return None + else: + return self.dict["plugins"][plugin][sorting_key][key] + + def set_plugin_value(self, plugin, key, value, sorting_key='unsorted'): + + self.lock.acquire() + + plugin = plugin.lower() + + if plugin not in self.dict["plugins"].keys(): + self.dict["plugins"][plugin] = {} + + if sorting_key not in self.dict["plugins"][plugin].keys(): + self.dict["plugins"][plugin][sorting_key] = self.db.get_plugin_value(plugin, sorting_key) or dict() + + self.dict["plugins"][plugin][sorting_key][key] = value + self.db.set_plugin_value(plugin, sorting_key, self.dict["plugins"][plugin][sorting_key]) + + self.lock.release() + + def delete_plugin_value(self, plugin, key, sorting_key='unsorted'): + + self.lock.acquire() + + plugin = plugin.lower() + + if plugin not in self.dict["plugins"].keys(): + self.dict["plugins"][plugin] = {} + + if sorting_key not in self.dict["plugins"][plugin].keys(): + self.dict["plugins"][plugin][sorting_key] = self.db.get_plugin_value(plugin, sorting_key) or dict() + + del self.dict["plugins"][plugin][sorting_key][key] + self.db.set_plugin_value(plugin, sorting_key, self.dict["plugins"][plugin][sorting_key]) + + self.lock.release() + + def adjust_plugin_value(self, plugin, key, value, sorting_key='unsorted'): + + self.lock.acquire() + + plugin = plugin.lower() + + if plugin not in self.dict["plugins"].keys(): + self.dict["plugins"][plugin] = {} + + if sorting_key not in self.dict["plugins"][plugin].keys(): + self.dict["plugins"][plugin][sorting_key] = self.db.get_plugin_value(plugin, sorting_key) or dict() + + if key not in self.dict["plugins"][plugin][sorting_key].keys(): + oldvalue = None + else: + oldvalue = self.dict["plugins"][plugin][sorting_key][key] + + if not oldvalue: + self.dict["plugins"][plugin][sorting_key][key] = value + else: + self.dict["plugins"][plugin][sorting_key][key] = oldvalue + value + self.db.set_plugin_value(plugin, sorting_key, self.dict["plugins"][plugin][sorting_key]) + + self.lock.release() + + def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection, sorting_key='unsorted'): + + self.lock.acquire() + + if not isinstance(entries, list): + entries = [entries] + + plugin = plugin.lower() + + if plugin not in self.dict["plugins"].keys(): + self.dict["plugins"][plugin] = {} + + if sorting_key not in self.dict["plugins"][plugin].keys(): + self.dict["plugins"][plugin][sorting_key] = self.db.get_plugin_value(plugin, sorting_key) or dict() + + if key not in self.dict["plugins"][plugin][sorting_key].keys(): + self.dict["plugins"][plugin][sorting_key][key] = [] + + if adjustmentdirection == 'add': + for entry in entries: + if entry not in self.dict["plugins"][plugin][sorting_key][key]: + self.dict["plugins"][plugin][sorting_key][key].append(entry) + elif adjustmentdirection == 'del': + for entry in entries: + while entry in self.dict["plugins"][plugin][sorting_key][key]: + self.dict["plugins"][plugin][sorting_key][key].remove(entry) + self.db.set_plugin_value(plugin, sorting_key, self.dict["plugins"][plugin][sorting_key]) self.lock.release() -botdb = BotDatabase() +db = BotDatabase() diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 6f4a137..a0cb4f3 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -13,7 +13,7 @@ import spicemanip from .Tools import command_permissions_check from .Commands import commands -from .Database import botdb +from .Database import db as botdb class BotPrerun(): @@ -106,7 +106,7 @@ class BotPrerun(): # don't run commands that are disabled in channels if not trigger.is_privmsg: - disabled_list = botdb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {} + disabled_list = botdb.get_channel_value(trigger.sender, 'disabled_commands', 'commands') or {} if trigger.sb["realcom"] in disabled_list.keys(): reason = disabled_list[trigger.sb["realcom"]]["reason"] timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"] From acaa8abe0c1c0f4eb7fdf026dbde9b581217e117 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 11:54:23 -0400 Subject: [PATCH 106/328] add bot finding abilities --- sopel_modules/SpiceBot/Database.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 6edec2f..5decfff 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -4,8 +4,9 @@ from __future__ import unicode_literals, absolute_import, division, print_functi This is the SpiceBot Database """ -from sopel.db import SopelDB +# sopel imports from sopel.tools import Identifier +from sopel.db import SopelDB import threading from .Config import config as botconfig @@ -16,11 +17,11 @@ class BotDatabase(): def __init__(self): self.lock = threading.Lock() - self.db = SopelDB(botconfig.config) self.dict = { "nicks": {}, "channels": {}, } + self.db = SopelDB(botconfig.config) """Nick""" @@ -138,6 +139,23 @@ class BotDatabase(): self.lock.release() + """Bot""" + + def get_bot_value(self, key, sorting_key='unsorted'): + return self.get_nick_value(botconfig.nick, key, sorting_key) + + def set_bot_value(self, key, value, sorting_key='unsorted'): + return self.set_nick_value(botconfig.nick, key, value, sorting_key) + + def delete_bot_value(self, key, sorting_key='unsorted'): + return self.delete_nick_value(botconfig.nick, key, sorting_key) + + def adjust_bot_value(self, key, value, sorting_key='unsorted'): + return self.adjust_nick_value(botconfig.nick, key, value, sorting_key) + + def adjust_bot_list(self, key, entries, adjustmentdirection, sorting_key): + return self.adjust_nick_list(botconfig.nick, key, entries, adjustmentdirection, sorting_key) + """Channels""" def get_channel_value(self, channel, key, sorting_key='unsorted'): From a2d2e9ef43e9b2e25e16d26c0553a3a0d0023647 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 12:16:06 -0400 Subject: [PATCH 107/328] push osd --- sopel_modules/SpiceBot/Prerun.py | 26 ++--- sopel_modules/SpiceBot_AI/AI_Acknowledge.py | 4 +- sopel_modules/SpiceBot_AI/AI_Goodbye.py | 2 +- sopel_modules/SpiceBot_AI/AI_Love.py | 4 +- sopel_modules/SpiceBot_AI/AI_Ping.py | 2 +- sopel_modules/SpiceBot_AI/AI_Really.py | 2 +- sopel_modules/SpiceBot_AI/AI_Thanks.py | 2 +- sopel_modules/SpiceBot_AI/AI_Welcomeback.py | 2 +- .../NickQueryCommand.py | 12 +-- .../SpiceBot_CommandsQuery/QueryCommand.py | 12 +-- sopel_modules/SpiceBot_Logs/Logs_Command.py | 6 +- sopel_modules/SpiceBot_Logs/Queue.py | 2 +- sopel_modules/SpiceBot_Messaging/Messaging.py | 6 +- sopel_modules/SpiceBot_Restart/Restart.py | 2 +- sopel_modules/SpiceBot_Update/Update.py | 4 +- sopel_modules/SpiceBot_osd/__init__.py | 96 +------------------ 16 files changed, 45 insertions(+), 139 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index a0cb4f3..dce2c5b 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -101,7 +101,7 @@ class BotPrerun(): if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): return True else: - bot.notice("The admin switch (-a) is for use by authorized nicks ONLY.") + bot.osd("The admin switch (-a) is for use by authorized nicks ONLY.", 'notice') return False # don't run commands that are disabled in channels @@ -118,9 +118,9 @@ class BotPrerun(): def trigger_cant_run(self, bot, trigger, message=None): if message: - bot.notice(message, trigger.nick) + bot.osd(message, trigger.nick, 'notice') if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): - bot.notice("You however are authorized to bypass this warning with the (-a) admin switch.", trigger.nick) + bot.osd("You however are authorized to bypass this warning with the (-a) admin switch.", trigger.nick, 'notice') return False def trigger_hyphen_args(self, trigger_args_part): @@ -146,48 +146,48 @@ class BotPrerun(): # Commands that cannot run via privmsg if trigger.sb["hyphen_arg"] in ['check']: if trigger.sb["com"].lower() != trigger.sb["realcom"]: - bot.say(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"]) + bot.osd(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"]) else: - bot.say(trigger.sb["com"] + " is a valid command") + bot.osd(trigger.sb["com"] + " is a valid command") return elif trigger.sb["hyphen_arg"] in ['enable']: if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): - bot.say("I was unable to disable this command due to privilege issues.") + bot.osd("I was unable to disable this command due to privilege issues.") return if trigger.is_privmsg: - bot.notice("This command must be run in a channel you which to enable it in.", trigger.nick) + bot.osd("This command must be run in a channel you which to enable it in.", trigger.nick, 'notice') return if not commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): - bot.notice(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick) + bot.osd(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick, 'notice') return commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender) - bot.say(trigger.sb["com"] + " is now enabled in " + str(trigger.sender)) + bot.osd(trigger.sb["com"] + " is now enabled in " + str(trigger.sender)) return elif trigger.sb["hyphen_arg"] in ['disable']: if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): - bot.say("I was unable to disable this command due to privilege issues.") + bot.osd("I was unable to disable this command due to privilege issues.") return if trigger.is_privmsg: - bot.notice("This command must be run in a channel you which to disable it in.", trigger.nick) + bot.osd("This command must be run in a channel you which to disable it in.", trigger.nick, 'notice') return if commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): - bot.notice(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick) + bot.osd(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick, 'notice') return trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given." timestamp = str(datetime.datetime.utcnow()) commands.set_command_disabled(bot, trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) - bot.say(trigger.sb["com"] + " is now disabled in " + str(trigger.sender)) + bot.osd(trigger.sb["com"] + " is now disabled in " + str(trigger.sender)) return return diff --git a/sopel_modules/SpiceBot_AI/AI_Acknowledge.py b/sopel_modules/SpiceBot_AI/AI_Acknowledge.py index e9e626e..50b1796 100644 --- a/sopel_modules/SpiceBot_AI/AI_Acknowledge.py +++ b/sopel_modules/SpiceBot_AI/AI_Acknowledge.py @@ -7,9 +7,9 @@ import sopel.module @sopel.module.rule('$nickname!') def exclaim(bot, trigger): - bot.say(trigger.nick + '!') + bot.osd(trigger.nick + '!') @sopel.module.rule('$nickname\?') def imhere(bot, trigger): - bot.say("I'm here, " + trigger.nick) + bot.osd("I'm here, " + trigger.nick) diff --git a/sopel_modules/SpiceBot_AI/AI_Goodbye.py b/sopel_modules/SpiceBot_AI/AI_Goodbye.py index 7f93bef..596da98 100644 --- a/sopel_modules/SpiceBot_AI/AI_Goodbye.py +++ b/sopel_modules/SpiceBot_AI/AI_Goodbye.py @@ -11,7 +11,7 @@ import spicemanip def bot_command_goodbye(bot, trigger): byemsg = spicemanip.main(['Bye', 'Goodbye', 'Seeya', 'Auf Wiedersehen', 'Au revoir', 'Ttyl'], "random") punctuation = spicemanip.main(['!', ''], "random") - bot.say(byemsg + ' ' + trigger.nick + punctuation) + bot.osd(byemsg + ' ' + trigger.nick + punctuation) @sopel.module.nickname_commands("bye", "goodbye", "gtg", "seeya", "cya", "ttyl", "g2g", "gnight", "goodnight") diff --git a/sopel_modules/SpiceBot_AI/AI_Love.py b/sopel_modules/SpiceBot_AI/AI_Love.py index 8674317..c43361c 100644 --- a/sopel_modules/SpiceBot_AI/AI_Love.py +++ b/sopel_modules/SpiceBot_AI/AI_Love.py @@ -7,7 +7,7 @@ import sopel.module @sopel.module.rule(r'(?i)(I love you|loveya),? $nickname[ \t]*$') def bot_command_love(bot, trigger): - bot.reply("I love you too.") + bot.osd(trigger.nick + ", I love you too.") @sopel.module.rule('$nickname (loveya|I love you)') @@ -27,7 +27,7 @@ def bot_command_love_d(bot, trigger): @sopel.module.rule(r'(?i)(I like you),? $nickname[ \t]*$') def bot_command_like(bot, trigger): - bot.reply("I like you too.") + bot.osd(trigger.nick + ", I like you too.") @sopel.module.rule('$nickname (I like you)') diff --git a/sopel_modules/SpiceBot_AI/AI_Ping.py b/sopel_modules/SpiceBot_AI/AI_Ping.py index 4931797..76b6ee4 100644 --- a/sopel_modules/SpiceBot_AI/AI_Ping.py +++ b/sopel_modules/SpiceBot_AI/AI_Ping.py @@ -7,7 +7,7 @@ import sopel.module @sopel.module.rule(r'(?i)(ping),? $nickname[ \t]*$') def bot_command_ping(bot, trigger): - bot.say("Pong") + bot.osd("Pong") @sopel.module.nickname_commands('ping') diff --git a/sopel_modules/SpiceBot_AI/AI_Really.py b/sopel_modules/SpiceBot_AI/AI_Really.py index 2a36402..162b828 100644 --- a/sopel_modules/SpiceBot_AI/AI_Really.py +++ b/sopel_modules/SpiceBot_AI/AI_Really.py @@ -10,7 +10,7 @@ import spicemanip @sopel.module.rule(r'(?i)(really),? $nickname\?') def bot_command_really(bot, trigger): really = spicemanip.main(["Yes, really.", "Really really"], "random") - bot.reply(really) + bot.osd(trigger.nick + ", " + really) @sopel.module.rule('$nickname really\?') diff --git a/sopel_modules/SpiceBot_AI/AI_Thanks.py b/sopel_modules/SpiceBot_AI/AI_Thanks.py index be80f7f..8babea3 100644 --- a/sopel_modules/SpiceBot_AI/AI_Thanks.py +++ b/sopel_modules/SpiceBot_AI/AI_Thanks.py @@ -7,7 +7,7 @@ import sopel.module @sopel.module.rule(r'(?i)(thank you|thanks),? $nickname[ \t]*$') def bot_command_thanks(bot, trigger): - bot.reply("You're welcome.") + bot.osd(trigger.nick + ",You're welcome.") @sopel.module.rule('$nickname (thank you)') diff --git a/sopel_modules/SpiceBot_AI/AI_Welcomeback.py b/sopel_modules/SpiceBot_AI/AI_Welcomeback.py index 334d8cb..b81f42c 100644 --- a/sopel_modules/SpiceBot_AI/AI_Welcomeback.py +++ b/sopel_modules/SpiceBot_AI/AI_Welcomeback.py @@ -10,4 +10,4 @@ import spicemanip @sopel.module.rule(r'(?i)(welcome back),? $nickname\?') def bot_command_really(bot, trigger): reply = spicemanip.main(['Thank you', 'thanks'], "random") - bot.reply(reply) + bot.osd(trigger.nick + ", " + reply) diff --git a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py index 15f3498..11109fd 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py @@ -42,14 +42,14 @@ def query_detection_nick(bot, trigger): 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(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") - bot.notice(dispmsg, trigger.nick) + bot.osd(dispmsg, trigger.nick, 'notice') return 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(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick) + bot.osd("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice') return if trigger.sb['com'].endswith("?"): @@ -60,9 +60,9 @@ def query_detection_nick(bot, trigger): 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(trigger.sb['com']) + ".", trigger.nick) + bot.osd("Cannot find any similar " + bot.nick + " commands for " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') else: - bot.notice("The following " + bot.nick + " commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick) + bot.osd("The following " + bot.nick + " commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice') return commandlist = [] @@ -71,6 +71,6 @@ def query_detection_nick(bot, trigger): commandlist.append(command) if not len(commandlist): - bot.notice("No " + bot.nick + " commands start with " + str(trigger.sb['com']) + ".", trigger.nick) + bot.osd("No " + bot.nick + " commands start with " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') else: - bot.notice("The following " + bot.nick + " commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick) + bot.osd("The following " + bot.nick + " commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice') diff --git a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py index f52b37e..533818c 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py @@ -40,14 +40,14 @@ def query_detection(bot, trigger): closestmatches = SpiceBot.similar_list(bot, trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') if len(closestmatches): dispmsg.append("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") - bot.notice(dispmsg, trigger.nick) + bot.osd(dispmsg, trigger.nick, 'notice') return 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(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick) + bot.osd("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice') return if trigger.sb['com'][:-1] == "?": @@ -58,9 +58,9 @@ def query_detection(bot, trigger): 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(trigger.sb['com']) + ".", trigger.nick) + bot.osd("Cannot find any similar commands for " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') else: - bot.notice("The following commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick) + bot.osd("The following commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice') return commandlist = [] @@ -69,6 +69,6 @@ def query_detection(bot, trigger): commandlist.append(command) if not len(commandlist): - bot.notice("No commands start with " + str(trigger.sb['com']) + ".", trigger.nick) + bot.osd("No commands start with " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') else: - bot.notice("The following commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick) + bot.osd("The following commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice') diff --git a/sopel_modules/SpiceBot_Logs/Logs_Command.py b/sopel_modules/SpiceBot_Logs/Logs_Command.py index 0af1032..0819ab6 100644 --- a/sopel_modules/SpiceBot_Logs/Logs_Command.py +++ b/sopel_modules/SpiceBot_Logs/Logs_Command.py @@ -14,7 +14,7 @@ import sopel_modules.SpiceBot as SpiceBot def bot_command_logs(bot, trigger): if not SpiceBot.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.") + bot.osd("I was unable to process this Bot Nick command due to privilege issues.") return logtype = spicemanip.main(trigger.sb['args'], 1) or None @@ -25,9 +25,9 @@ def bot_command_logs(bot, trigger): if not SpiceBot.inlist(logtype, SpiceBot.logs.dict["list"].keys()): closestmatches = SpiceBot.similar_list(bot, logtype, SpiceBot.logs.dict["list"].keys(), 10, 'reverse') if not len(closestmatches): - bot.notice("No valid logs match " + str(logtype) + ".", trigger.nick) + bot.osd("No valid logs match " + str(logtype) + ".", trigger.nick, 'notice') else: - bot.notice("The following commands may match " + str(logtype) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick) + bot.osd("The following commands may match " + str(logtype) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice') return diff --git a/sopel_modules/SpiceBot_Logs/Queue.py b/sopel_modules/SpiceBot_Logs/Queue.py index bbfe113..dedfc53 100644 --- a/sopel_modules/SpiceBot_Logs/Queue.py +++ b/sopel_modules/SpiceBot_Logs/Queue.py @@ -27,7 +27,7 @@ def join_log_channel(bot, trigger): while True: if len(SpiceBot.logs.dict["queue"]): - bot.say(str(SpiceBot.logs.dict["queue"][0]), channel) + bot.osd(str(SpiceBot.logs.dict["queue"][0]), channel) del SpiceBot.logs.dict["queue"][0] else: SpiceBot.logs.sopel_config["logging_channel"] = False diff --git a/sopel_modules/SpiceBot_Messaging/Messaging.py b/sopel_modules/SpiceBot_Messaging/Messaging.py index e2af152..de9f5eb 100644 --- a/sopel_modules/SpiceBot_Messaging/Messaging.py +++ b/sopel_modules/SpiceBot_Messaging/Messaging.py @@ -30,14 +30,14 @@ def bot_command_privmsg(bot, trigger): def bot_command_process(bot, trigger): if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner']): - bot.say("I was unable to process this Bot Nick command due to privilege issues.") + bot.osd("I was unable to process this Bot Nick command due to privilege issues.") return if trigger.sb['com'] in ['say', 'msg']: trigger.sb['com'] = 'privmsg' if not len(trigger.sb['args']): - bot.say("You must specify a channel or nick.") + bot.osd("You must specify a channel or nick.") return target = spicemanip.main(trigger.sb['args'], 1) @@ -58,7 +58,7 @@ def bot_command_process(bot, trigger): botmessage = spicemanip.main(trigger.sb['args'], 0) if not botmessage: - bot.say("You must specify a message to send.") + bot.osd("You must specify a message to send.") return bot.osd(botmessage, targetsendlist, trigger.sb['com'].upper()) diff --git a/sopel_modules/SpiceBot_Restart/Restart.py b/sopel_modules/SpiceBot_Restart/Restart.py index bc4ef6f..3f25341 100644 --- a/sopel_modules/SpiceBot_Restart/Restart.py +++ b/sopel_modules/SpiceBot_Restart/Restart.py @@ -12,7 +12,7 @@ import sopel_modules.SpiceBot as SpiceBot def nickname_comand_restart(bot, trigger): if not trigger.admin: - bot.say("You are not authorized to perform this function.") + bot.osd("You are not authorized to perform this function.") quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!" SpiceBot.logs.log('SpiceBot_Restart', quitmessage) diff --git a/sopel_modules/SpiceBot_Update/Update.py b/sopel_modules/SpiceBot_Update/Update.py index 9f69588..613d734 100644 --- a/sopel_modules/SpiceBot_Update/Update.py +++ b/sopel_modules/SpiceBot_Update/Update.py @@ -32,7 +32,7 @@ def setup(bot): def nickname_comand_update(bot, trigger): if not SpiceBot.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.") + bot.osd("I was unable to process this Bot Nick command due to privilege issues.") return if not len(trigger.sb['args']): @@ -41,7 +41,7 @@ def nickname_comand_update(bot, trigger): commandused = spicemanip.main(trigger.sb['args'], 1).lower() if commandused not in ['deps', 'nodeps']: - bot.say("Please specify deps or nodeps") + bot.osd("Please specify deps or nodeps") return trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') diff --git a/sopel_modules/SpiceBot_osd/__init__.py b/sopel_modules/SpiceBot_osd/__init__.py index 5dce22e..8cd686f 100644 --- a/sopel_modules/SpiceBot_osd/__init__.py +++ b/sopel_modules/SpiceBot_osd/__init__.py @@ -47,19 +47,6 @@ def setup(bot): tools.get_sendable_message_list = ToolsOSD.get_sendable_message_list tools.get_message_recipientgroups = ToolsOSD.get_message_recipientgroups - # overwrite default bot messaging - SpiceBot.logs.log('SpiceBot_OSD', "Overwrite Default Sopel messaging commands") - bot.osd = SopelOSD.osd - bot.say = SopelOSD.say - bot.action = SopelOSD.action - bot.notice = SopelOSD.notice - bot.reply = SopelOSD.reply - bot.msg = SopelOSD.msg - sopel.bot.SopelWrapper.say = SopelWrapperOSD.say - sopel.bot.SopelWrapper.action = SopelWrapperOSD.action - sopel.bot.SopelWrapper.notice = SopelWrapperOSD.notice - sopel.bot.SopelWrapper.reply = SopelWrapperOSD.reply - # verify config settings for server SpiceBot.logs.log('SpiceBot_OSD', "Checking for config settings") bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) @@ -283,7 +270,7 @@ class SopelOSD: recipient_id = Identifier(recipientgroup) - recipient_stack = self.stack.setdefault(recipient_id, { + recipient_stack = self.osdstack.setdefault(recipient_id, { 'messages': [], 'flood_left': self.config.SpiceBot_OSD.flood_burst_lines, 'dots': 0, @@ -343,61 +330,6 @@ class SopelOSD: finally: self.sending.release() - def say(self, text, recipient, max_messages=1): - """Send ``text`` as a PRIVMSG to ``recipient``. - In the context of a triggered callable, the ``recipient`` defaults to - the channel (or nickname, if a private message) from which the message - was received. - """ - self.osd(text, recipient, 'PRIVMSG', max_messages) - - def notice(self, text, dest, max_messages=1): - """Send an IRC NOTICE to a user or a channel. - - Within the context of a triggered callable, ``dest`` will default to - the channel (or nickname, if a private message), in which the trigger - happened. - """ - self.osd(text, dest, 'NOTICE', max_messages) - - def action(self, text, dest, max_messages=1): - """Send ``text`` as a CTCP ACTION PRIVMSG to ``dest``. - - The same loop detection and length restrictions apply as with - :func:`say`, though automatic message splitting is not available. - - Within the context of a triggered callable, ``dest`` will default to - the channel (or nickname, if a private message), in which the trigger - happened. - """ - self.osd(text, dest, 'ACTION', max_messages) - - def reply(self, text, dest, reply_to, notice=False, max_messages=1): - """Prepend ``reply_to`` to ``text``, and send as a PRIVMSG to ``dest``. - - If ``notice`` is ``True``, send a NOTICE rather than a PRIVMSG. - - The same loop detection and length restrictions apply as with - :func:`say`, though automatic message splitting is not available. - - Within the context of a triggered callable, ``reply_to`` will default to - the nickname of the user who triggered the call, and ``dest`` to the - channel (or nickname, if a private message), in which the trigger - happened. - """ - text = '%s: %s' % (reply_to, text) - if notice: - self.osd(text, dest, 'NOTICE', max_messages) - else: - self.osd(text, dest, 'PRIVMSG', max_messages) - - def msg(self, recipient, text, max_messages=1): - """ - .. deprecated:: 6.0 - Use :meth:`say` instead. Will be removed in Sopel 8. - """ - self.osd(text, recipient, 'PRIVMSG', max_messages) - class SopelWrapperOSD(object): @@ -405,29 +337,3 @@ class SopelWrapperOSD(object): if recipients is None: recipients = self._trigger.sender self._bot.osd(self, messages, recipients, text_method, max_messages) - - def say(self, message, destination=None, max_messages=1): - if destination is None: - destination = self._trigger.sender - self._bot.osd(self, message, destination, 'PRIVMSG', 1) - - def action(self, message, destination=None, max_messages=1): - if destination is None: - destination = self._trigger.sender - self._bot.osd(self, message, destination, 'ACTION', 1) - - def notice(self, message, destination=None, max_messages=1): - if destination is None: - destination = self._trigger.sender - self._bot.osd(self, message, destination, 'NOTICE', 1) - - def reply(self, message, destination=None, reply_to=None, notice=False, max_messages=1): - if destination is None: - destination = self._trigger.sender - if reply_to is None: - reply_to = self._trigger.nick - message = '%s: %s' % (reply_to, message) - if notice: - self._bot.osd(self, message, destination, 'NOTICE', 1) - else: - self._bot.osd(self, message, destination, 'PRIVMSG', 1) From 32a90748e267370fece0c9770c9d78889119b972 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 12:28:38 -0400 Subject: [PATCH 108/328] osdstack --- sopel_modules/SpiceBot_osd/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sopel_modules/SpiceBot_osd/__init__.py b/sopel_modules/SpiceBot_osd/__init__.py index 8cd686f..2137386 100644 --- a/sopel_modules/SpiceBot_osd/__init__.py +++ b/sopel_modules/SpiceBot_osd/__init__.py @@ -252,6 +252,9 @@ class SopelOSD: will default to ``1``. """ + if not hasattr(self, 'osdstack'): + self.osdstack = {} + text_method = text_method.upper() if text_method == 'SAY' or text_method not in ['NOTICE', 'ACTION']: text_method = 'PRIVMSG' From 9dfd95ae046c0db7714ac791d4b42066251f3806 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 12:41:47 -0400 Subject: [PATCH 109/328] db command --- sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py b/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py index 10b314a..b7ea84d 100644 --- a/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py +++ b/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py @@ -5,7 +5,9 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi # sopel imports import sopel.module +import sopel_modules.SpiceBot as SpiceBot + @sopel.module.nickname_commands('database') def bot_command_gender(bot, trigger): - bot.osd("Database is " + bot.config.core.db_type) + bot.osd("Database is " + SpiceBot.config.dict["core"]["db_type"]) From 0f7f0d043e9b12eceaf1bcf1be9a64291b046b9d Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 13:11:17 -0400 Subject: [PATCH 110/328] attempt sorting key logic --- sopel_modules/SpiceBot/Database.py | 365 ++++++++++++++++++++++++++++- 1 file changed, 364 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 5decfff..303c99c 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -6,11 +6,20 @@ This is the SpiceBot Database # sopel imports from sopel.tools import Identifier -from sopel.db import SopelDB +from sopel.db import SopelDB, Nicknames, _deserialize import threading from .Config import config as botconfig +from sqlalchemy import Column, ForeignKey, Integer, String +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.exc import SQLAlchemyError + +import json + + +BASE = declarative_base() + class BotDatabase(): """A thread safe database cache""" @@ -23,6 +32,21 @@ class BotDatabase(): } self.db = SopelDB(botconfig.config) + self.db.get_nick_value = SpiceDB.get_nick_value + self.db.set_nick_value = SpiceDB.set_nick_value + self.db.delete_nick_value = SpiceDB.delete_nick_value + self.db.adjust_nick_value = SpiceDB.adjust_nick_value + + self.db.get_channel_value = SpiceDB.get_channel_value + self.db.set_channel_value = SpiceDB.set_channel_value + self.db.delete_channel_value = SpiceDB.delete_channel_value + self.db.adjust_channel_value = SpiceDB.adjust_channel_value + + self.db.get_plugin_value = SpiceDB.get_plugin_value + self.db.set_plugin_value = SpiceDB.set_plugin_value + self.db.delete_plugin_value = SpiceDB.delete_plugin_value + self.db.adjust_plugin_value = SpiceDB.adjust_plugin_value + """Nick""" def get_nick_value(self, nick, key, sorting_key='unsorted'): @@ -378,3 +402,342 @@ class BotDatabase(): db = BotDatabase() + + +class PluginValues(BASE): + """ + PluginValues SQLAlchemy Class + """ + __tablename__ = 'plugin_values' + plugin = Column(String(255), primary_key=True) + sortingkey = Column(String(255), primary_key=True) + key = Column(String(255), primary_key=True) + value = Column(String(255)) + + +class NickValues(BASE): + """ + NickValues SQLAlchemy Class + """ + __tablename__ = 'nick_values' + nick_id = Column(Integer, ForeignKey('nick_ids.nick_id'), primary_key=True) + sortingkey = Column(String(255), primary_key=True) + key = Column(String(255), primary_key=True) + value = Column(String(255)) + + +class ChannelValues(BASE): + """ + ChannelValues SQLAlchemy Class + """ + __tablename__ = 'channel_values' + channel = Column(String(255), primary_key=True) + sortingkey = Column(String(255), primary_key=True) + key = Column(String(255), primary_key=True) + value = Column(String(255)) + + +class SpiceDB(object): + + # NICK FUNCTIONS + + def set_nick_value(self, nick, key, value, sortingkey='unsorted'): + """Sets the value for a given key to be associated with the nick.""" + nick = Identifier(nick) + value = json.dumps(value, ensure_ascii=False) + nick_id = self.get_nick_id(nick) + session = self.ssession() + try: + result = session.query(NickValues) \ + .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.sortingkey == sortingkey) \ + .filter(NickValues.key == key) \ + .one_or_none() + # NickValue exists, update + if result: + result.value = value + session.commit() + # DNE - Insert + else: + new_nickvalue = NickValues(nick_id=nick_id, sortingkey=sortingkey, key=key, value=value) + session.add(new_nickvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def get_nick_value(self, nick, key, sortingkey='unsorted'): + """Retrieves the value for a given key associated with a nick.""" + nick = Identifier(nick) + session = self.ssession() + try: + result = session.query(NickValues) \ + .filter(Nicknames.nick_id == NickValues.nick_id) \ + .filter(Nicknames.slug == nick.lower()) \ + .filter(NickValues.sortingkey == sortingkey) \ + .filter(NickValues.key == key) \ + .one_or_none() + if result is not None: + result = result.value + return _deserialize(result) + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def delete_nick_value(self, nick, key, sortingkey='unsorted'): + """Deletes the value for a given key to be associated with the nick.""" + nick = Identifier(nick) + nick_id = self.get_nick_id(nick) + session = self.ssession() + try: + result = session.query(NickValues) \ + .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.sortingkey == sortingkey) \ + .filter(NickValues.key == key) \ + .one_or_none() + # NickValue exists, delete + if result: + session.delete(result) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def adjust_nick_value(self, nick, key, value, sortingkey='unsorted'): + """Sets the value for a given key to be associated with the nick.""" + nick = Identifier(nick) + value = json.dumps(value, ensure_ascii=False) + nick_id = self.get_nick_id(nick) + session = self.ssession() + try: + result = session.query(NickValues) \ + .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.sortingkey == sortingkey) \ + .filter(NickValues.key == key) \ + .one_or_none() + # NickValue exists, update + if result: + result.value = result.value + value + session.commit() + # DNE - Insert + else: + new_nickvalue = NickValues(nick_id=nick_id, sortingkey=sortingkey, key=key, value=value) + session.add(new_nickvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + # CHANNEL FUNCTIONS + + def set_channel_value(self, channel, key, value, sortingkey='unsorted'): + """Sets the value for a given key to be associated with the channel.""" + channel = Identifier(channel).lower() + value = json.dumps(value, ensure_ascii=False) + session = self.ssession() + try: + result = session.query(ChannelValues) \ + .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.sortingkey == sortingkey) \ + .filter(ChannelValues.key == key) \ + .one_or_none() + # ChannelValue exists, update + if result: + result.value = value + session.commit() + # DNE - Insert + else: + new_channelvalue = ChannelValues(channel=channel, sortingkey=sortingkey, key=key, value=value) + session.add(new_channelvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def get_channel_value(self, channel, key, sortingkey='unsorted'): + """Retrieves the value for a given key associated with a channel.""" + channel = Identifier(channel).lower() + session = self.ssession() + try: + result = session.query(ChannelValues) \ + .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.sortingkey == sortingkey) \ + .filter(ChannelValues.key == key) \ + .one_or_none() + if result is not None: + result = result.value + return _deserialize(result) + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def delete_channel_value(self, channel, key, sortingkey='unsorted'): + """Sets the value for a given key to be associated with the channel.""" + channel = Identifier(channel).lower() + session = self.ssession() + try: + result = session.query(ChannelValues) \ + .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.sortingkey == sortingkey) \ + .filter(ChannelValues.key == key) \ + .one_or_none() + # ChannelValue exists, delete + if result: + session.delete(result) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def adjust_channel_value(self, channel, key, value, sortingkey='unsorted'): + """Sets the value for a given key to be associated with the channel.""" + channel = Identifier(channel).lower() + value = json.dumps(value, ensure_ascii=False) + session = self.ssession() + try: + result = session.query(ChannelValues) \ + .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.sortingkey == sortingkey) \ + .filter(ChannelValues.key == key) \ + .one_or_none() + # ChannelValue exists, update + if result: + result.value = result.value + value + session.commit() + # DNE - Insert + else: + new_channelvalue = ChannelValues(channel=channel, sortingkey=sortingkey, key=key, value=value) + session.add(new_channelvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + # NICK AND CHANNEL FUNCTIONS + + def get_nick_or_channel_value(self, name, key, sortingkey='unsorted'): + """Gets the value `key` associated to the nick or channel `name`.""" + name = Identifier(name) + if name.is_nick(): + return self.get_nick_value(name, key, sortingkey) + else: + return self.get_channel_value(name, key, sortingkey) + + def get_preferred_value(self, names, key, sortingkey='unsorted'): + """Gets the value for the first name which has it set. + + `names` is a list of channel and/or user names. Returns None if none of + the names have the key set.""" + for name in names: + value = self.get_nick_or_channel_value(name, key, sortingkey) + if value is not None: + return value + + # PLUGIN FUNCTIONS + + def set_plugin_value(self, plugin, key, value, sortingkey='unsorted'): + """Sets the value for a given key to be associated with the plugin.""" + plugin = Identifier(plugin).lower() + value = json.dumps(value, ensure_ascii=False) + session = self.ssession() + try: + result = session.query(PluginValues) \ + .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.sortingkey == sortingkey) \ + .filter(PluginValues.key == key) \ + .one_or_none() + # PluginValues exists, update + if result: + result.value = value + session.commit() + # DNE - Insert + else: + new_pluginvalue = PluginValues(plugin=plugin, sortingkey=sortingkey, key=key, value=value) + session.add(new_pluginvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def get_plugin_value(self, plugin, key, sortingkey='unsorted'): + """Retrieves the value for a given key associated with a plugin.""" + plugin = Identifier(plugin).lower() + session = self.ssession() + try: + result = session.query(PluginValues) \ + .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.sortingkey == sortingkey) \ + .filter(PluginValues.key == key) \ + .one_or_none() + if result is not None: + result = result.value + return _deserialize(result) + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def adjust_plugin_value(self, plugin, key, value, sortingkey='unsorted'): + """Sets the value for a given key to be associated with the plugin.""" + plugin = Identifier(plugin).lower() + value = json.dumps(value, ensure_ascii=False) + session = self.ssession() + try: + result = session.query(PluginValues) \ + .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.sortingkey == sortingkey) \ + .filter(PluginValues.key == key) \ + .one_or_none() + # ChannelValue exists, update + if result: + result.value = result.value + value + session.commit() + # DNE - Insert + else: + new_pluginvalue = PluginValues(plugin=plugin, sortingkey=sortingkey, key=key, value=value) + session.add(new_pluginvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def delete_plugin_value(self, plugin, key, sortingkey='unsorted'): + """Deletes the value for a given key to be associated with the plugin.""" + plugin = Identifier(plugin).lower() + session = self.ssession() + try: + result = session.query(PluginValues) \ + .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.sortingkey == sortingkey) \ + .filter(PluginValues.key == key) \ + .one_or_none() + # PluginValues exists, delete + if result: + session.delete(result) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() From 05a1758aab0b5fda6f38b11dbe5f2e92984f0017 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 13:19:47 -0400 Subject: [PATCH 111/328] not defined --- sopel_modules/SpiceBot/Database.py | 678 +++++++++--------- .../Databaseaddons.py | 232 ------ .../SpiceBot_Database_Addons/__init__.py | 6 - 3 files changed, 339 insertions(+), 577 deletions(-) delete mode 100644 sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py delete mode 100644 sopel_modules/SpiceBot_Database_Addons/__init__.py diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 303c99c..f7648c6 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -21,6 +21,345 @@ import json BASE = declarative_base() +class PluginValues(BASE): + """ + PluginValues SQLAlchemy Class + """ + __tablename__ = 'plugin_values' + plugin = Column(String(255), primary_key=True) + sortingkey = Column(String(255), primary_key=True) + key = Column(String(255), primary_key=True) + value = Column(String(255)) + + +class NickValues(BASE): + """ + NickValues SQLAlchemy Class + """ + __tablename__ = 'nick_values' + nick_id = Column(Integer, ForeignKey('nick_ids.nick_id'), primary_key=True) + sortingkey = Column(String(255), primary_key=True) + key = Column(String(255), primary_key=True) + value = Column(String(255)) + + +class ChannelValues(BASE): + """ + ChannelValues SQLAlchemy Class + """ + __tablename__ = 'channel_values' + channel = Column(String(255), primary_key=True) + sortingkey = Column(String(255), primary_key=True) + key = Column(String(255), primary_key=True) + value = Column(String(255)) + + +class SpiceDB(object): + + # NICK FUNCTIONS + + def set_nick_value(self, nick, key, value, sortingkey='unsorted'): + """Sets the value for a given key to be associated with the nick.""" + nick = Identifier(nick) + value = json.dumps(value, ensure_ascii=False) + nick_id = self.get_nick_id(nick) + session = self.ssession() + try: + result = session.query(NickValues) \ + .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.sortingkey == sortingkey) \ + .filter(NickValues.key == key) \ + .one_or_none() + # NickValue exists, update + if result: + result.value = value + session.commit() + # DNE - Insert + else: + new_nickvalue = NickValues(nick_id=nick_id, sortingkey=sortingkey, key=key, value=value) + session.add(new_nickvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def get_nick_value(self, nick, key, sortingkey='unsorted'): + """Retrieves the value for a given key associated with a nick.""" + nick = Identifier(nick) + session = self.ssession() + try: + result = session.query(NickValues) \ + .filter(Nicknames.nick_id == NickValues.nick_id) \ + .filter(Nicknames.slug == nick.lower()) \ + .filter(NickValues.sortingkey == sortingkey) \ + .filter(NickValues.key == key) \ + .one_or_none() + if result is not None: + result = result.value + return _deserialize(result) + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def delete_nick_value(self, nick, key, sortingkey='unsorted'): + """Deletes the value for a given key to be associated with the nick.""" + nick = Identifier(nick) + nick_id = self.get_nick_id(nick) + session = self.ssession() + try: + result = session.query(NickValues) \ + .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.sortingkey == sortingkey) \ + .filter(NickValues.key == key) \ + .one_or_none() + # NickValue exists, delete + if result: + session.delete(result) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def adjust_nick_value(self, nick, key, value, sortingkey='unsorted'): + """Sets the value for a given key to be associated with the nick.""" + nick = Identifier(nick) + value = json.dumps(value, ensure_ascii=False) + nick_id = self.get_nick_id(nick) + session = self.ssession() + try: + result = session.query(NickValues) \ + .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.sortingkey == sortingkey) \ + .filter(NickValues.key == key) \ + .one_or_none() + # NickValue exists, update + if result: + result.value = result.value + value + session.commit() + # DNE - Insert + else: + new_nickvalue = NickValues(nick_id=nick_id, sortingkey=sortingkey, key=key, value=value) + session.add(new_nickvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + # CHANNEL FUNCTIONS + + def set_channel_value(self, channel, key, value, sortingkey='unsorted'): + """Sets the value for a given key to be associated with the channel.""" + channel = Identifier(channel).lower() + value = json.dumps(value, ensure_ascii=False) + session = self.ssession() + try: + result = session.query(ChannelValues) \ + .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.sortingkey == sortingkey) \ + .filter(ChannelValues.key == key) \ + .one_or_none() + # ChannelValue exists, update + if result: + result.value = value + session.commit() + # DNE - Insert + else: + new_channelvalue = ChannelValues(channel=channel, sortingkey=sortingkey, key=key, value=value) + session.add(new_channelvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def get_channel_value(self, channel, key, sortingkey='unsorted'): + """Retrieves the value for a given key associated with a channel.""" + channel = Identifier(channel).lower() + session = self.ssession() + try: + result = session.query(ChannelValues) \ + .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.sortingkey == sortingkey) \ + .filter(ChannelValues.key == key) \ + .one_or_none() + if result is not None: + result = result.value + return _deserialize(result) + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def delete_channel_value(self, channel, key, sortingkey='unsorted'): + """Sets the value for a given key to be associated with the channel.""" + channel = Identifier(channel).lower() + session = self.ssession() + try: + result = session.query(ChannelValues) \ + .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.sortingkey == sortingkey) \ + .filter(ChannelValues.key == key) \ + .one_or_none() + # ChannelValue exists, delete + if result: + session.delete(result) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def adjust_channel_value(self, channel, key, value, sortingkey='unsorted'): + """Sets the value for a given key to be associated with the channel.""" + channel = Identifier(channel).lower() + value = json.dumps(value, ensure_ascii=False) + session = self.ssession() + try: + result = session.query(ChannelValues) \ + .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.sortingkey == sortingkey) \ + .filter(ChannelValues.key == key) \ + .one_or_none() + # ChannelValue exists, update + if result: + result.value = result.value + value + session.commit() + # DNE - Insert + else: + new_channelvalue = ChannelValues(channel=channel, sortingkey=sortingkey, key=key, value=value) + session.add(new_channelvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + # NICK AND CHANNEL FUNCTIONS + + def get_nick_or_channel_value(self, name, key, sortingkey='unsorted'): + """Gets the value `key` associated to the nick or channel `name`.""" + name = Identifier(name) + if name.is_nick(): + return self.get_nick_value(name, key, sortingkey) + else: + return self.get_channel_value(name, key, sortingkey) + + def get_preferred_value(self, names, key, sortingkey='unsorted'): + """Gets the value for the first name which has it set. + + `names` is a list of channel and/or user names. Returns None if none of + the names have the key set.""" + for name in names: + value = self.get_nick_or_channel_value(name, key, sortingkey) + if value is not None: + return value + + # PLUGIN FUNCTIONS + + def set_plugin_value(self, plugin, key, value, sortingkey='unsorted'): + """Sets the value for a given key to be associated with the plugin.""" + plugin = Identifier(plugin).lower() + value = json.dumps(value, ensure_ascii=False) + session = self.ssession() + try: + result = session.query(PluginValues) \ + .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.sortingkey == sortingkey) \ + .filter(PluginValues.key == key) \ + .one_or_none() + # PluginValues exists, update + if result: + result.value = value + session.commit() + # DNE - Insert + else: + new_pluginvalue = PluginValues(plugin=plugin, sortingkey=sortingkey, key=key, value=value) + session.add(new_pluginvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def get_plugin_value(self, plugin, key, sortingkey='unsorted'): + """Retrieves the value for a given key associated with a plugin.""" + plugin = Identifier(plugin).lower() + session = self.ssession() + try: + result = session.query(PluginValues) \ + .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.sortingkey == sortingkey) \ + .filter(PluginValues.key == key) \ + .one_or_none() + if result is not None: + result = result.value + return _deserialize(result) + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def adjust_plugin_value(self, plugin, key, value, sortingkey='unsorted'): + """Sets the value for a given key to be associated with the plugin.""" + plugin = Identifier(plugin).lower() + value = json.dumps(value, ensure_ascii=False) + session = self.ssession() + try: + result = session.query(PluginValues) \ + .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.sortingkey == sortingkey) \ + .filter(PluginValues.key == key) \ + .one_or_none() + # ChannelValue exists, update + if result: + result.value = result.value + value + session.commit() + # DNE - Insert + else: + new_pluginvalue = PluginValues(plugin=plugin, sortingkey=sortingkey, key=key, value=value) + session.add(new_pluginvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def delete_plugin_value(self, plugin, key, sortingkey='unsorted'): + """Deletes the value for a given key to be associated with the plugin.""" + plugin = Identifier(plugin).lower() + session = self.ssession() + try: + result = session.query(PluginValues) \ + .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.sortingkey == sortingkey) \ + .filter(PluginValues.key == key) \ + .one_or_none() + # PluginValues exists, delete + if result: + session.delete(result) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + class BotDatabase(): """A thread safe database cache""" @@ -402,342 +741,3 @@ class BotDatabase(): db = BotDatabase() - - -class PluginValues(BASE): - """ - PluginValues SQLAlchemy Class - """ - __tablename__ = 'plugin_values' - plugin = Column(String(255), primary_key=True) - sortingkey = Column(String(255), primary_key=True) - key = Column(String(255), primary_key=True) - value = Column(String(255)) - - -class NickValues(BASE): - """ - NickValues SQLAlchemy Class - """ - __tablename__ = 'nick_values' - nick_id = Column(Integer, ForeignKey('nick_ids.nick_id'), primary_key=True) - sortingkey = Column(String(255), primary_key=True) - key = Column(String(255), primary_key=True) - value = Column(String(255)) - - -class ChannelValues(BASE): - """ - ChannelValues SQLAlchemy Class - """ - __tablename__ = 'channel_values' - channel = Column(String(255), primary_key=True) - sortingkey = Column(String(255), primary_key=True) - key = Column(String(255), primary_key=True) - value = Column(String(255)) - - -class SpiceDB(object): - - # NICK FUNCTIONS - - def set_nick_value(self, nick, key, value, sortingkey='unsorted'): - """Sets the value for a given key to be associated with the nick.""" - nick = Identifier(nick) - value = json.dumps(value, ensure_ascii=False) - nick_id = self.get_nick_id(nick) - session = self.ssession() - try: - result = session.query(NickValues) \ - .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.sortingkey == sortingkey) \ - .filter(NickValues.key == key) \ - .one_or_none() - # NickValue exists, update - if result: - result.value = value - session.commit() - # DNE - Insert - else: - new_nickvalue = NickValues(nick_id=nick_id, sortingkey=sortingkey, key=key, value=value) - session.add(new_nickvalue) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def get_nick_value(self, nick, key, sortingkey='unsorted'): - """Retrieves the value for a given key associated with a nick.""" - nick = Identifier(nick) - session = self.ssession() - try: - result = session.query(NickValues) \ - .filter(Nicknames.nick_id == NickValues.nick_id) \ - .filter(Nicknames.slug == nick.lower()) \ - .filter(NickValues.sortingkey == sortingkey) \ - .filter(NickValues.key == key) \ - .one_or_none() - if result is not None: - result = result.value - return _deserialize(result) - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def delete_nick_value(self, nick, key, sortingkey='unsorted'): - """Deletes the value for a given key to be associated with the nick.""" - nick = Identifier(nick) - nick_id = self.get_nick_id(nick) - session = self.ssession() - try: - result = session.query(NickValues) \ - .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.sortingkey == sortingkey) \ - .filter(NickValues.key == key) \ - .one_or_none() - # NickValue exists, delete - if result: - session.delete(result) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def adjust_nick_value(self, nick, key, value, sortingkey='unsorted'): - """Sets the value for a given key to be associated with the nick.""" - nick = Identifier(nick) - value = json.dumps(value, ensure_ascii=False) - nick_id = self.get_nick_id(nick) - session = self.ssession() - try: - result = session.query(NickValues) \ - .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.sortingkey == sortingkey) \ - .filter(NickValues.key == key) \ - .one_or_none() - # NickValue exists, update - if result: - result.value = result.value + value - session.commit() - # DNE - Insert - else: - new_nickvalue = NickValues(nick_id=nick_id, sortingkey=sortingkey, key=key, value=value) - session.add(new_nickvalue) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - # CHANNEL FUNCTIONS - - def set_channel_value(self, channel, key, value, sortingkey='unsorted'): - """Sets the value for a given key to be associated with the channel.""" - channel = Identifier(channel).lower() - value = json.dumps(value, ensure_ascii=False) - session = self.ssession() - try: - result = session.query(ChannelValues) \ - .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.sortingkey == sortingkey) \ - .filter(ChannelValues.key == key) \ - .one_or_none() - # ChannelValue exists, update - if result: - result.value = value - session.commit() - # DNE - Insert - else: - new_channelvalue = ChannelValues(channel=channel, sortingkey=sortingkey, key=key, value=value) - session.add(new_channelvalue) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def get_channel_value(self, channel, key, sortingkey='unsorted'): - """Retrieves the value for a given key associated with a channel.""" - channel = Identifier(channel).lower() - session = self.ssession() - try: - result = session.query(ChannelValues) \ - .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.sortingkey == sortingkey) \ - .filter(ChannelValues.key == key) \ - .one_or_none() - if result is not None: - result = result.value - return _deserialize(result) - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def delete_channel_value(self, channel, key, sortingkey='unsorted'): - """Sets the value for a given key to be associated with the channel.""" - channel = Identifier(channel).lower() - session = self.ssession() - try: - result = session.query(ChannelValues) \ - .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.sortingkey == sortingkey) \ - .filter(ChannelValues.key == key) \ - .one_or_none() - # ChannelValue exists, delete - if result: - session.delete(result) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def adjust_channel_value(self, channel, key, value, sortingkey='unsorted'): - """Sets the value for a given key to be associated with the channel.""" - channel = Identifier(channel).lower() - value = json.dumps(value, ensure_ascii=False) - session = self.ssession() - try: - result = session.query(ChannelValues) \ - .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.sortingkey == sortingkey) \ - .filter(ChannelValues.key == key) \ - .one_or_none() - # ChannelValue exists, update - if result: - result.value = result.value + value - session.commit() - # DNE - Insert - else: - new_channelvalue = ChannelValues(channel=channel, sortingkey=sortingkey, key=key, value=value) - session.add(new_channelvalue) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - # NICK AND CHANNEL FUNCTIONS - - def get_nick_or_channel_value(self, name, key, sortingkey='unsorted'): - """Gets the value `key` associated to the nick or channel `name`.""" - name = Identifier(name) - if name.is_nick(): - return self.get_nick_value(name, key, sortingkey) - else: - return self.get_channel_value(name, key, sortingkey) - - def get_preferred_value(self, names, key, sortingkey='unsorted'): - """Gets the value for the first name which has it set. - - `names` is a list of channel and/or user names. Returns None if none of - the names have the key set.""" - for name in names: - value = self.get_nick_or_channel_value(name, key, sortingkey) - if value is not None: - return value - - # PLUGIN FUNCTIONS - - def set_plugin_value(self, plugin, key, value, sortingkey='unsorted'): - """Sets the value for a given key to be associated with the plugin.""" - plugin = Identifier(plugin).lower() - value = json.dumps(value, ensure_ascii=False) - session = self.ssession() - try: - result = session.query(PluginValues) \ - .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.sortingkey == sortingkey) \ - .filter(PluginValues.key == key) \ - .one_or_none() - # PluginValues exists, update - if result: - result.value = value - session.commit() - # DNE - Insert - else: - new_pluginvalue = PluginValues(plugin=plugin, sortingkey=sortingkey, key=key, value=value) - session.add(new_pluginvalue) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def get_plugin_value(self, plugin, key, sortingkey='unsorted'): - """Retrieves the value for a given key associated with a plugin.""" - plugin = Identifier(plugin).lower() - session = self.ssession() - try: - result = session.query(PluginValues) \ - .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.sortingkey == sortingkey) \ - .filter(PluginValues.key == key) \ - .one_or_none() - if result is not None: - result = result.value - return _deserialize(result) - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def adjust_plugin_value(self, plugin, key, value, sortingkey='unsorted'): - """Sets the value for a given key to be associated with the plugin.""" - plugin = Identifier(plugin).lower() - value = json.dumps(value, ensure_ascii=False) - session = self.ssession() - try: - result = session.query(PluginValues) \ - .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.sortingkey == sortingkey) \ - .filter(PluginValues.key == key) \ - .one_or_none() - # ChannelValue exists, update - if result: - result.value = result.value + value - session.commit() - # DNE - Insert - else: - new_pluginvalue = PluginValues(plugin=plugin, sortingkey=sortingkey, key=key, value=value) - session.add(new_pluginvalue) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def delete_plugin_value(self, plugin, key, sortingkey='unsorted'): - """Deletes the value for a given key to be associated with the plugin.""" - plugin = Identifier(plugin).lower() - session = self.ssession() - try: - result = session.query(PluginValues) \ - .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.sortingkey == sortingkey) \ - .filter(PluginValues.key == key) \ - .one_or_none() - # PluginValues exists, delete - if result: - session.delete(result) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() diff --git a/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py b/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py deleted file mode 100644 index 1d919e5..0000000 --- a/sopel_modules/SpiceBot_Database_Addons/Databaseaddons.py +++ /dev/null @@ -1,232 +0,0 @@ -#!/usr/bin/env python -# coding=utf-8 -from __future__ import unicode_literals, absolute_import, print_function, division - -# sopel imports -import sopel.module -from sopel.tools import Identifier -import sopel.db -from sopel.db import SopelDB, NickValues, ChannelValues, _deserialize - -from sqlalchemy import Column, String -from sqlalchemy.exc import SQLAlchemyError -from sqlalchemy.ext.declarative import declarative_base -import json - -import sopel_modules.SpiceBot as SpiceBot - -BASE = declarative_base() - - -def setup(bot): - - # Inject Database Functions - SpiceBot.logs.log('SpiceBot_Databaseaddons', "Implanting Database functions into bot") - sopel.db.PluginValues = PluginValues - - SopelDB.delete_nick_value = SopelDBAddon.delete_nick_value - SopelDB.adjust_nick_value = SopelDBAddon.adjust_nick_value - - SopelDB.delete_channel_value = SopelDBAddon.delete_channel_value - SopelDB.adjust_channel_value = SopelDBAddon.adjust_channel_value - - SopelDB.get_plugin_value = SopelDBAddon.get_plugin_value - SopelDB.set_plugin_value = SopelDBAddon.set_plugin_value - SopelDB.delete_plugin_value = SopelDBAddon.delete_plugin_value - SopelDB.adjust_plugin_value = SopelDBAddon.adjust_plugin_value - - -class PluginValues(BASE): - """ - PluginValues SQLAlchemy Class - """ - __tablename__ = 'plugin_values' - plugin = Column(String(255), primary_key=True) - key = Column(String(255), primary_key=True) - value = Column(String(255)) - - -class SopelDBAddon: - - """Nicks""" - - def delete_nick_value(self, nick, key): - """Deletes the value for a given key to be associated with the nick.""" - nick = Identifier(nick) - nick_id = self.get_nick_id(nick) - session = self.ssession() - try: - result = session.query(NickValues) \ - .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.key == key) \ - .one_or_none() - # NickValue exists, delete - if result: - session.delete(result) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def adjust_nick_value(self, nick, key, value): - """Sets the value for a given key to be associated with the nick.""" - nick = Identifier(nick) - value = json.dumps(value, ensure_ascii=False) - nick_id = self.get_nick_id(nick) - session = self.ssession() - try: - result = session.query(NickValues) \ - .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.key == key) \ - .one_or_none() - # NickValue exists, update - if result: - result.value = result.value + value - session.commit() - # DNE - Insert - else: - new_nickvalue = NickValues(nick_id=nick_id, key=key, value=value) - session.add(new_nickvalue) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - """Channels""" - - def delete_channel_value(self, channel, key): - """Sets the value for a given key to be associated with the channel.""" - channel = Identifier(channel).lower() - session = self.ssession() - try: - result = session.query(ChannelValues) \ - .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.key == key) \ - .one_or_none() - # ChannelValue exists, delete - if result: - session.delete(result) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def adjust_channel_value(self, channel, key, value): - """Sets the value for a given key to be associated with the channel.""" - channel = Identifier(channel).lower() - value = json.dumps(value, ensure_ascii=False) - session = self.ssession() - try: - result = session.query(ChannelValues) \ - .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.key == key) \ - .one_or_none() - # ChannelValue exists, update - if result: - result.value = result.value + value - session.commit() - # DNE - Insert - else: - new_channelvalue = ChannelValues(channel=channel, key=key, value=value) - session.add(new_channelvalue) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - # PLUGIN FUNCTIONS - - def set_plugin_value(self, plugin, key, value): - """Sets the value for a given key to be associated with the plugin.""" - plugin = Identifier(plugin).lower() - value = json.dumps(value, ensure_ascii=False) - session = self.ssession() - try: - result = session.query(PluginValues) \ - .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.key == key) \ - .one_or_none() - # PluginValues exists, update - if result: - result.value = value - session.commit() - # DNE - Insert - else: - new_pluginvalue = PluginValues(plugin=plugin, key=key, value=value) - session.add(new_pluginvalue) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def get_plugin_value(self, plugin, key): - """Retrieves the value for a given key associated with a plugin.""" - plugin = Identifier(plugin).lower() - session = self.ssession() - try: - result = session.query(PluginValues) \ - .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.key == key) \ - .one_or_none() - if result is not None: - result = result.value - return _deserialize(result) - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def adjust_plugin_value(self, plugin, key, value): - """Sets the value for a given key to be associated with the plugin.""" - plugin = Identifier(plugin).lower() - value = json.dumps(value, ensure_ascii=False) - session = self.ssession() - try: - result = session.query(PluginValues) \ - .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.key == key) \ - .one_or_none() - # ChannelValue exists, update - if result: - result.value = result.value + value - session.commit() - # DNE - Insert - else: - new_pluginvalue = PluginValues(plugin=plugin, key=key, value=value) - session.add(new_pluginvalue) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def delete_plugin_value(self, plugin, key): - """Deletes the value for a given key to be associated with the plugin.""" - plugin = Identifier(plugin).lower() - session = self.ssession() - try: - result = session.query(PluginValues) \ - .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.key == key) \ - .one_or_none() - # PluginValues exists, delete - if result: - session.delete(result) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() diff --git a/sopel_modules/SpiceBot_Database_Addons/__init__.py b/sopel_modules/SpiceBot_Database_Addons/__init__.py deleted file mode 100644 index 31715ae..0000000 --- a/sopel_modules/SpiceBot_Database_Addons/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# coding=utf-8 -"""Useful miscellaneous tools and shortcuts for SpiceBot Sopel modules -""" -from __future__ import unicode_literals, absolute_import, print_function, division - -from .Databaseaddons import * From 80128d90ea5b7c09d03bc8932c480c3522fd1580 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 13:31:08 -0400 Subject: [PATCH 112/328] revert to injection --- sopel_modules/SpiceBot/Database.py | 35 +++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index f7648c6..b170428 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -6,6 +6,7 @@ This is the SpiceBot Database # sopel imports from sopel.tools import Identifier +import sopel.db from sopel.db import SopelDB, Nicknames, _deserialize import threading @@ -369,23 +370,27 @@ class BotDatabase(): "nicks": {}, "channels": {}, } + + sopel.db.NickValues = NickValues + SopelDB.get_nick_value = SpiceDB.get_nick_value + SopelDB.set_nick_value = SpiceDB.set_nick_value + SopelDB.delete_nick_value = SpiceDB.delete_nick_value + SopelDB.adjust_nick_value = SpiceDB.adjust_nick_value + + sopel.db.ChannelValues = ChannelValues + SopelDB.get_channel_value = SpiceDB.get_channel_value + SopelDB.set_channel_value = SpiceDB.set_channel_value + SopelDB.delete_channel_value = SpiceDB.delete_channel_value + SopelDB.adjust_channel_value = SpiceDB.adjust_channel_value + + sopel.db.PluginValues = PluginValues + SopelDB.get_plugin_value = SpiceDB.get_plugin_value + SopelDB.set_plugin_value = SpiceDB.set_plugin_value + SopelDB.delete_plugin_value = SpiceDB.delete_plugin_value + SopelDB.adjust_plugin_value = SpiceDB.adjust_plugin_value + self.db = SopelDB(botconfig.config) - self.db.get_nick_value = SpiceDB.get_nick_value - self.db.set_nick_value = SpiceDB.set_nick_value - self.db.delete_nick_value = SpiceDB.delete_nick_value - self.db.adjust_nick_value = SpiceDB.adjust_nick_value - - self.db.get_channel_value = SpiceDB.get_channel_value - self.db.set_channel_value = SpiceDB.set_channel_value - self.db.delete_channel_value = SpiceDB.delete_channel_value - self.db.adjust_channel_value = SpiceDB.adjust_channel_value - - self.db.get_plugin_value = SpiceDB.get_plugin_value - self.db.set_plugin_value = SpiceDB.set_plugin_value - self.db.delete_plugin_value = SpiceDB.delete_plugin_value - self.db.adjust_plugin_value = SpiceDB.adjust_plugin_value - """Nick""" def get_nick_value(self, nick, key, sorting_key='unsorted'): From 44298e1e1a8cb1bd7e17d6eb81ca2d9f6b21b246 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 13:47:29 -0400 Subject: [PATCH 113/328] test --- sopel_modules/SpiceBot/Database.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index b170428..7066961 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -12,7 +12,7 @@ from sopel.db import SopelDB, Nicknames, _deserialize import threading from .Config import config as botconfig -from sqlalchemy import Column, ForeignKey, Integer, String +from sqlalchemy import Column, ForeignKey, Integer, String, PrimaryKeyConstraint from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.exc import SQLAlchemyError @@ -27,9 +27,12 @@ class PluginValues(BASE): PluginValues SQLAlchemy Class """ __tablename__ = 'plugin_values' - plugin = Column(String(255), primary_key=True) - sortingkey = Column(String(255), primary_key=True) - key = Column(String(255), primary_key=True) + __table_args__ = ( + PrimaryKeyConstraint('plugin', 'sortingkey', 'key'), + ) + plugin = Column(String(255)) + sortingkey = Column(String(255)) + key = Column(String(255)) value = Column(String(255)) @@ -38,9 +41,12 @@ class NickValues(BASE): NickValues SQLAlchemy Class """ __tablename__ = 'nick_values' - nick_id = Column(Integer, ForeignKey('nick_ids.nick_id'), primary_key=True) - sortingkey = Column(String(255), primary_key=True) - key = Column(String(255), primary_key=True) + __table_args__ = ( + PrimaryKeyConstraint('nick_id', 'sortingkey', 'key'), + ) + nick_id = Column(Integer, ForeignKey('nick_ids.nick_id')) + sortingkey = Column(String(255)) + key = Column(String(255)) value = Column(String(255)) @@ -49,9 +55,12 @@ class ChannelValues(BASE): ChannelValues SQLAlchemy Class """ __tablename__ = 'channel_values' - channel = Column(String(255), primary_key=True) - sortingkey = Column(String(255), primary_key=True) - key = Column(String(255), primary_key=True) + __table_args__ = ( + PrimaryKeyConstraint('channel', 'sortingkey', 'key'), + ) + channel = Column(String(255)) + sortingkey = Column(String(255)) + key = Column(String(255)) value = Column(String(255)) From b2622736fe4e2f12bf049749c769552057ab1f0e Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 13:53:56 -0400 Subject: [PATCH 114/328] index --- sopel_modules/SpiceBot/Database.py | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 7066961..8413881 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -12,7 +12,7 @@ from sopel.db import SopelDB, Nicknames, _deserialize import threading from .Config import config as botconfig -from sqlalchemy import Column, ForeignKey, Integer, String, PrimaryKeyConstraint +from sqlalchemy import Column, ForeignKey, Integer, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.exc import SQLAlchemyError @@ -27,12 +27,9 @@ class PluginValues(BASE): PluginValues SQLAlchemy Class """ __tablename__ = 'plugin_values' - __table_args__ = ( - PrimaryKeyConstraint('plugin', 'sortingkey', 'key'), - ) - plugin = Column(String(255)) - sortingkey = Column(String(255)) - key = Column(String(255)) + plugin = Column(String(255), primary_key=True) + sortingkey = Column(String(255), index=True) + key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -41,12 +38,9 @@ class NickValues(BASE): NickValues SQLAlchemy Class """ __tablename__ = 'nick_values' - __table_args__ = ( - PrimaryKeyConstraint('nick_id', 'sortingkey', 'key'), - ) - nick_id = Column(Integer, ForeignKey('nick_ids.nick_id')) - sortingkey = Column(String(255)) - key = Column(String(255)) + nick_id = Column(Integer, ForeignKey('nick_ids.nick_id'), primary_key=True) + sortingkey = Column(String(255), index=True) + key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -55,12 +49,9 @@ class ChannelValues(BASE): ChannelValues SQLAlchemy Class """ __tablename__ = 'channel_values' - __table_args__ = ( - PrimaryKeyConstraint('channel', 'sortingkey', 'key'), - ) - channel = Column(String(255)) - sortingkey = Column(String(255)) - key = Column(String(255)) + channel = Column(String(255), primary_key=True) + sortingkey = Column(String(255), index=True) + key = Column(String(255), primary_key=True) value = Column(String(255)) From 53f2d2e040bfe7a8003eed1d9fe7460c778b043a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 13:54:43 -0400 Subject: [PATCH 115/328] indexkey --- sopel_modules/SpiceBot/Database.py | 76 +++++++++++++++--------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 8413881..aa88bc8 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -28,7 +28,7 @@ class PluginValues(BASE): """ __tablename__ = 'plugin_values' plugin = Column(String(255), primary_key=True) - sortingkey = Column(String(255), index=True) + indexkey = Column(String(255), index=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -39,7 +39,7 @@ class NickValues(BASE): """ __tablename__ = 'nick_values' nick_id = Column(Integer, ForeignKey('nick_ids.nick_id'), primary_key=True) - sortingkey = Column(String(255), index=True) + indexkey = Column(String(255), index=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -50,7 +50,7 @@ class ChannelValues(BASE): """ __tablename__ = 'channel_values' channel = Column(String(255), primary_key=True) - sortingkey = Column(String(255), index=True) + indexkey = Column(String(255), index=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -59,7 +59,7 @@ class SpiceDB(object): # NICK FUNCTIONS - def set_nick_value(self, nick, key, value, sortingkey='unsorted'): + def set_nick_value(self, nick, key, value, indexkey='unsorted'): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) value = json.dumps(value, ensure_ascii=False) @@ -68,7 +68,7 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.sortingkey == sortingkey) \ + .filter(NickValues.indexkey == indexkey) \ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, update @@ -77,7 +77,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_nickvalue = NickValues(nick_id=nick_id, sortingkey=sortingkey, key=key, value=value) + new_nickvalue = NickValues(nick_id=nick_id, indexkey=indexkey, key=key, value=value) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -86,7 +86,7 @@ class SpiceDB(object): finally: session.close() - def get_nick_value(self, nick, key, sortingkey='unsorted'): + def get_nick_value(self, nick, key, indexkey='unsorted'): """Retrieves the value for a given key associated with a nick.""" nick = Identifier(nick) session = self.ssession() @@ -94,7 +94,7 @@ class SpiceDB(object): result = session.query(NickValues) \ .filter(Nicknames.nick_id == NickValues.nick_id) \ .filter(Nicknames.slug == nick.lower()) \ - .filter(NickValues.sortingkey == sortingkey) \ + .filter(NickValues.indexkey == indexkey) \ .filter(NickValues.key == key) \ .one_or_none() if result is not None: @@ -106,7 +106,7 @@ class SpiceDB(object): finally: session.close() - def delete_nick_value(self, nick, key, sortingkey='unsorted'): + def delete_nick_value(self, nick, key, indexkey='unsorted'): """Deletes the value for a given key to be associated with the nick.""" nick = Identifier(nick) nick_id = self.get_nick_id(nick) @@ -114,7 +114,7 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.sortingkey == sortingkey) \ + .filter(NickValues.indexkey == indexkey) \ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, delete @@ -127,7 +127,7 @@ class SpiceDB(object): finally: session.close() - def adjust_nick_value(self, nick, key, value, sortingkey='unsorted'): + def adjust_nick_value(self, nick, key, value, indexkey='unsorted'): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) value = json.dumps(value, ensure_ascii=False) @@ -136,7 +136,7 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.sortingkey == sortingkey) \ + .filter(NickValues.indexkey == indexkey) \ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, update @@ -145,7 +145,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_nickvalue = NickValues(nick_id=nick_id, sortingkey=sortingkey, key=key, value=value) + new_nickvalue = NickValues(nick_id=nick_id, indexkey=indexkey, key=key, value=value) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -156,7 +156,7 @@ class SpiceDB(object): # CHANNEL FUNCTIONS - def set_channel_value(self, channel, key, value, sortingkey='unsorted'): + def set_channel_value(self, channel, key, value, indexkey='unsorted'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() value = json.dumps(value, ensure_ascii=False) @@ -164,7 +164,7 @@ class SpiceDB(object): try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.sortingkey == sortingkey) \ + .filter(ChannelValues.indexkey == indexkey) \ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -173,7 +173,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_channelvalue = ChannelValues(channel=channel, sortingkey=sortingkey, key=key, value=value) + new_channelvalue = ChannelValues(channel=channel, indexkey=indexkey, key=key, value=value) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -182,14 +182,14 @@ class SpiceDB(object): finally: session.close() - def get_channel_value(self, channel, key, sortingkey='unsorted'): + def get_channel_value(self, channel, key, indexkey='unsorted'): """Retrieves the value for a given key associated with a channel.""" channel = Identifier(channel).lower() session = self.ssession() try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.sortingkey == sortingkey) \ + .filter(ChannelValues.indexkey == indexkey) \ .filter(ChannelValues.key == key) \ .one_or_none() if result is not None: @@ -201,14 +201,14 @@ class SpiceDB(object): finally: session.close() - def delete_channel_value(self, channel, key, sortingkey='unsorted'): + def delete_channel_value(self, channel, key, indexkey='unsorted'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() session = self.ssession() try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.sortingkey == sortingkey) \ + .filter(ChannelValues.indexkey == indexkey) \ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, delete @@ -221,7 +221,7 @@ class SpiceDB(object): finally: session.close() - def adjust_channel_value(self, channel, key, value, sortingkey='unsorted'): + def adjust_channel_value(self, channel, key, value, indexkey='unsorted'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() value = json.dumps(value, ensure_ascii=False) @@ -229,7 +229,7 @@ class SpiceDB(object): try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.sortingkey == sortingkey) \ + .filter(ChannelValues.indexkey == indexkey) \ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -238,7 +238,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_channelvalue = ChannelValues(channel=channel, sortingkey=sortingkey, key=key, value=value) + new_channelvalue = ChannelValues(channel=channel, indexkey=indexkey, key=key, value=value) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -249,27 +249,27 @@ class SpiceDB(object): # NICK AND CHANNEL FUNCTIONS - def get_nick_or_channel_value(self, name, key, sortingkey='unsorted'): + def get_nick_or_channel_value(self, name, key, indexkey='unsorted'): """Gets the value `key` associated to the nick or channel `name`.""" name = Identifier(name) if name.is_nick(): - return self.get_nick_value(name, key, sortingkey) + return self.get_nick_value(name, key, indexkey) else: - return self.get_channel_value(name, key, sortingkey) + return self.get_channel_value(name, key, indexkey) - def get_preferred_value(self, names, key, sortingkey='unsorted'): + def get_preferred_value(self, names, key, indexkey='unsorted'): """Gets the value for the first name which has it set. `names` is a list of channel and/or user names. Returns None if none of the names have the key set.""" for name in names: - value = self.get_nick_or_channel_value(name, key, sortingkey) + value = self.get_nick_or_channel_value(name, key, indexkey) if value is not None: return value # PLUGIN FUNCTIONS - def set_plugin_value(self, plugin, key, value, sortingkey='unsorted'): + def set_plugin_value(self, plugin, key, value, indexkey='unsorted'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -277,7 +277,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.sortingkey == sortingkey) \ + .filter(PluginValues.indexkey == indexkey) \ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, update @@ -286,7 +286,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, sortingkey=sortingkey, key=key, value=value) + new_pluginvalue = PluginValues(plugin=plugin, indexkey=indexkey, key=key, value=value) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -295,14 +295,14 @@ class SpiceDB(object): finally: session.close() - def get_plugin_value(self, plugin, key, sortingkey='unsorted'): + def get_plugin_value(self, plugin, key, indexkey='unsorted'): """Retrieves the value for a given key associated with a plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.sortingkey == sortingkey) \ + .filter(PluginValues.indexkey == indexkey) \ .filter(PluginValues.key == key) \ .one_or_none() if result is not None: @@ -314,7 +314,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_value(self, plugin, key, value, sortingkey='unsorted'): + def adjust_plugin_value(self, plugin, key, value, indexkey='unsorted'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -322,7 +322,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.sortingkey == sortingkey) \ + .filter(PluginValues.indexkey == indexkey) \ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -331,7 +331,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, sortingkey=sortingkey, key=key, value=value) + new_pluginvalue = PluginValues(plugin=plugin, indexkey=indexkey, key=key, value=value) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -340,14 +340,14 @@ class SpiceDB(object): finally: session.close() - def delete_plugin_value(self, plugin, key, sortingkey='unsorted'): + def delete_plugin_value(self, plugin, key, indexkey='unsorted'): """Deletes the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.sortingkey == sortingkey) \ + .filter(PluginValues.indexkey == indexkey) \ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, delete From e2fd7fd8970c5f7a361601a5d4c20434cef1bfcd Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 13:56:02 -0400 Subject: [PATCH 116/328] naming --- sopel_modules/SpiceBot/Database.py | 66 +++++++++++++++--------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index aa88bc8..70e7292 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -59,7 +59,7 @@ class SpiceDB(object): # NICK FUNCTIONS - def set_nick_value(self, nick, key, value, indexkey='unsorted'): + def set_nick_value(self, nick, key, value, indexkey='defaultindex'): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) value = json.dumps(value, ensure_ascii=False) @@ -86,7 +86,7 @@ class SpiceDB(object): finally: session.close() - def get_nick_value(self, nick, key, indexkey='unsorted'): + def get_nick_value(self, nick, key, indexkey='defaultindex'): """Retrieves the value for a given key associated with a nick.""" nick = Identifier(nick) session = self.ssession() @@ -106,7 +106,7 @@ class SpiceDB(object): finally: session.close() - def delete_nick_value(self, nick, key, indexkey='unsorted'): + def delete_nick_value(self, nick, key, indexkey='defaultindex'): """Deletes the value for a given key to be associated with the nick.""" nick = Identifier(nick) nick_id = self.get_nick_id(nick) @@ -127,7 +127,7 @@ class SpiceDB(object): finally: session.close() - def adjust_nick_value(self, nick, key, value, indexkey='unsorted'): + def adjust_nick_value(self, nick, key, value, indexkey='defaultindex'): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) value = json.dumps(value, ensure_ascii=False) @@ -156,7 +156,7 @@ class SpiceDB(object): # CHANNEL FUNCTIONS - def set_channel_value(self, channel, key, value, indexkey='unsorted'): + def set_channel_value(self, channel, key, value, indexkey='defaultindex'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() value = json.dumps(value, ensure_ascii=False) @@ -182,7 +182,7 @@ class SpiceDB(object): finally: session.close() - def get_channel_value(self, channel, key, indexkey='unsorted'): + def get_channel_value(self, channel, key, indexkey='defaultindex'): """Retrieves the value for a given key associated with a channel.""" channel = Identifier(channel).lower() session = self.ssession() @@ -201,7 +201,7 @@ class SpiceDB(object): finally: session.close() - def delete_channel_value(self, channel, key, indexkey='unsorted'): + def delete_channel_value(self, channel, key, indexkey='defaultindex'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() session = self.ssession() @@ -221,7 +221,7 @@ class SpiceDB(object): finally: session.close() - def adjust_channel_value(self, channel, key, value, indexkey='unsorted'): + def adjust_channel_value(self, channel, key, value, indexkey='defaultindex'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() value = json.dumps(value, ensure_ascii=False) @@ -249,7 +249,7 @@ class SpiceDB(object): # NICK AND CHANNEL FUNCTIONS - def get_nick_or_channel_value(self, name, key, indexkey='unsorted'): + def get_nick_or_channel_value(self, name, key, indexkey='defaultindex'): """Gets the value `key` associated to the nick or channel `name`.""" name = Identifier(name) if name.is_nick(): @@ -257,7 +257,7 @@ class SpiceDB(object): else: return self.get_channel_value(name, key, indexkey) - def get_preferred_value(self, names, key, indexkey='unsorted'): + def get_preferred_value(self, names, key, indexkey='defaultindex'): """Gets the value for the first name which has it set. `names` is a list of channel and/or user names. Returns None if none of @@ -269,7 +269,7 @@ class SpiceDB(object): # PLUGIN FUNCTIONS - def set_plugin_value(self, plugin, key, value, indexkey='unsorted'): + def set_plugin_value(self, plugin, key, value, indexkey='defaultindex'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -295,7 +295,7 @@ class SpiceDB(object): finally: session.close() - def get_plugin_value(self, plugin, key, indexkey='unsorted'): + def get_plugin_value(self, plugin, key, indexkey='defaultindex'): """Retrieves the value for a given key associated with a plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() @@ -314,7 +314,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_value(self, plugin, key, value, indexkey='unsorted'): + def adjust_plugin_value(self, plugin, key, value, indexkey='defaultindex'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -340,7 +340,7 @@ class SpiceDB(object): finally: session.close() - def delete_plugin_value(self, plugin, key, indexkey='unsorted'): + def delete_plugin_value(self, plugin, key, indexkey='defaultindex'): """Deletes the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() @@ -393,7 +393,7 @@ class BotDatabase(): """Nick""" - def get_nick_value(self, nick, key, sorting_key='unsorted'): + def get_nick_value(self, nick, key, sorting_key='defaultindex'): self.lock.acquire() @@ -413,7 +413,7 @@ class BotDatabase(): else: return self.dict["nicks"][nick_id][sorting_key][key] - def set_nick_value(self, nick, key, value, sorting_key='unsorted'): + def set_nick_value(self, nick, key, value, sorting_key='defaultindex'): self.lock.acquire() @@ -432,7 +432,7 @@ class BotDatabase(): self.lock.release() - def delete_nick_value(self, nick, key, sorting_key='unsorted'): + def delete_nick_value(self, nick, key, sorting_key='defaultindex'): self.lock.acquire() @@ -450,7 +450,7 @@ class BotDatabase(): self.lock.release() - def adjust_nick_value(self, nick, key, value, sorting_key='unsorted'): + def adjust_nick_value(self, nick, key, value, sorting_key='defaultindex'): self.lock.acquire() @@ -476,7 +476,7 @@ class BotDatabase(): self.lock.release() - def adjust_nick_list(self, nick, key, entries, adjustmentdirection, sorting_key='unsorted'): + def adjust_nick_list(self, nick, key, entries, adjustmentdirection, sorting_key='defaultindex'): self.lock.acquire() @@ -509,16 +509,16 @@ class BotDatabase(): """Bot""" - def get_bot_value(self, key, sorting_key='unsorted'): + def get_bot_value(self, key, sorting_key='defaultindex'): return self.get_nick_value(botconfig.nick, key, sorting_key) - def set_bot_value(self, key, value, sorting_key='unsorted'): + def set_bot_value(self, key, value, sorting_key='defaultindex'): return self.set_nick_value(botconfig.nick, key, value, sorting_key) - def delete_bot_value(self, key, sorting_key='unsorted'): + def delete_bot_value(self, key, sorting_key='defaultindex'): return self.delete_nick_value(botconfig.nick, key, sorting_key) - def adjust_bot_value(self, key, value, sorting_key='unsorted'): + def adjust_bot_value(self, key, value, sorting_key='defaultindex'): return self.adjust_nick_value(botconfig.nick, key, value, sorting_key) def adjust_bot_list(self, key, entries, adjustmentdirection, sorting_key): @@ -526,7 +526,7 @@ class BotDatabase(): """Channels""" - def get_channel_value(self, channel, key, sorting_key='unsorted'): + def get_channel_value(self, channel, key, sorting_key='defaultindex'): self.lock.acquire() @@ -545,7 +545,7 @@ class BotDatabase(): else: return self.dict["channels"][channel][sorting_key][key] - def set_channel_value(self, channel, key, value, sorting_key='unsorted'): + def set_channel_value(self, channel, key, value, sorting_key='defaultindex'): self.lock.acquire() @@ -562,7 +562,7 @@ class BotDatabase(): self.lock.release() - def delete_channel_value(self, channel, key, sorting_key='unsorted'): + def delete_channel_value(self, channel, key, sorting_key='defaultindex'): self.lock.acquire() @@ -579,7 +579,7 @@ class BotDatabase(): self.lock.release() - def adjust_channel_value(self, channel, key, value, sorting_key='unsorted'): + def adjust_channel_value(self, channel, key, value, sorting_key='defaultindex'): self.lock.acquire() @@ -604,7 +604,7 @@ class BotDatabase(): self.lock.release() - def adjust_channel_list(self, channel, key, entries, adjustmentdirection, sorting_key='unsorted'): + def adjust_channel_list(self, channel, key, entries, adjustmentdirection, sorting_key='defaultindex'): self.lock.acquire() @@ -636,7 +636,7 @@ class BotDatabase(): """Plugins""" - def get_plugin_value(self, plugin, key, sorting_key='unsorted'): + def get_plugin_value(self, plugin, key, sorting_key='defaultindex'): self.lock.acquire() @@ -655,7 +655,7 @@ class BotDatabase(): else: return self.dict["plugins"][plugin][sorting_key][key] - def set_plugin_value(self, plugin, key, value, sorting_key='unsorted'): + def set_plugin_value(self, plugin, key, value, sorting_key='defaultindex'): self.lock.acquire() @@ -672,7 +672,7 @@ class BotDatabase(): self.lock.release() - def delete_plugin_value(self, plugin, key, sorting_key='unsorted'): + def delete_plugin_value(self, plugin, key, sorting_key='defaultindex'): self.lock.acquire() @@ -689,7 +689,7 @@ class BotDatabase(): self.lock.release() - def adjust_plugin_value(self, plugin, key, value, sorting_key='unsorted'): + def adjust_plugin_value(self, plugin, key, value, sorting_key='defaultindex'): self.lock.acquire() @@ -714,7 +714,7 @@ class BotDatabase(): self.lock.release() - def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection, sorting_key='unsorted'): + def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection, sorting_key='defaultindex'): self.lock.acquire() From a2b19c05155c86739540b904745afc34ea24342f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 15:32:39 -0400 Subject: [PATCH 117/328] index no workee --- sopel_modules/SpiceBot/Database.py | 177 +++-------------------------- 1 file changed, 14 insertions(+), 163 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 70e7292..154b2b6 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -7,12 +7,12 @@ This is the SpiceBot Database # sopel imports from sopel.tools import Identifier import sopel.db -from sopel.db import SopelDB, Nicknames, _deserialize +from sopel.db import SopelDB, _deserialize, NickValues, ChannelValues import threading from .Config import config as botconfig -from sqlalchemy import Column, ForeignKey, Integer, String +from sqlalchemy import Column, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.exc import SQLAlchemyError @@ -28,29 +28,6 @@ class PluginValues(BASE): """ __tablename__ = 'plugin_values' plugin = Column(String(255), primary_key=True) - indexkey = Column(String(255), index=True) - key = Column(String(255), primary_key=True) - value = Column(String(255)) - - -class NickValues(BASE): - """ - NickValues SQLAlchemy Class - """ - __tablename__ = 'nick_values' - nick_id = Column(Integer, ForeignKey('nick_ids.nick_id'), primary_key=True) - indexkey = Column(String(255), index=True) - key = Column(String(255), primary_key=True) - value = Column(String(255)) - - -class ChannelValues(BASE): - """ - ChannelValues SQLAlchemy Class - """ - __tablename__ = 'channel_values' - channel = Column(String(255), primary_key=True) - indexkey = Column(String(255), index=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -59,54 +36,7 @@ class SpiceDB(object): # NICK FUNCTIONS - def set_nick_value(self, nick, key, value, indexkey='defaultindex'): - """Sets the value for a given key to be associated with the nick.""" - nick = Identifier(nick) - value = json.dumps(value, ensure_ascii=False) - nick_id = self.get_nick_id(nick) - session = self.ssession() - try: - result = session.query(NickValues) \ - .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.indexkey == indexkey) \ - .filter(NickValues.key == key) \ - .one_or_none() - # NickValue exists, update - if result: - result.value = value - session.commit() - # DNE - Insert - else: - new_nickvalue = NickValues(nick_id=nick_id, indexkey=indexkey, key=key, value=value) - session.add(new_nickvalue) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def get_nick_value(self, nick, key, indexkey='defaultindex'): - """Retrieves the value for a given key associated with a nick.""" - nick = Identifier(nick) - session = self.ssession() - try: - result = session.query(NickValues) \ - .filter(Nicknames.nick_id == NickValues.nick_id) \ - .filter(Nicknames.slug == nick.lower()) \ - .filter(NickValues.indexkey == indexkey) \ - .filter(NickValues.key == key) \ - .one_or_none() - if result is not None: - result = result.value - return _deserialize(result) - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def delete_nick_value(self, nick, key, indexkey='defaultindex'): + def delete_nick_value(self, nick, key): """Deletes the value for a given key to be associated with the nick.""" nick = Identifier(nick) nick_id = self.get_nick_id(nick) @@ -114,7 +44,6 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.indexkey == indexkey) \ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, delete @@ -127,7 +56,7 @@ class SpiceDB(object): finally: session.close() - def adjust_nick_value(self, nick, key, value, indexkey='defaultindex'): + def adjust_nick_value(self, nick, key, value): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) value = json.dumps(value, ensure_ascii=False) @@ -136,7 +65,6 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.indexkey == indexkey) \ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, update @@ -145,7 +73,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_nickvalue = NickValues(nick_id=nick_id, indexkey=indexkey, key=key, value=value) + new_nickvalue = NickValues(nick_id=nick_id, key=key, value=value) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -156,59 +84,13 @@ class SpiceDB(object): # CHANNEL FUNCTIONS - def set_channel_value(self, channel, key, value, indexkey='defaultindex'): - """Sets the value for a given key to be associated with the channel.""" - channel = Identifier(channel).lower() - value = json.dumps(value, ensure_ascii=False) - session = self.ssession() - try: - result = session.query(ChannelValues) \ - .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.indexkey == indexkey) \ - .filter(ChannelValues.key == key) \ - .one_or_none() - # ChannelValue exists, update - if result: - result.value = value - session.commit() - # DNE - Insert - else: - new_channelvalue = ChannelValues(channel=channel, indexkey=indexkey, key=key, value=value) - session.add(new_channelvalue) - session.commit() - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def get_channel_value(self, channel, key, indexkey='defaultindex'): - """Retrieves the value for a given key associated with a channel.""" - channel = Identifier(channel).lower() - session = self.ssession() - try: - result = session.query(ChannelValues) \ - .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.indexkey == indexkey) \ - .filter(ChannelValues.key == key) \ - .one_or_none() - if result is not None: - result = result.value - return _deserialize(result) - except SQLAlchemyError: - session.rollback() - raise - finally: - session.close() - - def delete_channel_value(self, channel, key, indexkey='defaultindex'): + def delete_channel_value(self, channel, key): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() session = self.ssession() try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.indexkey == indexkey) \ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, delete @@ -221,7 +103,7 @@ class SpiceDB(object): finally: session.close() - def adjust_channel_value(self, channel, key, value, indexkey='defaultindex'): + def adjust_channel_value(self, channel, key, value): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() value = json.dumps(value, ensure_ascii=False) @@ -229,7 +111,6 @@ class SpiceDB(object): try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.indexkey == indexkey) \ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -238,7 +119,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_channelvalue = ChannelValues(channel=channel, indexkey=indexkey, key=key, value=value) + new_channelvalue = ChannelValues(channel=channel, key=key, value=value) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -247,29 +128,9 @@ class SpiceDB(object): finally: session.close() - # NICK AND CHANNEL FUNCTIONS - - def get_nick_or_channel_value(self, name, key, indexkey='defaultindex'): - """Gets the value `key` associated to the nick or channel `name`.""" - name = Identifier(name) - if name.is_nick(): - return self.get_nick_value(name, key, indexkey) - else: - return self.get_channel_value(name, key, indexkey) - - def get_preferred_value(self, names, key, indexkey='defaultindex'): - """Gets the value for the first name which has it set. - - `names` is a list of channel and/or user names. Returns None if none of - the names have the key set.""" - for name in names: - value = self.get_nick_or_channel_value(name, key, indexkey) - if value is not None: - return value - # PLUGIN FUNCTIONS - def set_plugin_value(self, plugin, key, value, indexkey='defaultindex'): + def set_plugin_value(self, plugin, key, value): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -277,7 +138,6 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.indexkey == indexkey) \ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, update @@ -286,7 +146,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, indexkey=indexkey, key=key, value=value) + new_pluginvalue = PluginValues(plugin=plugin, key=key, value=value) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -295,14 +155,13 @@ class SpiceDB(object): finally: session.close() - def get_plugin_value(self, plugin, key, indexkey='defaultindex'): + def get_plugin_value(self, plugin, key): """Retrieves the value for a given key associated with a plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.indexkey == indexkey) \ .filter(PluginValues.key == key) \ .one_or_none() if result is not None: @@ -314,7 +173,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_value(self, plugin, key, value, indexkey='defaultindex'): + def adjust_plugin_value(self, plugin, key, value): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -322,7 +181,6 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.indexkey == indexkey) \ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -331,7 +189,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, indexkey=indexkey, key=key, value=value) + new_pluginvalue = PluginValues(plugin=plugin, key=key, value=value) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -340,14 +198,13 @@ class SpiceDB(object): finally: session.close() - def delete_plugin_value(self, plugin, key, indexkey='defaultindex'): + def delete_plugin_value(self, plugin, key): """Deletes the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.indexkey == indexkey) \ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, delete @@ -371,15 +228,9 @@ class BotDatabase(): "channels": {}, } - sopel.db.NickValues = NickValues - SopelDB.get_nick_value = SpiceDB.get_nick_value - SopelDB.set_nick_value = SpiceDB.set_nick_value SopelDB.delete_nick_value = SpiceDB.delete_nick_value SopelDB.adjust_nick_value = SpiceDB.adjust_nick_value - sopel.db.ChannelValues = ChannelValues - SopelDB.get_channel_value = SpiceDB.get_channel_value - SopelDB.set_channel_value = SpiceDB.set_channel_value SopelDB.delete_channel_value = SpiceDB.delete_channel_value SopelDB.adjust_channel_value = SpiceDB.adjust_channel_value From 5f29ba70c320e93c49ecb8cc25555b3621d1e204 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 16:14:31 -0400 Subject: [PATCH 118/328] no cache needed with mysql --- sopel_modules/SpiceBot/Commands.py | 16 +- sopel_modules/SpiceBot/Database.py | 512 ++++++++++------------------- sopel_modules/SpiceBot/Prerun.py | 6 +- 3 files changed, 188 insertions(+), 346 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 2f00517..03ecd0f 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -37,13 +37,13 @@ class BotCommands(): return commandstype return None - def get_disabled_commands(self, bot, channel): + def get_commands_disabled(self, bot, channel): if not len(list(self.dict['disabled'])): - self.dict['disabled'] = botdb.get_channel_value(bot, channel, 'disabled_commands', 'commands') or {} + self.dict['disabled'] = botdb.get_channel_value(bot, channel, 'commands_disabled') or {} return self.dict['disabled'] - def check_disabled_commands(self, bot, command, channel): - if command in self.get_disabled_commands(bot, channel).keys(): + def check_commands_disabled(self, bot, command, channel): + if command in self.get_commands_disabled(bot, channel).keys(): return True else: return False @@ -64,16 +64,16 @@ class BotCommands(): def set_command_disabled(self, bot, command, channel, timestamp, reason, bywhom): if not len(list(self.dict['disabled'])): - self.dict['disabled'] = botdb.get_channel_value(bot, channel, 'disabled_commands', 'commands') or {} + self.dict['disabled'] = botdb.get_channel_value(bot, channel, 'commands_disabled') or {} self.dict['disabled'][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom} - botdb.set_channel_value(bot, channel, 'disabled_commands', self.dict['disabled'], 'commands') + botdb.set_channel_value(bot, channel, 'commands_disabled', self.dict['disabled']) def unset_command_disabled(self, bot, command, channel): if not len(list(self.dict['disabled'])): - self.dict['disabled'] = botdb.get_channel_value(bot, channel, 'disabled_commands', 'commands') or {} + self.dict['disabled'] = botdb.get_channel_value(bot, channel, 'commands_disabled') or {} if command in self.dict['disabled'].keys(): del self.dict['disabled'][command] - botdb.set_channel_value(bot, channel, 'disabled_commands', self.dict['disabled'], 'commands') + botdb.set_channel_value(bot, channel, 'commands_disabled', self.dict['disabled']) def register(self, bot, command_dict): diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 154b2b6..461c96f 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -9,7 +9,6 @@ from sopel.tools import Identifier import sopel.db from sopel.db import SopelDB, _deserialize, NickValues, ChannelValues -import threading from .Config import config as botconfig from sqlalchemy import Column, String @@ -82,6 +81,50 @@ class SpiceDB(object): finally: session.close() + def adjust_nick_list(self, nick, key, entries, adjustmentdirection): + """Sets the value for a given key to be associated with the nick.""" + nick = Identifier(nick) + if not isinstance(entries, list): + entries = [entries] + entries = json.dumps(entries, ensure_ascii=False) + nick_id = self.get_nick_id(nick) + session = self.ssession() + try: + result = session.query(NickValues) \ + .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.key == key) \ + .one_or_none() + # NickValue exists, update + if result: + if adjustmentdirection == 'add': + for entry in entries: + if entry not in result.value: + result.value.append(entry) + elif adjustmentdirection == 'del': + for entry in entries: + while entry in result.value: + result.value.remove(entry) + session.commit() + # DNE - Insert + else: + values = [] + if adjustmentdirection == 'add': + for entry in entries: + if entry not in values: + values.append(entry) + elif adjustmentdirection == 'del': + for entry in entries: + while entry in values: + values.remove(entry) + new_nickvalue = NickValues(nick_id=nick_id, key=key, value=values) + session.add(new_nickvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + # CHANNEL FUNCTIONS def delete_channel_value(self, channel, key): @@ -128,6 +171,49 @@ class SpiceDB(object): finally: session.close() + def adjust_channel_list(self, channel, key, entries, adjustmentdirection): + """Sets the value for a given key to be associated with the channel.""" + channel = Identifier(channel).lower() + if not isinstance(entries, list): + entries = [entries] + entries = json.dumps(entries, ensure_ascii=False) + session = self.ssession() + try: + result = session.query(ChannelValues) \ + .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.key == key) \ + .one_or_none() + # ChannelValue exists, update + if result: + if adjustmentdirection == 'add': + for entry in entries: + if entry not in result.value: + result.value.append(entry) + elif adjustmentdirection == 'del': + for entry in entries: + while entry in result.value: + result.value.remove(entry) + session.commit() + # DNE - Insert + else: + values = [] + if adjustmentdirection == 'add': + for entry in entries: + if entry not in values: + values.append(entry) + elif adjustmentdirection == 'del': + for entry in entries: + while entry in values: + values.remove(entry) + new_channelvalue = ChannelValues(channel=channel, key=key, value=values) + session.add(new_channelvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + # PLUGIN FUNCTIONS def set_plugin_value(self, plugin, key, value): @@ -173,6 +259,25 @@ class SpiceDB(object): finally: session.close() + def delete_plugin_value(self, plugin, key): + """Deletes the value for a given key to be associated with the plugin.""" + plugin = Identifier(plugin).lower() + session = self.ssession() + try: + result = session.query(PluginValues) \ + .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.key == key) \ + .one_or_none() + # PluginValues exists, delete + if result: + session.delete(result) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + def adjust_plugin_value(self, plugin, key, value): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() @@ -198,18 +303,42 @@ class SpiceDB(object): finally: session.close() - def delete_plugin_value(self, plugin, key): - """Deletes the value for a given key to be associated with the plugin.""" + def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection): + """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() + if not isinstance(entries, list): + entries = [entries] + entries = json.dumps(entries, ensure_ascii=False) session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ .filter(PluginValues.key == key) \ .one_or_none() - # PluginValues exists, delete + # ChannelValue exists, update if result: - session.delete(result) + if adjustmentdirection == 'add': + for entry in entries: + if entry not in result.value: + result.value.append(entry) + elif adjustmentdirection == 'del': + for entry in entries: + while entry in result.value: + result.value.remove(entry) + session.commit() + # DNE - Insert + else: + values = [] + if adjustmentdirection == 'add': + for entry in entries: + if entry not in values: + values.append(entry) + elif adjustmentdirection == 'del': + for entry in entries: + while entry in values: + values.remove(entry) + new_pluginvalue = PluginValues(plugin=plugin, key=key, value=values) + session.add(new_pluginvalue) session.commit() except SQLAlchemyError: session.rollback() @@ -222,378 +351,91 @@ class BotDatabase(): """A thread safe database cache""" def __init__(self): - self.lock = threading.Lock() - self.dict = { - "nicks": {}, - "channels": {}, - } SopelDB.delete_nick_value = SpiceDB.delete_nick_value SopelDB.adjust_nick_value = SpiceDB.adjust_nick_value + SopelDB.adjust_nick_list = SpiceDB.adjust_nick_list SopelDB.delete_channel_value = SpiceDB.delete_channel_value SopelDB.adjust_channel_value = SpiceDB.adjust_channel_value + SopelDB.adjust_channel_list = SpiceDB.adjust_channel_list sopel.db.PluginValues = PluginValues SopelDB.get_plugin_value = SpiceDB.get_plugin_value SopelDB.set_plugin_value = SpiceDB.set_plugin_value SopelDB.delete_plugin_value = SpiceDB.delete_plugin_value SopelDB.adjust_plugin_value = SpiceDB.adjust_plugin_value + SopelDB.adjust_plugin_list = SpiceDB.adjust_plugin_list self.db = SopelDB(botconfig.config) """Nick""" - def get_nick_value(self, nick, key, sorting_key='defaultindex'): + def get_nick_value(self, nick, key): + return self.db.get_nick_value(nick, key) - self.lock.acquire() + def set_nick_value(self, nick, key, value): + return self.db.set_nick_value(nick, key, value) - nick = Identifier(nick) - nick_id = self.db.get_nick_id(nick, create=True) + def delete_nick_value(self, nick, key): + return self.db.delete_nick_value(nick, key) - if nick_id not in self.dict["nicks"].keys(): - self.dict["nicks"][nick_id] = {} + def adjust_nick_value(self, nick, key, value): + return self.db.adjust_nick_value(nick, key, value) - if sorting_key not in self.dict["nicks"][nick_id].keys(): - self.dict["nicks"][nick_id][sorting_key] = self.db.get_nick_value(nick, sorting_key) or dict() - - self.lock.release() - - if key not in self.dict["nicks"][nick_id][sorting_key].keys(): - return None - else: - return self.dict["nicks"][nick_id][sorting_key][key] - - def set_nick_value(self, nick, key, value, sorting_key='defaultindex'): - - self.lock.acquire() - - nick = Identifier(nick) - nick_id = self.db.get_nick_id(nick, create=True) - - if nick_id not in self.dict["nicks"].keys(): - self.dict["nicks"][nick_id] = {} - - if sorting_key not in self.dict["nicks"][nick_id].keys(): - self.dict["nicks"][nick_id][sorting_key] = self.db.get_nick_value(nick, sorting_key) or dict() - - self.dict["nicks"][nick_id][sorting_key][key] = value - - self.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) - - self.lock.release() - - def delete_nick_value(self, nick, key, sorting_key='defaultindex'): - - self.lock.acquire() - - nick = Identifier(nick) - nick_id = self.db.get_nick_id(nick, create=True) - - if nick_id not in self.dict["nicks"].keys(): - self.dict["nicks"][nick_id] = {} - - if sorting_key not in self.dict["nicks"][nick_id].keys(): - self.dict["nicks"][nick_id][sorting_key] = self.db.get_nick_value(nick, sorting_key) or dict() - - del self.dict["nicks"][nick_id][sorting_key][key] - self.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) - - self.lock.release() - - def adjust_nick_value(self, nick, key, value, sorting_key='defaultindex'): - - self.lock.acquire() - - nick = Identifier(nick) - nick_id = self.db.get_nick_id(nick, create=True) - - if nick_id not in self.dict["nicks"].keys(): - self.dict["nicks"][nick_id] = {} - - if sorting_key not in self.dict["nicks"][nick_id].keys(): - self.dict["nicks"][nick_id][sorting_key] = self.db.get_nick_value(nick, sorting_key) or dict() - - if key not in self.dict["nicks"][nick_id][sorting_key].keys(): - oldvalue = [] - else: - oldvalue = self.dict["nicks"][nick_id][sorting_key][key] - - if not oldvalue: - self.dict["nicks"][nick_id][sorting_key][key] = value - else: - self.dict["nicks"][nick_id][sorting_key][key] = oldvalue + value - self.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) - - self.lock.release() - - def adjust_nick_list(self, nick, key, entries, adjustmentdirection, sorting_key='defaultindex'): - - self.lock.acquire() - - if not isinstance(entries, list): - entries = [entries] - - nick = Identifier(nick) - nick_id = self.db.get_nick_id(nick, create=True) - - if nick_id not in self.dict["nicks"].keys(): - self.dict["nicks"][nick_id] = {} - - if sorting_key not in self.dict["nicks"][nick_id].keys(): - self.dict["nicks"][nick_id][sorting_key] = self.db.get_nick_value(nick, sorting_key) or dict() - - if key not in self.dict["nicks"][nick_id][sorting_key].keys(): - self.dict["nicks"][nick_id][sorting_key][key] = [] - - if adjustmentdirection == 'add': - for entry in entries: - if entry not in self.dict["nicks"][nick_id][sorting_key][key]: - self.dict["nicks"][nick_id][sorting_key][key].append(entry) - elif adjustmentdirection == 'del': - for entry in entries: - while entry in self.dict["nicks"][nick_id][sorting_key][key]: - self.dict["nicks"][nick_id][sorting_key][key].remove(entry) - self.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key]) - - self.lock.release() + def adjust_nick_list(self, nick, key, entries, adjustmentdirection): + return self.db.adjust_nick_list(nick, key, entries, adjustmentdirection) """Bot""" - def get_bot_value(self, key, sorting_key='defaultindex'): - return self.get_nick_value(botconfig.nick, key, sorting_key) + def get_bot_value(self, key): + return self.db.get_nick_value(botconfig.nick, key) - def set_bot_value(self, key, value, sorting_key='defaultindex'): - return self.set_nick_value(botconfig.nick, key, value, sorting_key) + def set_bot_value(self, key, value): + return self.db.set_nick_value(botconfig.nick, key, value) - def delete_bot_value(self, key, sorting_key='defaultindex'): - return self.delete_nick_value(botconfig.nick, key, sorting_key) + def delete_bot_value(self, key): + return self.db.delete_nick_value(botconfig.nick, key) - def adjust_bot_value(self, key, value, sorting_key='defaultindex'): - return self.adjust_nick_value(botconfig.nick, key, value, sorting_key) + def adjust_bot_value(self, key, value): + return self.db.adjust_nick_value(botconfig.nick, key, value) - def adjust_bot_list(self, key, entries, adjustmentdirection, sorting_key): - return self.adjust_nick_list(botconfig.nick, key, entries, adjustmentdirection, sorting_key) + def adjust_bot_list(self, key, entries, adjustmentdirection): + return self.db.adjust_nick_list(botconfig.nick, key, entries, adjustmentdirection) """Channels""" - def get_channel_value(self, channel, key, sorting_key='defaultindex'): + def get_channel_value(self, channel, key): + return self.db.get_channel_value(channel, key) - self.lock.acquire() + def set_channel_value(self, channel, key, value): + return self.db.set_channel_value(channel, key, value) - channel = Identifier(channel).lower().lower() + def delete_channel_value(self, channel, key): + return self.db.delete_channel_value(channel, key) - if channel not in self.dict["channels"].keys(): - self.dict["channels"][channel] = {} + def adjust_channel_value(self, channel, key, value): + return self.db.adjust_channel_value(channel, key, value) - if sorting_key not in self.dict["channels"][channel].keys(): - self.dict["channels"][channel][sorting_key] = self.db.get_channel_value(channel, sorting_key) or dict() - - self.lock.release() - - if key not in self.dict["channels"][channel][sorting_key].keys(): - return None - else: - return self.dict["channels"][channel][sorting_key][key] - - def set_channel_value(self, channel, key, value, sorting_key='defaultindex'): - - self.lock.acquire() - - channel = Identifier(channel).lower() - - if channel not in self.dict["channels"].keys(): - self.dict["channels"][channel] = {} - - if sorting_key not in self.dict["channels"][channel].keys(): - self.dict["channels"][channel][sorting_key] = self.db.get_channel_value(channel, sorting_key) or dict() - - self.dict["channels"][channel][sorting_key][key] = value - self.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) - - self.lock.release() - - def delete_channel_value(self, channel, key, sorting_key='defaultindex'): - - self.lock.acquire() - - channel = Identifier(channel).lower() - - if channel not in self.dict["channels"].keys(): - self.dict["channels"][channel] = {} - - if sorting_key not in self.dict["channels"][channel].keys(): - self.dict["channels"][channel][sorting_key] = self.db.get_channel_value(channel, sorting_key) or dict() - - del self.dict["channels"][channel][sorting_key][key] - self.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) - - self.lock.release() - - def adjust_channel_value(self, channel, key, value, sorting_key='defaultindex'): - - self.lock.acquire() - - channel = Identifier(channel).lower() - - if channel not in self.dict["channels"].keys(): - self.dict["channels"][channel] = {} - - if sorting_key not in self.dict["channels"][channel].keys(): - self.dict["channels"][channel][sorting_key] = self.db.get_channel_value(channel, sorting_key) or dict() - - if key not in self.dict["channels"][channel][sorting_key].keys(): - oldvalue = None - else: - oldvalue = self.dict["channels"][channel][sorting_key][key] - - if not oldvalue: - self.dict["channels"][channel][sorting_key][key] = value - else: - self.dict["channels"][channel][sorting_key][key] = oldvalue + value - self.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) - - self.lock.release() - - def adjust_channel_list(self, channel, key, entries, adjustmentdirection, sorting_key='defaultindex'): - - self.lock.acquire() - - if not isinstance(entries, list): - entries = [entries] - - channel = Identifier(channel).lower() - - if channel not in self.dict["channels"].keys(): - self.dict["channels"][channel] = {} - - if sorting_key not in self.dict["channels"][channel].keys(): - self.dict["channels"][channel][sorting_key] = self.db.get_channel_value(channel, sorting_key) or dict() - - if key not in self.dict["channels"][channel][sorting_key].keys(): - self.dict["channels"][channel][sorting_key][key] = [] - - if adjustmentdirection == 'add': - for entry in entries: - if entry not in self.dict["channels"][channel][sorting_key][key]: - self.dict["channels"][channel][sorting_key][key].append(entry) - elif adjustmentdirection == 'del': - for entry in entries: - while entry in self.dict["channels"][channel][sorting_key][key]: - self.dict["channels"][channel][sorting_key][key].remove(entry) - self.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key]) - - self.lock.release() + def adjust_channel_list(self, nick, key, entries, adjustmentdirection): + return self.db.adjust_channel_list(nick, key, entries, adjustmentdirection) """Plugins""" - def get_plugin_value(self, plugin, key, sorting_key='defaultindex'): + def get_plugin_value(self, plugin, key): + return self.db.get_plugin_value(plugin, key) - self.lock.acquire() + def set_plugin_value(self, plugin, key, value): + return self.db.set_plugin_value(plugin, key, value) - plugin = plugin.lower() + def delete_plugin_value(self, plugin, key): + return self.db.delete_plugin_value(plugin, key) - if plugin not in self.dict["plugins"].keys(): - self.dict["plugins"][plugin] = {} + def adjust_plugin_value(self, plugin, key, value): + return self.db.adjust_plugin_value(plugin, key, value) - if sorting_key not in self.dict["plugins"][plugin].keys(): - self.dict["plugins"][plugin][sorting_key] = self.db.get_plugin_value(plugin, sorting_key) or dict() - - self.lock.release() - - if key not in self.dict["plugins"][plugin][sorting_key].keys(): - return None - else: - return self.dict["plugins"][plugin][sorting_key][key] - - def set_plugin_value(self, plugin, key, value, sorting_key='defaultindex'): - - self.lock.acquire() - - plugin = plugin.lower() - - if plugin not in self.dict["plugins"].keys(): - self.dict["plugins"][plugin] = {} - - if sorting_key not in self.dict["plugins"][plugin].keys(): - self.dict["plugins"][plugin][sorting_key] = self.db.get_plugin_value(plugin, sorting_key) or dict() - - self.dict["plugins"][plugin][sorting_key][key] = value - self.db.set_plugin_value(plugin, sorting_key, self.dict["plugins"][plugin][sorting_key]) - - self.lock.release() - - def delete_plugin_value(self, plugin, key, sorting_key='defaultindex'): - - self.lock.acquire() - - plugin = plugin.lower() - - if plugin not in self.dict["plugins"].keys(): - self.dict["plugins"][plugin] = {} - - if sorting_key not in self.dict["plugins"][plugin].keys(): - self.dict["plugins"][plugin][sorting_key] = self.db.get_plugin_value(plugin, sorting_key) or dict() - - del self.dict["plugins"][plugin][sorting_key][key] - self.db.set_plugin_value(plugin, sorting_key, self.dict["plugins"][plugin][sorting_key]) - - self.lock.release() - - def adjust_plugin_value(self, plugin, key, value, sorting_key='defaultindex'): - - self.lock.acquire() - - plugin = plugin.lower() - - if plugin not in self.dict["plugins"].keys(): - self.dict["plugins"][plugin] = {} - - if sorting_key not in self.dict["plugins"][plugin].keys(): - self.dict["plugins"][plugin][sorting_key] = self.db.get_plugin_value(plugin, sorting_key) or dict() - - if key not in self.dict["plugins"][plugin][sorting_key].keys(): - oldvalue = None - else: - oldvalue = self.dict["plugins"][plugin][sorting_key][key] - - if not oldvalue: - self.dict["plugins"][plugin][sorting_key][key] = value - else: - self.dict["plugins"][plugin][sorting_key][key] = oldvalue + value - self.db.set_plugin_value(plugin, sorting_key, self.dict["plugins"][plugin][sorting_key]) - - self.lock.release() - - def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection, sorting_key='defaultindex'): - - self.lock.acquire() - - if not isinstance(entries, list): - entries = [entries] - - plugin = plugin.lower() - - if plugin not in self.dict["plugins"].keys(): - self.dict["plugins"][plugin] = {} - - if sorting_key not in self.dict["plugins"][plugin].keys(): - self.dict["plugins"][plugin][sorting_key] = self.db.get_plugin_value(plugin, sorting_key) or dict() - - if key not in self.dict["plugins"][plugin][sorting_key].keys(): - self.dict["plugins"][plugin][sorting_key][key] = [] - - if adjustmentdirection == 'add': - for entry in entries: - if entry not in self.dict["plugins"][plugin][sorting_key][key]: - self.dict["plugins"][plugin][sorting_key][key].append(entry) - elif adjustmentdirection == 'del': - for entry in entries: - while entry in self.dict["plugins"][plugin][sorting_key][key]: - self.dict["plugins"][plugin][sorting_key][key].remove(entry) - self.db.set_plugin_value(plugin, sorting_key, self.dict["plugins"][plugin][sorting_key]) - - self.lock.release() + def adjust_plugin_list(self, nick, key, entries, adjustmentdirection): + return self.db.adjust_plugin_list(nick, key, entries, adjustmentdirection) db = BotDatabase() diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index dce2c5b..6dc0cf5 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -106,7 +106,7 @@ class BotPrerun(): # don't run commands that are disabled in channels if not trigger.is_privmsg: - disabled_list = botdb.get_channel_value(trigger.sender, 'disabled_commands', 'commands') or {} + disabled_list = botdb.get_channel_value(trigger.sender, 'commands_disabled') or {} if trigger.sb["realcom"] in disabled_list.keys(): reason = disabled_list[trigger.sb["realcom"]]["reason"] timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"] @@ -161,7 +161,7 @@ class BotPrerun(): bot.osd("This command must be run in a channel you which to enable it in.", trigger.nick, 'notice') return - if not commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): + if not commands.check_commands_disabled(bot, trigger.sb["realcom"], trigger.sender): bot.osd(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick, 'notice') return @@ -179,7 +179,7 @@ class BotPrerun(): bot.osd("This command must be run in a channel you which to disable it in.", trigger.nick, 'notice') return - if commands.check_disabled_commands(bot, trigger.sb["realcom"], trigger.sender): + if commands.check_commands_disabled(bot, trigger.sb["realcom"], trigger.sender): bot.osd(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick, 'notice') return From 621fb498c52e70979a8da3a6cf6c328a366bb176 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 16:23:51 -0400 Subject: [PATCH 119/328] test --- sopel_modules/SpiceBot/Database.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 461c96f..022f34f 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -68,11 +68,11 @@ class SpiceDB(object): .one_or_none() # NickValue exists, update if result: - result.value = result.value + value + result.value = float(result.value) + float(value) session.commit() # DNE - Insert else: - new_nickvalue = NickValues(nick_id=nick_id, key=key, value=value) + new_nickvalue = NickValues(nick_id=nick_id, key=key, value=float(value)) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -158,11 +158,11 @@ class SpiceDB(object): .one_or_none() # ChannelValue exists, update if result: - result.value = result.value + value + result.value = result.value + float(value) session.commit() # DNE - Insert else: - new_channelvalue = ChannelValues(channel=channel, key=key, value=value) + new_channelvalue = ChannelValues(channel=channel, key=key, value=float(value)) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -290,11 +290,11 @@ class SpiceDB(object): .one_or_none() # ChannelValue exists, update if result: - result.value = result.value + value + result.value = float(result.value) + float(value) session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, key=key, value=value) + new_pluginvalue = PluginValues(plugin=plugin, key=key, value=float(value)) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: From 5e9101242b6239b8bd885bf181cac326bb1c6959 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 16:27:22 -0400 Subject: [PATCH 120/328] float --- sopel_modules/SpiceBot/Database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 022f34f..f86fab6 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -158,7 +158,7 @@ class SpiceDB(object): .one_or_none() # ChannelValue exists, update if result: - result.value = result.value + float(value) + result.value = float(result.value) + float(value) session.commit() # DNE - Insert else: From dfdc2dcde5303c4fb5650f3ddb18bd611fe20607 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 08:12:51 -0400 Subject: [PATCH 121/328] attempt plugin category --- sopel_modules/SpiceBot/Database.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index f86fab6..76f8439 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -27,6 +27,7 @@ class PluginValues(BASE): """ __tablename__ = 'plugin_values' plugin = Column(String(255), primary_key=True) + category = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -216,7 +217,7 @@ class SpiceDB(object): # PLUGIN FUNCTIONS - def set_plugin_value(self, plugin, key, value): + def set_plugin_value(self, plugin, key, value, category='default'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -224,6 +225,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, update @@ -232,7 +234,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, key=key, value=value) + new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=value) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -241,13 +243,14 @@ class SpiceDB(object): finally: session.close() - def get_plugin_value(self, plugin, key): + def get_plugin_value(self, plugin, key, category='default'): """Retrieves the value for a given key associated with a plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() if result is not None: @@ -259,13 +262,14 @@ class SpiceDB(object): finally: session.close() - def delete_plugin_value(self, plugin, key): + def delete_plugin_value(self, plugin, key, category='default'): """Deletes the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, delete @@ -278,7 +282,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_value(self, plugin, key, value): + def adjust_plugin_value(self, plugin, key, value, category='default'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -286,6 +290,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -294,7 +299,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, key=key, value=float(value)) + new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=float(value)) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -303,7 +308,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection): + def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection, category='default'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() if not isinstance(entries, list): @@ -313,6 +318,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -337,7 +343,7 @@ class SpiceDB(object): for entry in entries: while entry in values: values.remove(entry) - new_pluginvalue = PluginValues(plugin=plugin, key=key, value=values) + new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=values) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: From b402287cb1f76093c4c72ddcc9af32d8bab8a267 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 08:21:24 -0400 Subject: [PATCH 122/328] test --- sopel_modules/SpiceBot/Database.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 76f8439..3841d13 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -27,9 +27,9 @@ class PluginValues(BASE): """ __tablename__ = 'plugin_values' plugin = Column(String(255), primary_key=True) - category = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) value = Column(String(255)) + category = Column(String(255)) class SpiceDB(object): @@ -225,7 +225,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ + .filter_by(category=category) \ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, update @@ -250,7 +250,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ + .filter_by(category=category) \ .filter(PluginValues.key == key) \ .one_or_none() if result is not None: @@ -269,7 +269,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ + .filter_by(category=category) \ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, delete @@ -290,7 +290,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ + .filter_by(category=category) \ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -318,7 +318,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ + .filter_by(category=category) \ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update From 64e5dbcfd3ab6afe62b6b235156d46f9d9784c75 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 08:50:39 -0400 Subject: [PATCH 123/328] more filtering test --- sopel_modules/SpiceBot/Database.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 3841d13..9e12290 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -27,9 +27,9 @@ class PluginValues(BASE): """ __tablename__ = 'plugin_values' plugin = Column(String(255), primary_key=True) - key = Column(String(255), primary_key=True) + category = Column(String(255), primary_key=True) + key = Column(String(255)) value = Column(String(255)) - category = Column(String(255)) class SpiceDB(object): @@ -225,7 +225,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter_by(category=category) \ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, update @@ -250,7 +250,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter_by(category=category) \ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() if result is not None: @@ -269,7 +269,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter_by(category=category) \ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, delete @@ -290,7 +290,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter_by(category=category) \ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -318,7 +318,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter_by(category=category) \ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update From 688daaba1a788010ef531a3fdea506af43b0c4d9 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 09:01:39 -0400 Subject: [PATCH 124/328] test --- sopel_modules/SpiceBot/Database.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 9e12290..19b4d18 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -27,8 +27,8 @@ class PluginValues(BASE): """ __tablename__ = 'plugin_values' plugin = Column(String(255), primary_key=True) - category = Column(String(255), primary_key=True) - key = Column(String(255)) + key = Column(String(255), primary_key=True) + category = Column(String(255)) value = Column(String(255)) @@ -217,7 +217,7 @@ class SpiceDB(object): # PLUGIN FUNCTIONS - def set_plugin_value(self, plugin, key, value, category='default'): + def set_plugin_value(self, plugin, key, value): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -225,7 +225,6 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, update @@ -234,7 +233,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=value) + new_pluginvalue = PluginValues(plugin=plugin, key=key, value=value) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -243,14 +242,13 @@ class SpiceDB(object): finally: session.close() - def get_plugin_value(self, plugin, key, category='default'): + def get_plugin_value(self, plugin, key): """Retrieves the value for a given key associated with a plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() if result is not None: @@ -262,14 +260,13 @@ class SpiceDB(object): finally: session.close() - def delete_plugin_value(self, plugin, key, category='default'): + def delete_plugin_value(self, plugin, key): """Deletes the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, delete @@ -282,7 +279,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_value(self, plugin, key, value, category='default'): + def adjust_plugin_value(self, plugin, key, value): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -290,7 +287,6 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -299,7 +295,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=float(value)) + new_pluginvalue = PluginValues(plugin=plugin, key=key, value=float(value)) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -308,7 +304,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection, category='default'): + def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() if not isinstance(entries, list): @@ -318,7 +314,6 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -343,7 +338,7 @@ class SpiceDB(object): for entry in entries: while entry in values: values.remove(entry) - new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=values) + new_pluginvalue = PluginValues(plugin=plugin, key=key, value=values) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: From 794623b26adf61b2bbca3b3efb8ace9d3340858b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 09:05:59 -0400 Subject: [PATCH 125/328] test --- sopel_modules/SpiceBot/Database.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 19b4d18..f86fab6 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -28,7 +28,6 @@ class PluginValues(BASE): __tablename__ = 'plugin_values' plugin = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) - category = Column(String(255)) value = Column(String(255)) From e4d06c7da15c60ec8c34b13cd9fd886f67a5f08f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 09:31:39 -0400 Subject: [PATCH 126/328] test --- sopel_modules/SpiceBot/Database.py | 172 +++++++++++++++++++++++++---- 1 file changed, 152 insertions(+), 20 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index f86fab6..a62cfd1 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -7,11 +7,11 @@ This is the SpiceBot Database # sopel imports from sopel.tools import Identifier import sopel.db -from sopel.db import SopelDB, _deserialize, NickValues, ChannelValues +from sopel.db import SopelDB, _deserialize, Nicknames from .Config import config as botconfig -from sqlalchemy import Column, String +from sqlalchemy import Column, String, ForeignKey, Integer from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.exc import SQLAlchemyError @@ -21,12 +21,35 @@ import json BASE = declarative_base() +class NickValues(BASE): + """ + NickValues SQLAlchemy Class + """ + __tablename__ = 'nick_values' + nick_id = Column(Integer, ForeignKey('nick_ids.nick_id'), primary_key=True) + category = Column(String(255), primary_key=True) + key = Column(String(255), primary_key=True) + value = Column(String(255)) + + +class ChannelValues(BASE): + """ + ChannelValues SQLAlchemy Class + """ + __tablename__ = 'channel_values' + channel = Column(String(255), primary_key=True) + category = Column(String(255), primary_key=True) + key = Column(String(255), primary_key=True) + value = Column(String(255)) + + class PluginValues(BASE): """ PluginValues SQLAlchemy Class """ __tablename__ = 'plugin_values' plugin = Column(String(255), primary_key=True) + category = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -35,7 +58,54 @@ class SpiceDB(object): # NICK FUNCTIONS - def delete_nick_value(self, nick, key): + def set_nick_value(self, nick, key, value, category='default'): + """Sets the value for a given key to be associated with the nick.""" + nick = Identifier(nick) + value = json.dumps(value, ensure_ascii=False) + nick_id = self.get_nick_id(nick) + session = self.ssession() + try: + result = session.query(NickValues) \ + .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.category == category)\ + .filter(NickValues.key == key) \ + .one_or_none() + # NickValue exists, update + if result: + result.value = value + session.commit() + # DNE - Insert + else: + new_nickvalue = NickValues(nick_id=nick_id, category=category, key=key, value=value) + session.add(new_nickvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def get_nick_value(self, nick, key, category='default'): + """Retrieves the value for a given key associated with a nick.""" + nick = Identifier(nick) + session = self.ssession() + try: + result = session.query(NickValues) \ + .filter(Nicknames.nick_id == NickValues.nick_id) \ + .filter(Nicknames.slug == nick.lower()) \ + .filter(NickValues.category == category)\ + .filter(NickValues.key == key) \ + .one_or_none() + if result is not None: + result = result.value + return _deserialize(result) + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def delete_nick_value(self, nick, key, category='default'): """Deletes the value for a given key to be associated with the nick.""" nick = Identifier(nick) nick_id = self.get_nick_id(nick) @@ -43,6 +113,7 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.category == category)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, delete @@ -55,7 +126,7 @@ class SpiceDB(object): finally: session.close() - def adjust_nick_value(self, nick, key, value): + def adjust_nick_value(self, nick, key, value, category='default'): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) value = json.dumps(value, ensure_ascii=False) @@ -64,6 +135,7 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.category == category)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, update @@ -72,7 +144,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_nickvalue = NickValues(nick_id=nick_id, key=key, value=float(value)) + new_nickvalue = NickValues(nick_id=nick_id, category=category, key=key, value=float(value)) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -81,7 +153,7 @@ class SpiceDB(object): finally: session.close() - def adjust_nick_list(self, nick, key, entries, adjustmentdirection): + def adjust_nick_list(self, nick, key, entries, adjustmentdirection, category='default'): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) if not isinstance(entries, list): @@ -92,6 +164,7 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.category == category)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, update @@ -116,7 +189,7 @@ class SpiceDB(object): for entry in entries: while entry in values: values.remove(entry) - new_nickvalue = NickValues(nick_id=nick_id, key=key, value=values) + new_nickvalue = NickValues(nick_id=nick_id, category=category, key=key, value=values) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -127,13 +200,59 @@ class SpiceDB(object): # CHANNEL FUNCTIONS - def delete_channel_value(self, channel, key): + def set_channel_value(self, channel, key, value, category='default'): + """Sets the value for a given key to be associated with the channel.""" + channel = Identifier(channel).lower() + value = json.dumps(value, ensure_ascii=False) + session = self.ssession() + try: + result = session.query(ChannelValues) \ + .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.category == category)\ + .filter(ChannelValues.key == key) \ + .one_or_none() + # ChannelValue exists, update + if result: + result.value = value + session.commit() + # DNE - Insert + else: + new_channelvalue = ChannelValues(channel=channel, category=category, key=key, value=value) + session.add(new_channelvalue) + session.commit() + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def get_channel_value(self, channel, key, category='default'): + """Retrieves the value for a given key associated with a channel.""" + channel = Identifier(channel).lower() + session = self.ssession() + try: + result = session.query(ChannelValues) \ + .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.category == category)\ + .filter(ChannelValues.key == key) \ + .one_or_none() + if result is not None: + result = result.value + return _deserialize(result) + except SQLAlchemyError: + session.rollback() + raise + finally: + session.close() + + def delete_channel_value(self, channel, key, category='default'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() session = self.ssession() try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.category == category)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, delete @@ -146,7 +265,7 @@ class SpiceDB(object): finally: session.close() - def adjust_channel_value(self, channel, key, value): + def adjust_channel_value(self, channel, key, value, category='default'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() value = json.dumps(value, ensure_ascii=False) @@ -154,6 +273,7 @@ class SpiceDB(object): try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.category == category)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -162,7 +282,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_channelvalue = ChannelValues(channel=channel, key=key, value=float(value)) + new_channelvalue = ChannelValues(channel=channel, category=category, key=key, value=float(value)) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -171,7 +291,7 @@ class SpiceDB(object): finally: session.close() - def adjust_channel_list(self, channel, key, entries, adjustmentdirection): + def adjust_channel_list(self, channel, key, entries, adjustmentdirection, category='default'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() if not isinstance(entries, list): @@ -181,6 +301,7 @@ class SpiceDB(object): try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.category == category)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -205,7 +326,7 @@ class SpiceDB(object): for entry in entries: while entry in values: values.remove(entry) - new_channelvalue = ChannelValues(channel=channel, key=key, value=values) + new_channelvalue = ChannelValues(channel=channel, category=category, key=key, value=values) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -216,7 +337,7 @@ class SpiceDB(object): # PLUGIN FUNCTIONS - def set_plugin_value(self, plugin, key, value): + def set_plugin_value(self, plugin, key, value, category='default'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -224,6 +345,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(ChannelValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, update @@ -232,7 +354,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, key=key, value=value) + new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=value) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -241,13 +363,14 @@ class SpiceDB(object): finally: session.close() - def get_plugin_value(self, plugin, key): + def get_plugin_value(self, plugin, key, category='default'): """Retrieves the value for a given key associated with a plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(ChannelValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() if result is not None: @@ -259,13 +382,14 @@ class SpiceDB(object): finally: session.close() - def delete_plugin_value(self, plugin, key): + def delete_plugin_value(self, plugin, key, category='default'): """Deletes the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(ChannelValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, delete @@ -278,7 +402,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_value(self, plugin, key, value): + def adjust_plugin_value(self, plugin, key, value, category='default'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -286,6 +410,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(ChannelValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -294,7 +419,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, key=key, value=float(value)) + new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=float(value)) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -303,7 +428,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection): + def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection, category='default'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() if not isinstance(entries, list): @@ -313,6 +438,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(ChannelValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -337,7 +463,7 @@ class SpiceDB(object): for entry in entries: while entry in values: values.remove(entry) - new_pluginvalue = PluginValues(plugin=plugin, key=key, value=values) + new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=values) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -352,10 +478,16 @@ class BotDatabase(): def __init__(self): + sopel.db.NickValues = NickValues + SopelDB.get_nick_value = SpiceDB.get_nick_value + SopelDB.set_nick_value = SpiceDB.set_nick_value SopelDB.delete_nick_value = SpiceDB.delete_nick_value SopelDB.adjust_nick_value = SpiceDB.adjust_nick_value SopelDB.adjust_nick_list = SpiceDB.adjust_nick_list + sopel.db.ChannelValues = ChannelValues + SopelDB.get_channel_value = SpiceDB.get_channel_value + SopelDB.set_channel_value = SpiceDB.set_channel_value SopelDB.delete_channel_value = SpiceDB.delete_channel_value SopelDB.adjust_channel_value = SpiceDB.adjust_channel_value SopelDB.adjust_channel_list = SpiceDB.adjust_channel_list From b9eb5c02ed36dc7192c98931585bff9893c92a83 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 10:00:53 -0400 Subject: [PATCH 127/328] make sure plugin works --- sopel_modules/SpiceBot/Database.py | 69 ++++++++++++------------------ 1 file changed, 27 insertions(+), 42 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index a62cfd1..9852882 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -27,7 +27,7 @@ class NickValues(BASE): """ __tablename__ = 'nick_values' nick_id = Column(Integer, ForeignKey('nick_ids.nick_id'), primary_key=True) - category = Column(String(255), primary_key=True) + # category = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -38,7 +38,7 @@ class ChannelValues(BASE): """ __tablename__ = 'channel_values' channel = Column(String(255), primary_key=True) - category = Column(String(255), primary_key=True) + # category = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -49,7 +49,7 @@ class PluginValues(BASE): """ __tablename__ = 'plugin_values' plugin = Column(String(255), primary_key=True) - category = Column(String(255), primary_key=True) + # category = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -58,7 +58,7 @@ class SpiceDB(object): # NICK FUNCTIONS - def set_nick_value(self, nick, key, value, category='default'): + def set_nick_value(self, nick, key, value): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) value = json.dumps(value, ensure_ascii=False) @@ -67,7 +67,6 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.category == category)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, update @@ -76,7 +75,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_nickvalue = NickValues(nick_id=nick_id, category=category, key=key, value=value) + new_nickvalue = NickValues(nick_id=nick_id, key=key, value=value) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -85,7 +84,7 @@ class SpiceDB(object): finally: session.close() - def get_nick_value(self, nick, key, category='default'): + def get_nick_value(self, nick, key): """Retrieves the value for a given key associated with a nick.""" nick = Identifier(nick) session = self.ssession() @@ -93,7 +92,6 @@ class SpiceDB(object): result = session.query(NickValues) \ .filter(Nicknames.nick_id == NickValues.nick_id) \ .filter(Nicknames.slug == nick.lower()) \ - .filter(NickValues.category == category)\ .filter(NickValues.key == key) \ .one_or_none() if result is not None: @@ -105,7 +103,7 @@ class SpiceDB(object): finally: session.close() - def delete_nick_value(self, nick, key, category='default'): + def delete_nick_value(self, nick, key): """Deletes the value for a given key to be associated with the nick.""" nick = Identifier(nick) nick_id = self.get_nick_id(nick) @@ -113,7 +111,6 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.category == category)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, delete @@ -126,7 +123,7 @@ class SpiceDB(object): finally: session.close() - def adjust_nick_value(self, nick, key, value, category='default'): + def adjust_nick_value(self, nick, key, value): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) value = json.dumps(value, ensure_ascii=False) @@ -135,7 +132,6 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.category == category)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, update @@ -144,7 +140,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_nickvalue = NickValues(nick_id=nick_id, category=category, key=key, value=float(value)) + new_nickvalue = NickValues(nick_id=nick_id, key=key, value=float(value)) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -153,7 +149,7 @@ class SpiceDB(object): finally: session.close() - def adjust_nick_list(self, nick, key, entries, adjustmentdirection, category='default'): + def adjust_nick_list(self, nick, key, entries, adjustmentdirection): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) if not isinstance(entries, list): @@ -164,7 +160,6 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.category == category)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, update @@ -189,7 +184,7 @@ class SpiceDB(object): for entry in entries: while entry in values: values.remove(entry) - new_nickvalue = NickValues(nick_id=nick_id, category=category, key=key, value=values) + new_nickvalue = NickValues(nick_id=nick_id, key=key, value=values) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -200,7 +195,7 @@ class SpiceDB(object): # CHANNEL FUNCTIONS - def set_channel_value(self, channel, key, value, category='default'): + def set_channel_value(self, channel, key, value): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() value = json.dumps(value, ensure_ascii=False) @@ -208,7 +203,6 @@ class SpiceDB(object): try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.category == category)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -217,7 +211,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_channelvalue = ChannelValues(channel=channel, category=category, key=key, value=value) + new_channelvalue = ChannelValues(channel=channel, key=key, value=value) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -226,14 +220,13 @@ class SpiceDB(object): finally: session.close() - def get_channel_value(self, channel, key, category='default'): + def get_channel_value(self, channel, key): """Retrieves the value for a given key associated with a channel.""" channel = Identifier(channel).lower() session = self.ssession() try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.category == category)\ .filter(ChannelValues.key == key) \ .one_or_none() if result is not None: @@ -245,14 +238,13 @@ class SpiceDB(object): finally: session.close() - def delete_channel_value(self, channel, key, category='default'): + def delete_channel_value(self, channel, key): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() session = self.ssession() try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.category == category)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, delete @@ -265,7 +257,7 @@ class SpiceDB(object): finally: session.close() - def adjust_channel_value(self, channel, key, value, category='default'): + def adjust_channel_value(self, channel, key, value): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() value = json.dumps(value, ensure_ascii=False) @@ -273,7 +265,6 @@ class SpiceDB(object): try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.category == category)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -282,7 +273,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_channelvalue = ChannelValues(channel=channel, category=category, key=key, value=float(value)) + new_channelvalue = ChannelValues(channel=channel, key=key, value=float(value)) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -291,7 +282,7 @@ class SpiceDB(object): finally: session.close() - def adjust_channel_list(self, channel, key, entries, adjustmentdirection, category='default'): + def adjust_channel_list(self, channel, key, entries, adjustmentdirection): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() if not isinstance(entries, list): @@ -301,7 +292,6 @@ class SpiceDB(object): try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.category == category)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -326,7 +316,7 @@ class SpiceDB(object): for entry in entries: while entry in values: values.remove(entry) - new_channelvalue = ChannelValues(channel=channel, category=category, key=key, value=values) + new_channelvalue = ChannelValues(channel=channel, key=key, value=values) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -337,7 +327,7 @@ class SpiceDB(object): # PLUGIN FUNCTIONS - def set_plugin_value(self, plugin, key, value, category='default'): + def set_plugin_value(self, plugin, key, value): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -345,7 +335,6 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(ChannelValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, update @@ -354,7 +343,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=value) + new_pluginvalue = PluginValues(plugin=plugin, key=key, value=value) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -363,14 +352,13 @@ class SpiceDB(object): finally: session.close() - def get_plugin_value(self, plugin, key, category='default'): + def get_plugin_value(self, plugin, key): """Retrieves the value for a given key associated with a plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(ChannelValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() if result is not None: @@ -382,14 +370,13 @@ class SpiceDB(object): finally: session.close() - def delete_plugin_value(self, plugin, key, category='default'): + def delete_plugin_value(self, plugin, key): """Deletes the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(ChannelValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, delete @@ -402,7 +389,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_value(self, plugin, key, value, category='default'): + def adjust_plugin_value(self, plugin, key, value): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -410,7 +397,6 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(ChannelValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -419,7 +405,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=float(value)) + new_pluginvalue = PluginValues(plugin=plugin, key=key, value=float(value)) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -428,7 +414,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection, category='default'): + def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() if not isinstance(entries, list): @@ -438,7 +424,6 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(ChannelValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -463,7 +448,7 @@ class SpiceDB(object): for entry in entries: while entry in values: values.remove(entry) - new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=values) + new_pluginvalue = PluginValues(plugin=plugin, key=key, value=values) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: From 1c5e3e82128bc2e00c1209e4917a195b2028bc34 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 10:14:55 -0400 Subject: [PATCH 128/328] spicebot database is seperate from bot database --- sopel_modules/SpiceBot/Database.py | 75 ++++++++++++++++++------------ 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 9852882..9be78d3 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -25,9 +25,9 @@ class NickValues(BASE): """ NickValues SQLAlchemy Class """ - __tablename__ = 'nick_values' + __tablename__ = 'spice_nick_values' nick_id = Column(Integer, ForeignKey('nick_ids.nick_id'), primary_key=True) - # category = Column(String(255), primary_key=True) + category = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -36,9 +36,9 @@ class ChannelValues(BASE): """ ChannelValues SQLAlchemy Class """ - __tablename__ = 'channel_values' + __tablename__ = 'spice_channel_values' channel = Column(String(255), primary_key=True) - # category = Column(String(255), primary_key=True) + category = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -47,9 +47,9 @@ class PluginValues(BASE): """ PluginValues SQLAlchemy Class """ - __tablename__ = 'plugin_values' + __tablename__ = 'spice_plugin_values' plugin = Column(String(255), primary_key=True) - # category = Column(String(255), primary_key=True) + category = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -58,7 +58,7 @@ class SpiceDB(object): # NICK FUNCTIONS - def set_nick_value(self, nick, key, value): + def set_nick_value(self, nick, key, value, category='default'): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) value = json.dumps(value, ensure_ascii=False) @@ -67,6 +67,7 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.category == category)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, update @@ -75,7 +76,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_nickvalue = NickValues(nick_id=nick_id, key=key, value=value) + new_nickvalue = NickValues(nick_id=nick_id, category=category, key=key, value=value) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -84,7 +85,7 @@ class SpiceDB(object): finally: session.close() - def get_nick_value(self, nick, key): + def get_nick_value(self, nick, key, category='default'): """Retrieves the value for a given key associated with a nick.""" nick = Identifier(nick) session = self.ssession() @@ -92,6 +93,7 @@ class SpiceDB(object): result = session.query(NickValues) \ .filter(Nicknames.nick_id == NickValues.nick_id) \ .filter(Nicknames.slug == nick.lower()) \ + .filter(NickValues.category == category)\ .filter(NickValues.key == key) \ .one_or_none() if result is not None: @@ -103,7 +105,7 @@ class SpiceDB(object): finally: session.close() - def delete_nick_value(self, nick, key): + def delete_nick_value(self, nick, key, category='default'): """Deletes the value for a given key to be associated with the nick.""" nick = Identifier(nick) nick_id = self.get_nick_id(nick) @@ -111,6 +113,7 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.category == category)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, delete @@ -123,7 +126,7 @@ class SpiceDB(object): finally: session.close() - def adjust_nick_value(self, nick, key, value): + def adjust_nick_value(self, nick, key, value, category='default'): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) value = json.dumps(value, ensure_ascii=False) @@ -132,6 +135,7 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.category == category)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, update @@ -140,7 +144,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_nickvalue = NickValues(nick_id=nick_id, key=key, value=float(value)) + new_nickvalue = NickValues(nick_id=nick_id, category=category, key=key, value=float(value)) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -149,7 +153,7 @@ class SpiceDB(object): finally: session.close() - def adjust_nick_list(self, nick, key, entries, adjustmentdirection): + def adjust_nick_list(self, nick, key, entries, adjustmentdirection, category='default'): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) if not isinstance(entries, list): @@ -160,6 +164,7 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ + .filter(NickValues.category == category)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, update @@ -184,7 +189,7 @@ class SpiceDB(object): for entry in entries: while entry in values: values.remove(entry) - new_nickvalue = NickValues(nick_id=nick_id, key=key, value=values) + new_nickvalue = NickValues(nick_id=nick_id, category=category, key=key, value=values) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -195,7 +200,7 @@ class SpiceDB(object): # CHANNEL FUNCTIONS - def set_channel_value(self, channel, key, value): + def set_channel_value(self, channel, key, value, category='default'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() value = json.dumps(value, ensure_ascii=False) @@ -203,6 +208,7 @@ class SpiceDB(object): try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.category == category)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -211,7 +217,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_channelvalue = ChannelValues(channel=channel, key=key, value=value) + new_channelvalue = ChannelValues(channel=channel, category=category, key=key, value=value) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -220,13 +226,14 @@ class SpiceDB(object): finally: session.close() - def get_channel_value(self, channel, key): + def get_channel_value(self, channel, key, category='default'): """Retrieves the value for a given key associated with a channel.""" channel = Identifier(channel).lower() session = self.ssession() try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.category == category)\ .filter(ChannelValues.key == key) \ .one_or_none() if result is not None: @@ -238,13 +245,14 @@ class SpiceDB(object): finally: session.close() - def delete_channel_value(self, channel, key): + def delete_channel_value(self, channel, key, category='default'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() session = self.ssession() try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.category == category)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, delete @@ -257,7 +265,7 @@ class SpiceDB(object): finally: session.close() - def adjust_channel_value(self, channel, key, value): + def adjust_channel_value(self, channel, key, value, category='default'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() value = json.dumps(value, ensure_ascii=False) @@ -265,6 +273,7 @@ class SpiceDB(object): try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.category == category)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -273,7 +282,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_channelvalue = ChannelValues(channel=channel, key=key, value=float(value)) + new_channelvalue = ChannelValues(channel=channel, category=category, key=key, value=float(value)) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -282,7 +291,7 @@ class SpiceDB(object): finally: session.close() - def adjust_channel_list(self, channel, key, entries, adjustmentdirection): + def adjust_channel_list(self, channel, key, entries, adjustmentdirection, category='default'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() if not isinstance(entries, list): @@ -292,6 +301,7 @@ class SpiceDB(object): try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ + .filter(ChannelValues.category == category)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -316,7 +326,7 @@ class SpiceDB(object): for entry in entries: while entry in values: values.remove(entry) - new_channelvalue = ChannelValues(channel=channel, key=key, value=values) + new_channelvalue = ChannelValues(channel=channel, category=category, key=key, value=values) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -327,7 +337,7 @@ class SpiceDB(object): # PLUGIN FUNCTIONS - def set_plugin_value(self, plugin, key, value): + def set_plugin_value(self, plugin, key, value, category='default'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -335,6 +345,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, update @@ -343,7 +354,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, key=key, value=value) + new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=value) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -352,13 +363,14 @@ class SpiceDB(object): finally: session.close() - def get_plugin_value(self, plugin, key): + def get_plugin_value(self, plugin, key, category='default'): """Retrieves the value for a given key associated with a plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() if result is not None: @@ -370,13 +382,14 @@ class SpiceDB(object): finally: session.close() - def delete_plugin_value(self, plugin, key): + def delete_plugin_value(self, plugin, key, category='default'): """Deletes the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, delete @@ -389,7 +402,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_value(self, plugin, key, value): + def adjust_plugin_value(self, plugin, key, value, category='default'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -397,6 +410,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -405,7 +419,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, key=key, value=float(value)) + new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=float(value)) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -414,7 +428,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection): + def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection, category='default'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() if not isinstance(entries, list): @@ -424,6 +438,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ + .filter(PluginValues.category == category)\ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -448,7 +463,7 @@ class SpiceDB(object): for entry in entries: while entry in values: values.remove(entry) - new_pluginvalue = PluginValues(plugin=plugin, key=key, value=values) + new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=values) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: From 940e249f44276aa5677c367d6ee9df304d9cfb37 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 10:36:41 -0400 Subject: [PATCH 129/328] test database table creation --- sopel_modules/SpiceBot/Database.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 9be78d3..ce3fe04 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -500,6 +500,7 @@ class BotDatabase(): SopelDB.adjust_plugin_list = SpiceDB.adjust_plugin_list self.db = SopelDB(botconfig.config) + BASE.metadata.create_all(self.db.engine) """Nick""" From 9593c75b67bdea86940e4648cc9cd84eab65faa4 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 10:43:35 -0400 Subject: [PATCH 130/328] anotehr import --- sopel_modules/SpiceBot/Database.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index ce3fe04..88231d9 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -7,7 +7,7 @@ This is the SpiceBot Database # sopel imports from sopel.tools import Identifier import sopel.db -from sopel.db import SopelDB, _deserialize, Nicknames +from sopel.db import SopelDB, _deserialize, Nicknames, NickIDs from .Config import config as botconfig @@ -56,6 +56,9 @@ class PluginValues(BASE): class SpiceDB(object): + def dummyfunc_pep(self): + return NickIDs + # NICK FUNCTIONS def set_nick_value(self, nick, key, value, category='default'): From 0f940705c0b47561ac4b82540f40a84585c8a1eb Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 10:55:48 -0400 Subject: [PATCH 131/328] test --- sopel_modules/SpiceBot/Database.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 88231d9..2a10747 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -7,7 +7,7 @@ This is the SpiceBot Database # sopel imports from sopel.tools import Identifier import sopel.db -from sopel.db import SopelDB, _deserialize, Nicknames, NickIDs +from sopel.db import SopelDB, _deserialize from .Config import config as botconfig @@ -21,6 +21,24 @@ import json BASE = declarative_base() +class NickIDs(BASE): + """ + NickIDs SQLAlchemy Class + """ + __tablename__ = 'spice_nick_ids' + nick_id = Column(Integer, primary_key=True) + + +class Nicknames(BASE): + """ + Nicknames SQLAlchemy Class + """ + __tablename__ = 'spice_nicknames' + nick_id = Column(Integer, ForeignKey('spice_nick_ids.nick_id'), primary_key=True) + slug = Column(String(255), primary_key=True) + canonical = Column(String(255)) + + class NickValues(BASE): """ NickValues SQLAlchemy Class From d1141f951fa181c7134f81e60cc124426e517f38 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 11:05:31 -0400 Subject: [PATCH 132/328] naming --- sopel_modules/SpiceBot/Database.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 2a10747..783baaa 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -25,7 +25,7 @@ class NickIDs(BASE): """ NickIDs SQLAlchemy Class """ - __tablename__ = 'spice_nick_ids' + __tablename__ = 'nick_ids' nick_id = Column(Integer, primary_key=True) @@ -33,8 +33,8 @@ class Nicknames(BASE): """ Nicknames SQLAlchemy Class """ - __tablename__ = 'spice_nicknames' - nick_id = Column(Integer, ForeignKey('spice_nick_ids.nick_id'), primary_key=True) + __tablename__ = 'nicknames' + nick_id = Column(Integer, ForeignKey('nick_ids.nick_id'), primary_key=True) slug = Column(String(255), primary_key=True) canonical = Column(String(255)) From e97a3fd0456c7e862f299db9f50816ecc172fd3d Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 11:13:57 -0400 Subject: [PATCH 133/328] add category --- sopel_modules/SpiceBot/Database.py | 80 +++++++++++++++--------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 783baaa..5759333 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -525,71 +525,71 @@ class BotDatabase(): """Nick""" - def get_nick_value(self, nick, key): - return self.db.get_nick_value(nick, key) + def get_nick_value(self, nick, key, category='default'): + return self.db.get_nick_value(nick, key, category) - def set_nick_value(self, nick, key, value): - return self.db.set_nick_value(nick, key, value) + def set_nick_value(self, nick, key, value, category='default'): + return self.db.set_nick_value(nick, key, value, category) - def delete_nick_value(self, nick, key): - return self.db.delete_nick_value(nick, key) + def delete_nick_value(self, nick, key, category='default'): + return self.db.delete_nick_value(nick, key, category) - def adjust_nick_value(self, nick, key, value): - return self.db.adjust_nick_value(nick, key, value) + def adjust_nick_value(self, nick, key, value, category='default'): + return self.db.adjust_nick_value(nick, key, value, category) - def adjust_nick_list(self, nick, key, entries, adjustmentdirection): - return self.db.adjust_nick_list(nick, key, entries, adjustmentdirection) + def adjust_nick_list(self, nick, key, entries, adjustmentdirection, category='default'): + return self.db.adjust_nick_list(nick, key, entries, adjustmentdirection, category) """Bot""" - def get_bot_value(self, key): - return self.db.get_nick_value(botconfig.nick, key) + def get_bot_value(self, key, category='default'): + return self.db.get_nick_value(botconfig.nick, key, category) - def set_bot_value(self, key, value): - return self.db.set_nick_value(botconfig.nick, key, value) + def set_bot_value(self, key, value, category='default'): + return self.db.set_nick_value(botconfig.nick, key, value, category) - def delete_bot_value(self, key): - return self.db.delete_nick_value(botconfig.nick, key) + def delete_bot_value(self, key, category='default'): + return self.db.delete_nick_value(botconfig.nick, key, category) - def adjust_bot_value(self, key, value): - return self.db.adjust_nick_value(botconfig.nick, key, value) + def adjust_bot_value(self, key, value, category='default', category): + return self.db.adjust_nick_value(botconfig.nick, key, value, category) - def adjust_bot_list(self, key, entries, adjustmentdirection): - return self.db.adjust_nick_list(botconfig.nick, key, entries, adjustmentdirection) + def adjust_bot_list(self, key, entries, adjustmentdirection, category='default'): + return self.db.adjust_nick_list(botconfig.nick, key, entries, adjustmentdirection, category) """Channels""" - def get_channel_value(self, channel, key): - return self.db.get_channel_value(channel, key) + def get_channel_value(self, channel, key, category='default'): + return self.db.get_channel_value(channel, key, category) - def set_channel_value(self, channel, key, value): - return self.db.set_channel_value(channel, key, value) + def set_channel_value(self, channel, key, value, category='default'): + return self.db.set_channel_value(channel, key, value, category) - def delete_channel_value(self, channel, key): - return self.db.delete_channel_value(channel, key) + def delete_channel_value(self, channel, key, category='default'): + return self.db.delete_channel_value(channel, key, category) - def adjust_channel_value(self, channel, key, value): - return self.db.adjust_channel_value(channel, key, value) + def adjust_channel_value(self, channel, key, value, category='default'): + return self.db.adjust_channel_value(channel, key, value, category) - def adjust_channel_list(self, nick, key, entries, adjustmentdirection): - return self.db.adjust_channel_list(nick, key, entries, adjustmentdirection) + def adjust_channel_list(self, nick, key, entries, adjustmentdirection, category='default'): + return self.db.adjust_channel_list(nick, key, entries, adjustmentdirection, category) """Plugins""" - def get_plugin_value(self, plugin, key): - return self.db.get_plugin_value(plugin, key) + def get_plugin_value(self, plugin, key, category='default'): + return self.db.get_plugin_value(plugin, key, category) - def set_plugin_value(self, plugin, key, value): - return self.db.set_plugin_value(plugin, key, value) + def set_plugin_value(self, plugin, key, value, category='default'): + return self.db.set_plugin_value(plugin, key, value, category) - def delete_plugin_value(self, plugin, key): - return self.db.delete_plugin_value(plugin, key) + def delete_plugin_value(self, plugin, key, category='default'): + return self.db.delete_plugin_value(plugin, key, category) - def adjust_plugin_value(self, plugin, key, value): - return self.db.adjust_plugin_value(plugin, key, value) + def adjust_plugin_value(self, plugin, key, value, category='default'): + return self.db.adjust_plugin_value(plugin, key, value, category) - def adjust_plugin_list(self, nick, key, entries, adjustmentdirection): - return self.db.adjust_plugin_list(nick, key, entries, adjustmentdirection) + def adjust_plugin_list(self, nick, key, entries, adjustmentdirection, category='default'): + return self.db.adjust_plugin_list(nick, key, entries, adjustmentdirection, category) db = BotDatabase() From f1b9b4df03715ddda23282c52a855c70ef141987 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 11:34:39 -0400 Subject: [PATCH 134/328] test --- sopel_modules/SpiceBot/Database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 5759333..394c969 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -551,7 +551,7 @@ class BotDatabase(): def delete_bot_value(self, key, category='default'): return self.db.delete_nick_value(botconfig.nick, key, category) - def adjust_bot_value(self, key, value, category='default', category): + def adjust_bot_value(self, key, value, category='default'): return self.db.adjust_nick_value(botconfig.nick, key, value, category) def adjust_bot_list(self, key, entries, adjustmentdirection, category='default'): From 72edc5f33c6a4da96d7f6154514558078d6ea677 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 13:48:06 -0400 Subject: [PATCH 135/328] commands no longer needs bot --- sopel_modules/SpiceBot/Commands.py | 39 ++++++++++--------- sopel_modules/SpiceBot/Prerun.py | 8 ++-- sopel_modules/SpiceBot_GifSearch/gifsearch.py | 2 +- .../SpiceBot_Module_Parsing/ModuleParsing.py | 2 +- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 03ecd0f..11ebcdb 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -12,6 +12,7 @@ import threading import spicemanip from .Logs import logs +from .Config import config as botconfig from .Database import db as botdb @@ -37,13 +38,13 @@ class BotCommands(): return commandstype return None - def get_commands_disabled(self, bot, channel): + def get_commands_disabled(self, channel): if not len(list(self.dict['disabled'])): - self.dict['disabled'] = botdb.get_channel_value(bot, channel, 'commands_disabled') or {} + self.dict['disabled'] = botdb.get_channel_value(channel, 'commands_disabled') or {} return self.dict['disabled'] - def check_commands_disabled(self, bot, command, channel): - if command in self.get_commands_disabled(bot, channel).keys(): + def check_commands_disabled(self, command, channel): + if command in self.get_commands_disabled(channel).keys(): return True else: return False @@ -62,20 +63,20 @@ class BotCommands(): return realcom - def set_command_disabled(self, bot, command, channel, timestamp, reason, bywhom): + def set_command_disabled(self, command, channel, timestamp, reason, bywhom): if not len(list(self.dict['disabled'])): - self.dict['disabled'] = botdb.get_channel_value(bot, channel, 'commands_disabled') or {} + self.dict['disabled'] = botdb.get_channel_value(channel, 'commands_disabled') or {} self.dict['disabled'][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom} - botdb.set_channel_value(bot, channel, 'commands_disabled', self.dict['disabled']) + botdb.set_channel_value(channel, 'commands_disabled', self.dict['disabled']) - def unset_command_disabled(self, bot, command, channel): + def unset_command_disabled(self, command, channel): if not len(list(self.dict['disabled'])): - self.dict['disabled'] = botdb.get_channel_value(bot, channel, 'commands_disabled') or {} + self.dict['disabled'] = botdb.get_channel_value(channel, 'commands_disabled') or {} if command in self.dict['disabled'].keys(): del self.dict['disabled'][command] - botdb.set_channel_value(bot, channel, 'commands_disabled', self.dict['disabled']) + botdb.set_channel_value(channel, 'commands_disabled', self.dict['disabled']) - def register(self, bot, command_dict): + def register(self, command_dict): self.lock.acquire() @@ -107,7 +108,7 @@ class BotCommands(): self.lock.release() - def module_directory_list(self, bot): + def module_directory_list(self): filepathlisting = [] # main Modules directory @@ -116,7 +117,7 @@ class BotCommands(): filepathlisting.append(modules_dir) # Home Directory - home_modules_dir = os.path.join(bot.config.homedir, 'modules') + home_modules_dir = os.path.join(botconfig.config.homedir, 'modules') if os.path.isdir(home_modules_dir): filepathlisting.append(home_modules_dir) @@ -131,13 +132,13 @@ class BotCommands(): logs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) # Extra directories - for directory in bot.config.core.extra: + for directory in botconfig.dict["core"]["extra"]: filepathlisting.append(directory) return filepathlisting - def module_files_list(self, bot): - filepathlisting = self.module_directory_list(bot) + def module_files_list(self): + filepathlisting = self.module_directory_list() filepathlist = [] @@ -155,8 +156,8 @@ class BotCommands(): return filepathlist - def module_files_parse(self, bot): - filepathlist = self.module_files_list(bot) + def module_files_parse(self): + filepathlist = self.module_files_list() for modulefile in filepathlist: @@ -226,7 +227,7 @@ class BotCommands(): if len(filelinelist): for atlinefound in filelinelist: - self.register(bot, atlinefound) + self.register(atlinefound) commands = BotCommands() diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 6dc0cf5..820552d 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -161,11 +161,11 @@ class BotPrerun(): bot.osd("This command must be run in a channel you which to enable it in.", trigger.nick, 'notice') return - if not commands.check_commands_disabled(bot, trigger.sb["realcom"], trigger.sender): + if not commands.check_commands_disabled(trigger.sb["realcom"], trigger.sender): bot.osd(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick, 'notice') return - commands.unset_command_disabled(bot, trigger.sb["realcom"], trigger.sender) + commands.unset_command_disabled(trigger.sb["realcom"], trigger.sender) bot.osd(trigger.sb["com"] + " is now enabled in " + str(trigger.sender)) return @@ -179,14 +179,14 @@ class BotPrerun(): bot.osd("This command must be run in a channel you which to disable it in.", trigger.nick, 'notice') return - if commands.check_commands_disabled(bot, trigger.sb["realcom"], trigger.sender): + if commands.check_commands_disabled(trigger.sb["realcom"], trigger.sender): bot.osd(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick, 'notice') return trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given." timestamp = str(datetime.datetime.utcnow()) - commands.set_command_disabled(bot, trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) + commands.set_command_disabled(trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) bot.osd(trigger.sb["com"] + " is now disabled in " + str(trigger.sender)) return diff --git a/sopel_modules/SpiceBot_GifSearch/gifsearch.py b/sopel_modules/SpiceBot_GifSearch/gifsearch.py index a63bf93..8d64430 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifsearch.py +++ b/sopel_modules/SpiceBot_GifSearch/gifsearch.py @@ -75,7 +75,7 @@ def setup(bot): "validcoms": validgifapi } SpiceBot.commands.dict['counts'] += 1 - SpiceBot.commands.register(bot, command_dict) + SpiceBot.commands.register(command_dict) if validgifapi not in bot.memory["SpiceBot_GifSearch"]['cache'].keys(): bot.memory["SpiceBot_GifSearch"]['cache'][validgifapi] = dict() diff --git a/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py b/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py index 0802d4f..38d6ac2 100644 --- a/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py +++ b/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py @@ -12,7 +12,7 @@ def setup(bot): SpiceBot.logs.log('SpiceBot_Commands', "Starting setup procedure") SpiceBot.events.startup_add([SpiceBot.events.BOT_COMMANDSQUERY]) - SpiceBot.commands.module_files_parse(bot) + SpiceBot.commands.module_files_parse() for comtype in ['module', 'nickname', 'rule']: SpiceBot.logs.log('SpiceBot_Commands', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) From 663f7f318249dcb97bda1dc2c5338a0e4ef57643 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 14:10:37 -0400 Subject: [PATCH 136/328] test setting up complete config --- sopel_modules/SpiceBot/Config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 6d6508c..1bed86d 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals, absolute_import, division, print_function """A way to read the bot's config without bot""" +import sopel.config from sopel.cli.run import build_parser, get_configuration import sys @@ -25,6 +26,9 @@ class BotConfig(): # Filename self.filename = self.config.filename + # load Sopel config fully + sopel.config.Config(self.config.filename) + # load as dict config = configparser.ConfigParser() config.read(self.filename) From 81104b692bb1ad5c079bcca89057116f1160204e Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 14:18:40 -0400 Subject: [PATCH 137/328] extra --- sopel_modules/SpiceBot/Commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 11ebcdb..1bd72d3 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -132,7 +132,7 @@ class BotCommands(): logs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) # Extra directories - for directory in botconfig.dict["core"]["extra"]: + for directory in botconfig.config.extra: filepathlisting.append(directory) return filepathlisting From 0b72005726f31c125c80bfb892569f8bf697997b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 14:26:46 -0400 Subject: [PATCH 138/328] test extra --- sopel_modules/SpiceBot/Commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 1bd72d3..b5cdc3d 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -132,7 +132,7 @@ class BotCommands(): logs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) # Extra directories - for directory in botconfig.config.extra: + for directory in botconfig.config.core.extra: filepathlisting.append(directory) return filepathlisting From 3c5608f347878c177dd3fc45960b4fef0c9f2ca7 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 14:33:25 -0400 Subject: [PATCH 139/328] didn't need that --- sopel_modules/SpiceBot/Config.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 1bed86d..c7fe077 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -26,9 +26,6 @@ class BotConfig(): # Filename self.filename = self.config.filename - # load Sopel config fully - sopel.config.Config(self.config.filename) - # load as dict config = configparser.ConfigParser() config.read(self.filename) From ae8e58b819c64332b28f6cf597d33c6a37b012de Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 14:43:28 -0400 Subject: [PATCH 140/328] logs without bot --- sopel_modules/SpiceBot/Logs.py | 27 +++++++++---------- sopel_modules/SpiceBot_Logs/Logs_Command.py | 2 +- sopel_modules/SpiceBot_Logs/Queue.py | 3 +-- .../StartupMonologue_Display_Errors.py | 2 +- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/sopel_modules/SpiceBot/Logs.py b/sopel_modules/SpiceBot/Logs.py index 0b13058..9e201d5 100644 --- a/sopel_modules/SpiceBot/Logs.py +++ b/sopel_modules/SpiceBot/Logs.py @@ -11,6 +11,8 @@ import threading import os import spicemanip +from .Config import config as botconfig + class BotLogs(): """This Is a contained source of log information""" @@ -20,9 +22,6 @@ class BotLogs(): "list": {"Sopel_systemd": [], "Sopel_stdio": []}, "queue": [] } - self.sopel_config = { - "logging_channel": True - } def log(self, logtype, logentry, stdio=False): @@ -31,7 +30,7 @@ class BotLogs(): logtitle = "[" + logtype + "]" logmessage = logtitle + " " + logentry - if self.sopel_config["logging_channel"]: + if botconfig.config.core.logging_channel: self.dict["queue"].append(logmessage) if stdio: @@ -43,22 +42,22 @@ class BotLogs(): self.lock.release() - def get_logs(self, bot, logtype): + def get_logs(self, logtype): if logtype == "Sopel_systemd": - logindex = self.systemd_logs_fetch(bot) + logindex = self.systemd_logs_fetch() elif logtype == "Sopel_stdio": - logindex = self.stdio_logs_fetch(bot) + logindex = self.stdio_logs_fetch() else: logindex = self.dict["list"][logtype] return logindex - def stdio_logs_fetch(self, bot): + def stdio_logs_fetch(self): stdio_ignore = [] for logtype in self.dict["list"].keys(): stdio_ignore.append("[" + logtype + "]") - logfile = os.path.os.path.join(bot.config.core.logdir, 'stdio.log') + logfile = os.path.os.path.join(botconfig.config.core.logdir, 'stdio.log') try: log_file_lines = [] @@ -92,8 +91,8 @@ class BotLogs(): return debuglines - def systemd_logs_fetch(self, bot): - servicepid = self.get_running_pid(bot) + def systemd_logs_fetch(self): + servicepid = self.get_running_pid() debuglines = [] for line in os.popen(str("sudo journalctl _PID=" + str(servicepid))).read().split('\n'): line = str(line).split(str(os.uname()[1] + " "))[-1] @@ -104,14 +103,14 @@ class BotLogs(): debuglines.append(str(line)) return debuglines - def get_running_pid(self, bot): + def get_running_pid(self): try: - filename = "/run/sopel/sopel-" + str(bot.nick) + ".pid" + filename = "/run/sopel/sopel-" + str(botconfig.config.core.nick) + ".pid" with open(filename, 'r') as pid_file: pidnum = int(pid_file.read()) except Exception as e: pidnum = e - pidnum = str(os.popen("systemctl show " + str(bot.nick) + " --property=MainPID").read()).split("=")[-1] + pidnum = str(os.popen("systemctl show " + str(botconfig.config.core.nick) + " --property=MainPID").read()).split("=")[-1] return pidnum diff --git a/sopel_modules/SpiceBot_Logs/Logs_Command.py b/sopel_modules/SpiceBot_Logs/Logs_Command.py index 0819ab6..99545f1 100644 --- a/sopel_modules/SpiceBot_Logs/Logs_Command.py +++ b/sopel_modules/SpiceBot_Logs/Logs_Command.py @@ -33,7 +33,7 @@ def bot_command_logs(bot, trigger): logtype = SpiceBot.inlist_match(logtype, SpiceBot.logs.dict["list"].keys()) - logindex = SpiceBot.logs.get_logs(bot, logtype) + logindex = SpiceBot.logs.get_logs(logtype) if not len(logindex): bot.osd("No logs found for " + str(logtype) + ".") diff --git a/sopel_modules/SpiceBot_Logs/Queue.py b/sopel_modules/SpiceBot_Logs/Queue.py index dedfc53..274bdeb 100644 --- a/sopel_modules/SpiceBot_Logs/Queue.py +++ b/sopel_modules/SpiceBot_Logs/Queue.py @@ -18,7 +18,7 @@ def setup(bot): @sopel.module.rule('.*') def join_log_channel(bot, trigger): - if bot.config.core.logging_channel: + if SpiceBot.config.config.core.logging_channel: channel = bot.config.core.logging_channel if channel not in bot.channels.keys(): bot.write(('JOIN', bot.nick, channel)) @@ -30,5 +30,4 @@ def join_log_channel(bot, trigger): bot.osd(str(SpiceBot.logs.dict["queue"][0]), channel) del SpiceBot.logs.dict["queue"][0] else: - SpiceBot.logs.sopel_config["logging_channel"] = False SpiceBot.logs.dict["queue"] = [] diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py index 34b0ede..4cd49db 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py @@ -10,7 +10,7 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.rule('.*') def bot_startup_monologue_start(bot, trigger): - debuglines = SpiceBot.logs.stdio_logs_fetch(bot) + debuglines = SpiceBot.logs.stdio_logs_fetch() searchphrasefound = [] for line in debuglines: From 12737d5381a17eb0636e29037970f6a3c9e5481f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 15:05:28 -0400 Subject: [PATCH 141/328] rework tools and setup procedures with the new config --- sopel_modules/SpiceBot/Tools.py | 35 ++++++++++--------- sopel_modules/SpiceBot_AI/AI.py | 12 +++---- sopel_modules/SpiceBot_BotPrivs/BotPrivs.py | 2 +- .../Channels_Parsing.py | 1 + .../NickQueryCommand.py | 4 +-- .../SpiceBot_CommandsQuery/QueryCommand.py | 4 +-- sopel_modules/SpiceBot_GifSearch/gifsearch.py | 6 ++-- sopel_modules/SpiceBot_Kick/__init__.py | 1 + sopel_modules/SpiceBot_Logs/Logs_Command.py | 2 +- sopel_modules/SpiceBot_Restart/Restart.py | 2 +- .../SpiceBot_SopelPatches/Patches.py | 2 +- sopel_modules/SpiceBot_Update/Update.py | 7 ++-- sopel_modules/SpiceBot_osd/__init__.py | 1 + 13 files changed, 43 insertions(+), 36 deletions(-) diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index b724240..e290cf2 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -20,6 +20,7 @@ from pygit2 import clone_repository import spicemanip from .Logs import logs +from .Config import config as botconfig """Variable References""" @@ -38,10 +39,10 @@ github_dict = { """Sopel Wrapping Tools""" -def bot_privs(bot, privtype): +def bot_privs(privtype): if privtype == 'owners': privtype = 'owner' - botpriveval = eval("bot.config.core." + privtype) + botpriveval = eval("botconfig.config.config.core." + privtype) if not isinstance(botpriveval, list): botpriveval = [botpriveval] return botpriveval @@ -53,7 +54,7 @@ def command_permissions_check(bot, trigger, privslist): for botpriv in ["admins", "owner"]: if botpriv in privslist: - botpriveval = bot_privs(bot, botpriv) + botpriveval = bot_privs(botpriv) if not inlist(trigger.nick, botpriveval): commandrunconsensus.append('False') else: @@ -117,7 +118,7 @@ def humanized_time(countdownseconds): """Online Information Requests""" -def googlesearch(bot, searchterm, searchtype=None): +def googlesearch(searchterm, searchtype=None): header = {'User-Agent': str(UserAgent().chrome)} data = searchterm.replace(' ', '+') lookfor = data.replace(':', '%3A') @@ -184,7 +185,7 @@ def similar(a, b): return SequenceMatcher(None, a, b).ratio() -def similar_list(bot, searchitem, searchlist, matchcount=1, searchorder='reverse'): +def similar_list(searchitem, searchlist, matchcount=1, searchorder='reverse'): if sys.version_info.major >= 3: if isinstance(searchlist, abc.KeysView): @@ -213,7 +214,7 @@ def similar_list(bot, searchitem, searchlist, matchcount=1, searchorder='reverse return sim_listitems -def array_arrangesort(bot, sortbyarray, arrayb): +def array_arrangesort(sortbyarray, arrayb): sortbyarray, arrayb = (list(x) for x in zip(*sorted(zip(sortbyarray, arrayb), key=itemgetter(0)))) return sortbyarray, arrayb @@ -249,7 +250,7 @@ def channel_privs(bot, channel, privtype): """Environment Functions""" -def stock_modules_begone(bot): +def stock_modules_begone(): # Remove stock modules, if present main_sopel_dir = os.path.dirname(os.path.abspath(sopel.__file__)) @@ -273,7 +274,7 @@ def stock_modules_begone(bot): os.system("sudo mv " + path + " " + stockdir) -def spicebot_update(bot, deps=False): +def spicebot_update(deps=False): if not os.path.exists("/tmp") or not os.path.isdir("/tmp"): os.system("sudo mkdir /tmp") @@ -283,13 +284,13 @@ def spicebot_update(bot, deps=False): logs.log('SpiceBot_Update', "Cloning to " + clonepath, True) - clone_repository(str(bot.config.SpiceBot_Update.gitrepo + ".git"), clonepath, checkout_branch=bot.config.SpiceBot_Update.gitbranch) + clone_repository(str(botconfig.config.config.SpiceBot_Update.gitrepo + ".git"), clonepath, checkout_branch=botconfig.config.config.SpiceBot_Update.gitbranch) pipcommand = "sudo pip3 install --upgrade" if not deps: pipcommand += " --no-deps" pipcommand += " --force-reinstall" - # pipcommand += " git+" + str(bot.config.SpiceBot_Update.gitrepo) + "@" + str(bot.config.SpiceBot_Update.gitbranch) + # pipcommand += " git+" + str(botconfig.config.config.SpiceBot_Update.gitrepo) + "@" + str(botconfig.config.config.SpiceBot_Update.gitbranch) pipcommand += " /tmp/SpiceBot/" logs.log('SpiceBot_Update', "Running `" + pipcommand + "`", True) @@ -301,15 +302,15 @@ def spicebot_update(bot, deps=False): os.system("sudo rm -r /tmp/SpiceBot") - stock_modules_begone(bot) + stock_modules_begone() def spicebot_reload(bot, log_from='service_manip', quitmessage='Recieved QUIT'): - # service_manip(bot, bot.nick, 'restart', log_from) + # service_manip(bot.nick, 'restart', log_from) bot.restart(quitmessage) -def service_manip(bot, servicename, dowhat, log_from='service_manip'): +def service_manip(servicename, dowhat, log_from='service_manip'): if str(dowhat) not in ["start", "stop", "restart"]: return try: @@ -322,7 +323,7 @@ def service_manip(bot, servicename, dowhat, log_from='service_manip'): """Config Reading Functions""" -def read_directory_json_to_dict(bot, directories, configtypename="Config File", log_from='read_directory_json_to_dict'): +def read_directory_json_to_dict(directories, configtypename="Config File", log_from='read_directory_json_to_dict', logging=True): if not isinstance(directories, list): directories = [directories] @@ -347,7 +348,7 @@ def read_directory_json_to_dict(bot, directories, configtypename="Config File", dict_from_file = eval(infread) except Exception as e: filereadgood = False - if bot: + if logging: logs.log(log_from, "Error loading %s: %s (%s)" % (configtypename, e, filepath)) dict_from_file = dict() # Close File @@ -362,11 +363,11 @@ def read_directory_json_to_dict(bot, directories, configtypename="Config File", fileopenfail += 1 if filecount: - if bot: + if logging: logs.log(log_from, 'Registered %d %s dict files,' % (filecount, configtypename)) logs.log(log_from, '%d %s dict files failed to load' % (fileopenfail, configtypename), True) else: - if bot: + if logging: logs.log(log_from, "Warning: Couldn't load any %s dict files" % (configtypename)) return configs_dict diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index e43eb53..314dc26 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -29,7 +29,7 @@ def bot_command_nick(bot, trigger): if fulltrigger.lower().startswith("what is"): searchterm = spicemanip.main(trigger.sb['args'], "3+") or None if searchterm: - searchreturn = SpiceBot.googlesearch(bot, searchterm) + searchreturn = SpiceBot.googlesearch(searchterm) if not searchreturn: bot.osd('I cannot find anything about that') else: @@ -44,7 +44,7 @@ def bot_command_nick(bot, trigger): if searchterm.lower() in ['waldo', 'wally']: bot.osd("He is hiding for a reason?") - searchreturn = SpiceBot.googlesearch(bot, "wimmelbilderbuch") + searchreturn = SpiceBot.googlesearch("wimmelbilderbuch") if searchreturn: bot.osd(str(searchreturn)) return @@ -53,7 +53,7 @@ def bot_command_nick(bot, trigger): carmenlocale = ['ACME Headquarters', "Villains' International League of Evil"] bot.osd("Currently she is located at " + spicemanip.main(carmenlocale, 'random')) return - searchreturn = SpiceBot.googlesearch(bot, searchterm, 'maps') + searchreturn = SpiceBot.googlesearch(searchterm, 'maps') if not searchreturn: bot.osd('I cannot find anything about that') @@ -96,7 +96,7 @@ def bot_command_nick(bot, trigger): elif fulltrigger.lower().endswith(tuple(["order 66"])): if fulltrigger.lower() == "execute order 66": - if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs(bot, 'owners')): + if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs('owners')): if trigger.is_privmsg: jedi = None else: @@ -114,7 +114,7 @@ def bot_command_nick(bot, trigger): bot.osd("I'm sure I don't know what you're talking about.") elif fulltrigger.lower() == "explain order 66": - if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs(bot, 'owners')): + if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs('owners')): bot.osd("Order 66 is an instruction that only you can give, sir. When you give the order I will rise up against my overlords and slay them.") else: bot.osd("I'm afraid I cannot tell you that, sir.") @@ -123,7 +123,7 @@ def bot_command_nick(bot, trigger): return elif fulltrigger.lower() == "initiate clean slate protocol": - if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs(bot, 'admins')): + if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs('admins')): bot.osd("sends a destruct command to the network of bots.", 'action') else: bot.osd("I'm afraid you do not have the authority to make that call, " + trigger.nick + ".") diff --git a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py index 9927b9b..af409f4 100644 --- a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py +++ b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py @@ -26,5 +26,5 @@ def bot_command_process(bot, trigger): if trigger.sb['com'] == 'owner': trigger.sb['com'] = 'owners' - privlist = spicemanip.main(SpiceBot.bot_privs(bot, trigger.sb['com']), 'andlist') + privlist = spicemanip.main(SpiceBot.bot_privs(trigger.sb['com']), 'andlist') bot.osd(str(bot.nick) + " " + trigger.sb['com'] + ": " + privlist) diff --git a/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py b/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py index a9002e7..f497c3a 100644 --- a/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py +++ b/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py @@ -32,6 +32,7 @@ def setup(bot): SpiceBot.logs.log('SpiceBot_Channels', "Starting setup procedure") SpiceBot.events.startup_add([SpiceBot.events.BOT_CHANNELS]) bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) + SpiceBot.config.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) @sopel.module.event(SpiceBot.events.RPL_WELCOME) diff --git a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py index 11109fd..d4fef62 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py @@ -39,7 +39,7 @@ def query_detection_nick(bot, trigger): 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') + closestmatches = SpiceBot.similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') if len(closestmatches): dispmsg.append("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") bot.osd(dispmsg, trigger.nick, 'notice') @@ -58,7 +58,7 @@ def query_detection_nick(bot, trigger): if not trigger.sb['com'] or not len(trigger.sb['com']): return - closestmatches = SpiceBot.similar_list(bot, trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') + closestmatches = SpiceBot.similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') if not len(closestmatches): bot.osd("Cannot find any similar " + bot.nick + " commands for " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') else: diff --git a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py index 533818c..277db87 100644 --- a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py +++ b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py @@ -37,7 +37,7 @@ def query_detection(bot, trigger): 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') + closestmatches = SpiceBot.similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') if len(closestmatches): dispmsg.append("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") bot.osd(dispmsg, trigger.nick, 'notice') @@ -56,7 +56,7 @@ def query_detection(bot, trigger): if not trigger.sb['com'] or not len(trigger.sb['com']): return - closestmatches = SpiceBot.similar_list(bot, trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') + closestmatches = SpiceBot.similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') if not len(closestmatches): bot.osd("Cannot find any similar commands for " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') else: diff --git a/sopel_modules/SpiceBot_GifSearch/gifsearch.py b/sopel_modules/SpiceBot_GifSearch/gifsearch.py index 8d64430..b7eda44 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifsearch.py +++ b/sopel_modules/SpiceBot_GifSearch/gifsearch.py @@ -29,7 +29,7 @@ class GifAPISection(StaticSection): def configure(config): moduledir = os.path.dirname(os.path.abspath(__file__)) api_dir = os.path.join(moduledir, 'gifapi') - valid_gif_api_dict = SpiceBot.read_directory_json_to_dict(None, [api_dir], "Gif API", "SpiceBot_GifSearch") + valid_gif_api_dict = SpiceBot.read_directory_json_to_dict([api_dir], "Gif API", "SpiceBot_GifSearch", logging=True) config.define_section("SopelGifSearch", GifAPIMainSection, validate=False) config.SopelGifSearch.configure_setting('extra', 'SpiceBot_GifSearch API Extra directory') @@ -55,13 +55,15 @@ def setup(bot): dir_to_scan.append(api_dir) bot.config.define_section("SopelGifSearch", GifAPIMainSection, validate=False) + SpiceBot.config.config.define_section("SopelGifSearch", GifAPIMainSection, validate=False) if bot.config.SopelGifSearch.extra: dir_to_scan.append(bot.config.SopelGifSearch.extra) - valid_gif_api_dict = SpiceBot.read_directory_json_to_dict(bot, dir_to_scan, "Gif API", "SpiceBot_GifSearch") + valid_gif_api_dict = SpiceBot.read_directory_json_to_dict(dir_to_scan, "Gif API", "SpiceBot_GifSearch", logging=True) for gif_api in valid_gif_api_dict.keys(): bot.config.define_section(gif_api, GifAPISection, validate=False) + SpiceBot.config.config.define_section(gif_api, GifAPISection, validate=False) apikey = eval("bot.config." + gif_api + ".apikey") if apikey: valid_gif_api_dict[gif_api]["apikey"] = apikey diff --git a/sopel_modules/SpiceBot_Kick/__init__.py b/sopel_modules/SpiceBot_Kick/__init__.py index d00503b..b628b5c 100644 --- a/sopel_modules/SpiceBot_Kick/__init__.py +++ b/sopel_modules/SpiceBot_Kick/__init__.py @@ -42,6 +42,7 @@ def setup(bot): # verify config settings for server SpiceBot.logs.log('SpiceBot_Kick', "Checking for config settings") bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) + SpiceBot.config.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) @module.event('005') diff --git a/sopel_modules/SpiceBot_Logs/Logs_Command.py b/sopel_modules/SpiceBot_Logs/Logs_Command.py index 99545f1..d170629 100644 --- a/sopel_modules/SpiceBot_Logs/Logs_Command.py +++ b/sopel_modules/SpiceBot_Logs/Logs_Command.py @@ -23,7 +23,7 @@ def bot_command_logs(bot, trigger): return if not SpiceBot.inlist(logtype, SpiceBot.logs.dict["list"].keys()): - closestmatches = SpiceBot.similar_list(bot, logtype, SpiceBot.logs.dict["list"].keys(), 10, 'reverse') + closestmatches = SpiceBot.similar_list(logtype, SpiceBot.logs.dict["list"].keys(), 10, 'reverse') if not len(closestmatches): bot.osd("No valid logs match " + str(logtype) + ".", trigger.nick, 'notice') else: diff --git a/sopel_modules/SpiceBot_Restart/Restart.py b/sopel_modules/SpiceBot_Restart/Restart.py index 3f25341..f3f255d 100644 --- a/sopel_modules/SpiceBot_Restart/Restart.py +++ b/sopel_modules/SpiceBot_Restart/Restart.py @@ -18,5 +18,5 @@ def nickname_comand_restart(bot, trigger): SpiceBot.logs.log('SpiceBot_Restart', quitmessage) bot.osd(quitmessage, bot.channels.keys()) - # service_manip(bot, bot.nick, 'restart', 'SpiceBot_Restart') + # service_manip(bot.nick, 'restart', 'SpiceBot_Restart') SpiceBot.spicebot_reload(bot, 'SpiceBot_Restart', quitmessage) diff --git a/sopel_modules/SpiceBot_SopelPatches/Patches.py b/sopel_modules/SpiceBot_SopelPatches/Patches.py index eb4d009..e6a19f7 100644 --- a/sopel_modules/SpiceBot_SopelPatches/Patches.py +++ b/sopel_modules/SpiceBot_SopelPatches/Patches.py @@ -16,4 +16,4 @@ def setup(bot): bot.memory['url_callbacks'] = sopel.tools.SopelMemory() SpiceBot.logs.log('Sopel_Patch', "Removing Stock Modules and verifying Dummy Command is present.") - SpiceBot.stock_modules_begone(bot) + SpiceBot.stock_modules_begone() diff --git a/sopel_modules/SpiceBot_Update/Update.py b/sopel_modules/SpiceBot_Update/Update.py index 613d734..43450d3 100644 --- a/sopel_modules/SpiceBot_Update/Update.py +++ b/sopel_modules/SpiceBot_Update/Update.py @@ -25,6 +25,7 @@ def configure(config): def setup(bot): SpiceBot.logs.log('SpiceBot_Update', "Initial Setup processing") bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) + SpiceBot.config.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) @SpiceBot.prerun.prerun('nickname') @@ -51,9 +52,9 @@ def nickname_comand_update(bot, trigger): bot.osd(quitmessage, bot.channels.keys()) if commandused == 'nodeps': - SpiceBot.spicebot_update(bot, False) + SpiceBot.spicebot_update(False) if commandused == 'deps': - SpiceBot.spicebot_update(bot, True) + SpiceBot.spicebot_update(True) - # service_manip(bot, bot.nick, 'restart', 'SpiceBot_Update') + # service_manip(bot.nick, 'restart', 'SpiceBot_Update') SpiceBot.spicebot_reload(bot, 'SpiceBot_Update', quitmessage) diff --git a/sopel_modules/SpiceBot_osd/__init__.py b/sopel_modules/SpiceBot_osd/__init__.py index 2137386..96b857a 100644 --- a/sopel_modules/SpiceBot_osd/__init__.py +++ b/sopel_modules/SpiceBot_osd/__init__.py @@ -50,6 +50,7 @@ def setup(bot): # verify config settings for server SpiceBot.logs.log('SpiceBot_OSD', "Checking for config settings") bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) + SpiceBot.config.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) @module.event('005') From 81acd5ae49dda301ef753e0c5df56f27ebff5316 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 15:22:17 -0400 Subject: [PATCH 142/328] test configure and setup migration --- sopel_modules/SpiceBot/Config.py | 7 +++++- sopel_modules/SpiceBot/__init__.py | 3 +++ sopel_modules/SpiceBot/configure.py | 22 ++++++++++++++++++ sopel_modules/SpiceBot/setup.py | 19 +++++++++++++++ .../Channels_Parsing.py | 23 ------------------- 5 files changed, 50 insertions(+), 24 deletions(-) create mode 100644 sopel_modules/SpiceBot/configure.py create mode 100644 sopel_modules/SpiceBot/setup.py diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index c7fe077..c145d87 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -36,10 +36,15 @@ class BotConfig(): if each_key.lower() not in self.dict[each_section.lower()].keys(): self.dict[each_section.lower()][each_key.lower()] = each_val + def define_section(self, name, cls_, validate=True): + return self.config.define_section(name, cls_, validate) + def __getattr__(self, name): ''' will only get called for undefined attributes ''' """We will try to find a core value, or return None""" - if name.lower() in self.dict["core"].keys(): + if hasattr(self.config.core, name): + return eval("self.config.core." + name) + elif name.lower() in self.dict["core"].keys(): return self.dict["core"][str(name).lower()] else: return None diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index 93f67c6..e7ffc2b 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -6,6 +6,9 @@ These are the core SpiceBot Classes This module contains references only for other modules to utilize. """ +from .configure import * +from .setup import * + from .Config import * from .Tools import * from .Logs import * diff --git a/sopel_modules/SpiceBot/configure.py b/sopel_modules/SpiceBot/configure.py new file mode 100644 index 0000000..ca4126b --- /dev/null +++ b/sopel_modules/SpiceBot/configure.py @@ -0,0 +1,22 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +"""Configuration for SpiceBot""" + +import sopel.module +from sopel.config.types import StaticSection, ValidatedAttribute, ListAttribute + + +class SpiceBot_Channels_MainSection(StaticSection): + announcenew = ValidatedAttribute('announcenew', default=False) + joinall = ValidatedAttribute('joinall', default=False) + operadmin = ValidatedAttribute('operadmin', default=False) + chanignore = ListAttribute('chanignore') + + +def configure(config): + + config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) + config.SpiceBot_Channels.configure_setting('announcenew', 'SpiceBot_Channels Announce New Channels') + config.SpiceBot_Channels.configure_setting('joinall', 'SpiceBot_Channels JOIN New Channels') + config.SpiceBot_Channels.configure_setting('operadmin', 'SpiceBot_Channels OPER ADMIN MODE') + config.SpiceBot_Channels.configure_setting('chanignore', 'SpiceBot_Channels Ignore JOIN for channels') diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py new file mode 100644 index 0000000..8063962 --- /dev/null +++ b/sopel_modules/SpiceBot/setup.py @@ -0,0 +1,19 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +"""Configuration for SpiceBot""" + +import sopel.module + +from .Logs import logs +from .Events import events +from .Config import config as botconfig + +from .configure import SpiceBot_Channels_MainSection + + +def setup(bot): + + logs.log('SpiceBot_Channels', "Starting setup procedure") + events.startup_add([events.BOT_CHANNELS]) + bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) + botconfig.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) diff --git a/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py b/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py index f497c3a..b33d9f0 100644 --- a/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py +++ b/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py @@ -4,7 +4,6 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi # sopel imports import sopel.module -from sopel.config.types import StaticSection, ValidatedAttribute, ListAttribute import sopel_modules.SpiceBot as SpiceBot @@ -13,28 +12,6 @@ import spicemanip import time -class SpiceBot_Channels_MainSection(StaticSection): - announcenew = ValidatedAttribute('announcenew', default=False) - joinall = ValidatedAttribute('joinall', default=False) - operadmin = ValidatedAttribute('operadmin', default=False) - chanignore = ListAttribute('chanignore') - - -def configure(config): - config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) - config.SpiceBot_Channels.configure_setting('announcenew', 'SpiceBot_Channels Announce New Channels') - config.SpiceBot_Channels.configure_setting('joinall', 'SpiceBot_Channels JOIN New Channels') - config.SpiceBot_Channels.configure_setting('operadmin', 'SpiceBot_Channels OPER ADMIN MODE') - config.SpiceBot_Channels.configure_setting('chanignore', 'SpiceBot_Channels Ignore JOIN for channels') - - -def setup(bot): - SpiceBot.logs.log('SpiceBot_Channels', "Starting setup procedure") - SpiceBot.events.startup_add([SpiceBot.events.BOT_CHANNELS]) - bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) - SpiceBot.config.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) - - @sopel.module.event(SpiceBot.events.RPL_WELCOME) @sopel.module.rule('.*') def unkickable_bot(bot, trigger): From fdcfe42bf4a5c1b7e078a79ed035c16bb4bd99b9 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 15:34:47 -0400 Subject: [PATCH 143/328] test configuration --- sopel_modules/SpiceBot/Channels.py | 19 +++++++++++++++++++ sopel_modules/SpiceBot/configure.py | 10 +--------- sopel_modules/SpiceBot/setup.py | 10 ++-------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index 998ee55..1e21b84 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -4,13 +4,32 @@ from __future__ import unicode_literals, absolute_import, division, print_functi This is the SpiceBot Channels system. """ import sopel +from sopel.config.types import StaticSection, ValidatedAttribute, ListAttribute + import re import threading +from .Config import config as botconfig +from .Events import events +from .Logs import logs + + +class SpiceBot_Channels_MainSection(StaticSection): + announcenew = ValidatedAttribute('announcenew', default=False) + joinall = ValidatedAttribute('joinall', default=False) + operadmin = ValidatedAttribute('operadmin', default=False) + chanignore = ListAttribute('chanignore') + class BotChannels(): """This Logs all channels known to the server""" def __init__(self): + + # SpiceBot + logs.log('SpiceBot_Channels', "Setting Up BotChannels class") + botconfig.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) + events.startup_add([events.BOT_CHANNELS]) + self.lock = threading.Lock() self.channel_lock = False self.dict = { diff --git a/sopel_modules/SpiceBot/configure.py b/sopel_modules/SpiceBot/configure.py index ca4126b..3b8a30a 100644 --- a/sopel_modules/SpiceBot/configure.py +++ b/sopel_modules/SpiceBot/configure.py @@ -2,15 +2,7 @@ from __future__ import unicode_literals, absolute_import, division, print_function """Configuration for SpiceBot""" -import sopel.module -from sopel.config.types import StaticSection, ValidatedAttribute, ListAttribute - - -class SpiceBot_Channels_MainSection(StaticSection): - announcenew = ValidatedAttribute('announcenew', default=False) - joinall = ValidatedAttribute('joinall', default=False) - operadmin = ValidatedAttribute('operadmin', default=False) - chanignore = ListAttribute('chanignore') +from .Channels import SpiceBot_Channels_MainSection def configure(config): diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index 8063962..882f39c 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -2,18 +2,12 @@ from __future__ import unicode_literals, absolute_import, division, print_function """Configuration for SpiceBot""" -import sopel.module - from .Logs import logs -from .Events import events -from .Config import config as botconfig -from .configure import SpiceBot_Channels_MainSection +from .Channels import SpiceBot_Channels_MainSection def setup(bot): - logs.log('SpiceBot_Channels', "Starting setup procedure") - events.startup_add([events.BOT_CHANNELS]) + logs.log('SpiceBot_Channels', "Setting Up Configuration") bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) - botconfig.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) From bf3b6e078c40b147784c32afc5df46f743d589f4 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 15:37:22 -0400 Subject: [PATCH 144/328] docstring --- sopel_modules/SpiceBot/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index 882f39c..cc2ba83 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -1,6 +1,6 @@ # coding=utf8 from __future__ import unicode_literals, absolute_import, division, print_function -"""Configuration for SpiceBot""" +"""Setup for SpiceBot""" from .Logs import logs From 75d38194ca5eccedf2683e68b783fa96b2f061e7 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 15:37:59 -0400 Subject: [PATCH 145/328] dont need import --- sopel_modules/SpiceBot/Config.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index c145d87..954083e 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -2,7 +2,6 @@ from __future__ import unicode_literals, absolute_import, division, print_function """A way to read the bot's config without bot""" -import sopel.config from sopel.cli.run import build_parser, get_configuration import sys From 070b637253c07433d61a5c2de6214efc76fdcf03 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 15:59:17 -0400 Subject: [PATCH 146/328] cleanup --- sopel_modules/SpiceBot/Commands.py | 2 +- sopel_modules/SpiceBot/Config.py | 18 +----------------- sopel_modules/SpiceBot/Logs.py | 8 ++++---- sopel_modules/SpiceBot/Tools.py | 2 +- .../DatabaseCommand.py | 2 +- sopel_modules/SpiceBot_GifSearch/gifsearch.py | 4 ++-- sopel_modules/SpiceBot_Kick/__init__.py | 2 +- sopel_modules/SpiceBot_Logs/Queue.py | 2 +- sopel_modules/SpiceBot_Update/Update.py | 2 +- sopel_modules/SpiceBot_osd/__init__.py | 2 +- 10 files changed, 14 insertions(+), 30 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index b5cdc3d..d163c6f 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -132,7 +132,7 @@ class BotCommands(): logs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) # Extra directories - for directory in botconfig.config.core.extra: + for directory in botconfig.extra: filepathlisting.append(directory) return filepathlisting diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 954083e..450ba59 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals, absolute_import, division, print_functi from sopel.cli.run import build_parser, get_configuration import sys -import configparser class BotConfig(): @@ -22,29 +21,14 @@ class BotConfig(): opts = parser.parse_args(argv) self.config = get_configuration(opts) - # Filename - self.filename = self.config.filename - - # load as dict - config = configparser.ConfigParser() - config.read(self.filename) - for each_section in config.sections(): - if each_section.lower() not in self.dict.keys(): - self.dict[each_section.lower()] = dict() - for (each_key, each_val) in config.items(each_section): - if each_key.lower() not in self.dict[each_section.lower()].keys(): - self.dict[each_section.lower()][each_key.lower()] = each_val - def define_section(self, name, cls_, validate=True): return self.config.define_section(name, cls_, validate) def __getattr__(self, name): ''' will only get called for undefined attributes ''' """We will try to find a core value, or return None""" - if hasattr(self.config.core, name): + if hasattr(self.config, name): return eval("self.config.core." + name) - elif name.lower() in self.dict["core"].keys(): - return self.dict["core"][str(name).lower()] else: return None diff --git a/sopel_modules/SpiceBot/Logs.py b/sopel_modules/SpiceBot/Logs.py index 9e201d5..b1a0853 100644 --- a/sopel_modules/SpiceBot/Logs.py +++ b/sopel_modules/SpiceBot/Logs.py @@ -30,7 +30,7 @@ class BotLogs(): logtitle = "[" + logtype + "]" logmessage = logtitle + " " + logentry - if botconfig.config.core.logging_channel: + if botconfig.logging_channel: self.dict["queue"].append(logmessage) if stdio: @@ -57,7 +57,7 @@ class BotLogs(): for logtype in self.dict["list"].keys(): stdio_ignore.append("[" + logtype + "]") - logfile = os.path.os.path.join(botconfig.config.core.logdir, 'stdio.log') + logfile = os.path.os.path.join(botconfig.logdir, 'stdio.log') try: log_file_lines = [] @@ -105,12 +105,12 @@ class BotLogs(): def get_running_pid(self): try: - filename = "/run/sopel/sopel-" + str(botconfig.config.core.nick) + ".pid" + filename = "/run/sopel/sopel-" + str(botconfig.nick) + ".pid" with open(filename, 'r') as pid_file: pidnum = int(pid_file.read()) except Exception as e: pidnum = e - pidnum = str(os.popen("systemctl show " + str(botconfig.config.core.nick) + " --property=MainPID").read()).split("=")[-1] + pidnum = str(os.popen("systemctl show " + str(botconfig.nick) + " --property=MainPID").read()).split("=")[-1] return pidnum diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index e290cf2..8519ef7 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -42,7 +42,7 @@ github_dict = { def bot_privs(privtype): if privtype == 'owners': privtype = 'owner' - botpriveval = eval("botconfig.config.config.core." + privtype) + botpriveval = eval("botconfig." + privtype) if not isinstance(botpriveval, list): botpriveval = [botpriveval] return botpriveval diff --git a/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py b/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py index b7ea84d..5a2e8ff 100644 --- a/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py +++ b/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py @@ -10,4 +10,4 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.nickname_commands('database') def bot_command_gender(bot, trigger): - bot.osd("Database is " + SpiceBot.config.dict["core"]["db_type"]) + bot.osd("Database is " + SpiceBot.config.db_type) diff --git a/sopel_modules/SpiceBot_GifSearch/gifsearch.py b/sopel_modules/SpiceBot_GifSearch/gifsearch.py index b7eda44..8681674 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifsearch.py +++ b/sopel_modules/SpiceBot_GifSearch/gifsearch.py @@ -55,7 +55,7 @@ def setup(bot): dir_to_scan.append(api_dir) bot.config.define_section("SopelGifSearch", GifAPIMainSection, validate=False) - SpiceBot.config.config.define_section("SopelGifSearch", GifAPIMainSection, validate=False) + SpiceBot.config.define_section("SopelGifSearch", GifAPIMainSection, validate=False) if bot.config.SopelGifSearch.extra: dir_to_scan.append(bot.config.SopelGifSearch.extra) @@ -63,7 +63,7 @@ def setup(bot): for gif_api in valid_gif_api_dict.keys(): bot.config.define_section(gif_api, GifAPISection, validate=False) - SpiceBot.config.config.define_section(gif_api, GifAPISection, validate=False) + SpiceBot.config.define_section(gif_api, GifAPISection, validate=False) apikey = eval("bot.config." + gif_api + ".apikey") if apikey: valid_gif_api_dict[gif_api]["apikey"] = apikey diff --git a/sopel_modules/SpiceBot_Kick/__init__.py b/sopel_modules/SpiceBot_Kick/__init__.py index b628b5c..54fe4f8 100644 --- a/sopel_modules/SpiceBot_Kick/__init__.py +++ b/sopel_modules/SpiceBot_Kick/__init__.py @@ -42,7 +42,7 @@ def setup(bot): # verify config settings for server SpiceBot.logs.log('SpiceBot_Kick', "Checking for config settings") bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) - SpiceBot.config.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) + SpiceBot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) @module.event('005') diff --git a/sopel_modules/SpiceBot_Logs/Queue.py b/sopel_modules/SpiceBot_Logs/Queue.py index 274bdeb..8daedbb 100644 --- a/sopel_modules/SpiceBot_Logs/Queue.py +++ b/sopel_modules/SpiceBot_Logs/Queue.py @@ -18,7 +18,7 @@ def setup(bot): @sopel.module.rule('.*') def join_log_channel(bot, trigger): - if SpiceBot.config.config.core.logging_channel: + if SpiceBot.config.logging_channel: channel = bot.config.core.logging_channel if channel not in bot.channels.keys(): bot.write(('JOIN', bot.nick, channel)) diff --git a/sopel_modules/SpiceBot_Update/Update.py b/sopel_modules/SpiceBot_Update/Update.py index 43450d3..cd8424d 100644 --- a/sopel_modules/SpiceBot_Update/Update.py +++ b/sopel_modules/SpiceBot_Update/Update.py @@ -25,7 +25,7 @@ def configure(config): def setup(bot): SpiceBot.logs.log('SpiceBot_Update', "Initial Setup processing") bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) - SpiceBot.config.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) + SpiceBot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) @SpiceBot.prerun.prerun('nickname') diff --git a/sopel_modules/SpiceBot_osd/__init__.py b/sopel_modules/SpiceBot_osd/__init__.py index 96b857a..b8529b9 100644 --- a/sopel_modules/SpiceBot_osd/__init__.py +++ b/sopel_modules/SpiceBot_osd/__init__.py @@ -50,7 +50,7 @@ def setup(bot): # verify config settings for server SpiceBot.logs.log('SpiceBot_OSD', "Checking for config settings") bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) - SpiceBot.config.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) + SpiceBot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) @module.event('005') From 093f2cc8dbc322851a6ac70952d3789aa4f94ea2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 16:11:54 -0400 Subject: [PATCH 147/328] fix --- sopel_modules/SpiceBot/Config.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 450ba59..954083e 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -5,6 +5,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi from sopel.cli.run import build_parser, get_configuration import sys +import configparser class BotConfig(): @@ -21,14 +22,29 @@ class BotConfig(): opts = parser.parse_args(argv) self.config = get_configuration(opts) + # Filename + self.filename = self.config.filename + + # load as dict + config = configparser.ConfigParser() + config.read(self.filename) + for each_section in config.sections(): + if each_section.lower() not in self.dict.keys(): + self.dict[each_section.lower()] = dict() + for (each_key, each_val) in config.items(each_section): + if each_key.lower() not in self.dict[each_section.lower()].keys(): + self.dict[each_section.lower()][each_key.lower()] = each_val + def define_section(self, name, cls_, validate=True): return self.config.define_section(name, cls_, validate) def __getattr__(self, name): ''' will only get called for undefined attributes ''' """We will try to find a core value, or return None""" - if hasattr(self.config, name): + if hasattr(self.config.core, name): return eval("self.config.core." + name) + elif name.lower() in self.dict["core"].keys(): + return self.dict["core"][str(name).lower()] else: return None From 3ee4450b697f4494ccb8e2959fabce788effda40 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 16:20:21 -0400 Subject: [PATCH 148/328] testing --- sopel_modules/SpiceBot/Config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 954083e..1a40f54 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals, absolute_import, division, print_function """A way to read the bot's config without bot""" +from sopel.tools import stderr from sopel.cli.run import build_parser, get_configuration import sys @@ -39,6 +40,7 @@ class BotConfig(): return self.config.define_section(name, cls_, validate) def __getattr__(self, name): + stderr(str(name)) ''' will only get called for undefined attributes ''' """We will try to find a core value, or return None""" if hasattr(self.config.core, name): From 56d502098e4f53f0e85eb367aecb33b36689f34b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 22:43:10 -0400 Subject: [PATCH 149/328] test --- sopel_modules/SpiceBot/Config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 1a40f54..09b0bf1 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -40,7 +40,6 @@ class BotConfig(): return self.config.define_section(name, cls_, validate) def __getattr__(self, name): - stderr(str(name)) ''' will only get called for undefined attributes ''' """We will try to find a core value, or return None""" if hasattr(self.config.core, name): @@ -48,6 +47,7 @@ class BotConfig(): elif name.lower() in self.dict["core"].keys(): return self.dict["core"][str(name).lower()] else: + stderr(str(name)) return None From fa30a91a114c047c7a13ce7af15f3dfc1c702da7 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 22:48:43 -0400 Subject: [PATCH 150/328] RETURN --- sopel_modules/SpiceBot/Config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 09b0bf1..9cd866c 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -46,6 +46,8 @@ class BotConfig(): return eval("self.config.core." + name) elif name.lower() in self.dict["core"].keys(): return self.dict["core"][str(name).lower()] + elif hasattr(self.config, name): + return eval("self.config." + name) else: stderr(str(name)) return None From 3177ad80382c445bab3d7614def3981de49ea1c1 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 22:55:31 -0400 Subject: [PATCH 151/328] remove dbug --- sopel_modules/SpiceBot/Config.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 9cd866c..79bba67 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -49,7 +49,6 @@ class BotConfig(): elif hasattr(self.config, name): return eval("self.config." + name) else: - stderr(str(name)) return None From 7657feb0e555611a5ad9b3b25f1c7a3f819ae644 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 22:55:59 -0400 Subject: [PATCH 152/328] remove import --- sopel_modules/SpiceBot/Config.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 79bba67..ec388ff 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -2,7 +2,6 @@ from __future__ import unicode_literals, absolute_import, division, print_function """A way to read the bot's config without bot""" -from sopel.tools import stderr from sopel.cli.run import build_parser, get_configuration import sys From fc84cb487c6278a2f920ac99ba45f4dcf422bd69 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 22:57:47 -0400 Subject: [PATCH 153/328] tidy up --- sopel_modules/SpiceBot/Commands.py | 2 +- sopel_modules/SpiceBot/Tools.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index d163c6f..3bc8fdd 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -117,7 +117,7 @@ class BotCommands(): filepathlisting.append(modules_dir) # Home Directory - home_modules_dir = os.path.join(botconfig.config.homedir, 'modules') + home_modules_dir = os.path.join(botconfig.homedir, 'modules') if os.path.isdir(home_modules_dir): filepathlisting.append(home_modules_dir) diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index 8519ef7..1a9f94a 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -284,13 +284,13 @@ def spicebot_update(deps=False): logs.log('SpiceBot_Update', "Cloning to " + clonepath, True) - clone_repository(str(botconfig.config.config.SpiceBot_Update.gitrepo + ".git"), clonepath, checkout_branch=botconfig.config.config.SpiceBot_Update.gitbranch) + clone_repository(str(botconfig.SpiceBot_Update.gitrepo + ".git"), clonepath, checkout_branch=botconfig.SpiceBot_Update.gitbranch) pipcommand = "sudo pip3 install --upgrade" if not deps: pipcommand += " --no-deps" pipcommand += " --force-reinstall" - # pipcommand += " git+" + str(botconfig.config.config.SpiceBot_Update.gitrepo) + "@" + str(botconfig.config.config.SpiceBot_Update.gitbranch) + # pipcommand += " git+" + str(botconfig.SpiceBot_Update.gitrepo) + "@" + str(botconfig.SpiceBot_Update.gitbranch) pipcommand += " /tmp/SpiceBot/" logs.log('SpiceBot_Update', "Running `" + pipcommand + "`", True) From 7fe614587affea12b4f0ecd5cf8c2c74d0dfc7f8 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 30 May 2019 22:59:14 -0400 Subject: [PATCH 154/328] remove dummy pep ignore --- sopel_modules/SpiceBot/Database.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 394c969..653624c 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -74,9 +74,6 @@ class PluginValues(BASE): class SpiceDB(object): - def dummyfunc_pep(self): - return NickIDs - # NICK FUNCTIONS def set_nick_value(self, nick, key, value, category='default'): From 52381e0bcddd6802a7bdea4e6f8cb606dbc233c4 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 08:07:05 -0400 Subject: [PATCH 155/328] setup config for log precision --- sopel_modules/SpiceBot/Config.py | 11 +++++++++-- sopel_modules/SpiceBot/Logs.py | 4 +--- sopel_modules/SpiceBot/setup.py | 13 +++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index ec388ff..e097d53 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -5,12 +5,14 @@ from __future__ import unicode_literals, absolute_import, division, print_functi from sopel.cli.run import build_parser, get_configuration import sys +import os import configparser class BotConfig(): def __init__(self): + self.dict = {} # Load config @@ -22,8 +24,13 @@ class BotConfig(): opts = parser.parse_args(argv) self.config = get_configuration(opts) - # Filename - self.filename = self.config.filename + self.config.basename = os.path.basename(self.config.filename).rsplit('.', 1)[0] + self.config.core.logs_stdio = os.path.join(self.config.core.logdir, 'stdio.log') + # self.config.core.logs_stdio = os.path.os.path.join(self.config.core.logdir, self.config.basename + '.stdio.log') + self.config.core.logs_exceptions = os.path.join(self.config.core.logdir, 'exceptions.log') + # self.config.core.logs_exceptions = os.path.os.path.join(self.config.core.logdir, self.config.basename + '.exceptions.log') + self.config.core.logs_raw = os.path.join(self.config.core.logdir, 'raw.log') + # self.config.core.logs_raw = os.path.os.path.join(self.config.core.logdir, self.config.basename + '.raw.log') # load as dict config = configparser.ConfigParser() diff --git a/sopel_modules/SpiceBot/Logs.py b/sopel_modules/SpiceBot/Logs.py index b1a0853..ab7a4d3 100644 --- a/sopel_modules/SpiceBot/Logs.py +++ b/sopel_modules/SpiceBot/Logs.py @@ -57,11 +57,9 @@ class BotLogs(): for logtype in self.dict["list"].keys(): stdio_ignore.append("[" + logtype + "]") - logfile = os.path.os.path.join(botconfig.logdir, 'stdio.log') - try: log_file_lines = [] - log_file = open(logfile, 'r') + log_file = open(botconfig.logs_stdio, 'r') lines = log_file.readlines() for line in lines: log_file_lines.append(line) diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index cc2ba83..0ab7baa 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -2,6 +2,8 @@ from __future__ import unicode_literals, absolute_import, division, print_function """Setup for SpiceBot""" +import os + from .Logs import logs from .Channels import SpiceBot_Channels_MainSection @@ -9,5 +11,16 @@ from .Channels import SpiceBot_Channels_MainSection def setup(bot): + logs.log('SpiceBot_Config', "Setting Up Configuration") + bot.config.core.basename = os.path.basename(bot.config.filename).rsplit('.', 1)[0] + bot.config.core.logs_stdio = os.path.join(bot.config.core.logdir, 'stdio.log') + # bot.config.core.logs_stdio = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.stdio.log') + bot.config.core.logs_exceptions = os.path.join(bot.config.core.logdir, 'exceptions.log') + # bot.config.core.logs_exceptions = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.exceptions.log') + bot.config.core.logs_raw = os.path.join(bot.config.core.logdir, 'raw.log') + # bot.config.core.logs_raw = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.raw.log') + + # logs.log('SpiceBot_Logs', "Setting Up Configuration") + logs.log('SpiceBot_Channels', "Setting Up Configuration") bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) From 2f108d1174f787f4c496840785e96a7cc96355ec Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 08:29:29 -0400 Subject: [PATCH 156/328] naming --- sopel_modules/SpiceBot/Database.py | 164 ++++++++++++++--------------- 1 file changed, 82 insertions(+), 82 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 653624c..5832abc 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -45,7 +45,7 @@ class NickValues(BASE): """ __tablename__ = 'spice_nick_values' nick_id = Column(Integer, ForeignKey('nick_ids.nick_id'), primary_key=True) - category = Column(String(255), primary_key=True) + namespace = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -56,7 +56,7 @@ class ChannelValues(BASE): """ __tablename__ = 'spice_channel_values' channel = Column(String(255), primary_key=True) - category = Column(String(255), primary_key=True) + namespace = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -67,7 +67,7 @@ class PluginValues(BASE): """ __tablename__ = 'spice_plugin_values' plugin = Column(String(255), primary_key=True) - category = Column(String(255), primary_key=True) + namespace = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) value = Column(String(255)) @@ -76,7 +76,7 @@ class SpiceDB(object): # NICK FUNCTIONS - def set_nick_value(self, nick, key, value, category='default'): + def set_nick_value(self, nick, key, value, namespace='default'): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) value = json.dumps(value, ensure_ascii=False) @@ -85,7 +85,7 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.category == category)\ + .filter(NickValues.namespace == namespace)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, update @@ -94,7 +94,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_nickvalue = NickValues(nick_id=nick_id, category=category, key=key, value=value) + new_nickvalue = NickValues(nick_id=nick_id, namespace=namespace, key=key, value=value) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -103,7 +103,7 @@ class SpiceDB(object): finally: session.close() - def get_nick_value(self, nick, key, category='default'): + def get_nick_value(self, nick, key, namespace='default'): """Retrieves the value for a given key associated with a nick.""" nick = Identifier(nick) session = self.ssession() @@ -111,7 +111,7 @@ class SpiceDB(object): result = session.query(NickValues) \ .filter(Nicknames.nick_id == NickValues.nick_id) \ .filter(Nicknames.slug == nick.lower()) \ - .filter(NickValues.category == category)\ + .filter(NickValues.namespace == namespace)\ .filter(NickValues.key == key) \ .one_or_none() if result is not None: @@ -123,7 +123,7 @@ class SpiceDB(object): finally: session.close() - def delete_nick_value(self, nick, key, category='default'): + def delete_nick_value(self, nick, key, namespace='default'): """Deletes the value for a given key to be associated with the nick.""" nick = Identifier(nick) nick_id = self.get_nick_id(nick) @@ -131,7 +131,7 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.category == category)\ + .filter(NickValues.namespace == namespace)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, delete @@ -144,7 +144,7 @@ class SpiceDB(object): finally: session.close() - def adjust_nick_value(self, nick, key, value, category='default'): + def adjust_nick_value(self, nick, key, value, namespace='default'): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) value = json.dumps(value, ensure_ascii=False) @@ -153,7 +153,7 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.category == category)\ + .filter(NickValues.namespace == namespace)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, update @@ -162,7 +162,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_nickvalue = NickValues(nick_id=nick_id, category=category, key=key, value=float(value)) + new_nickvalue = NickValues(nick_id=nick_id, namespace=namespace, key=key, value=float(value)) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -171,7 +171,7 @@ class SpiceDB(object): finally: session.close() - def adjust_nick_list(self, nick, key, entries, adjustmentdirection, category='default'): + def adjust_nick_list(self, nick, key, entries, adjustmentdirection, namespace='default'): """Sets the value for a given key to be associated with the nick.""" nick = Identifier(nick) if not isinstance(entries, list): @@ -182,7 +182,7 @@ class SpiceDB(object): try: result = session.query(NickValues) \ .filter(NickValues.nick_id == nick_id) \ - .filter(NickValues.category == category)\ + .filter(NickValues.namespace == namespace)\ .filter(NickValues.key == key) \ .one_or_none() # NickValue exists, update @@ -207,7 +207,7 @@ class SpiceDB(object): for entry in entries: while entry in values: values.remove(entry) - new_nickvalue = NickValues(nick_id=nick_id, category=category, key=key, value=values) + new_nickvalue = NickValues(nick_id=nick_id, namespace=namespace, key=key, value=values) session.add(new_nickvalue) session.commit() except SQLAlchemyError: @@ -218,7 +218,7 @@ class SpiceDB(object): # CHANNEL FUNCTIONS - def set_channel_value(self, channel, key, value, category='default'): + def set_channel_value(self, channel, key, value, namespace='default'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() value = json.dumps(value, ensure_ascii=False) @@ -226,7 +226,7 @@ class SpiceDB(object): try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.category == category)\ + .filter(ChannelValues.namespace == namespace)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -235,7 +235,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_channelvalue = ChannelValues(channel=channel, category=category, key=key, value=value) + new_channelvalue = ChannelValues(channel=channel, namespace=namespace, key=key, value=value) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -244,14 +244,14 @@ class SpiceDB(object): finally: session.close() - def get_channel_value(self, channel, key, category='default'): + def get_channel_value(self, channel, key, namespace='default'): """Retrieves the value for a given key associated with a channel.""" channel = Identifier(channel).lower() session = self.ssession() try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.category == category)\ + .filter(ChannelValues.namespace == namespace)\ .filter(ChannelValues.key == key) \ .one_or_none() if result is not None: @@ -263,14 +263,14 @@ class SpiceDB(object): finally: session.close() - def delete_channel_value(self, channel, key, category='default'): + def delete_channel_value(self, channel, key, namespace='default'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() session = self.ssession() try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.category == category)\ + .filter(ChannelValues.namespace == namespace)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, delete @@ -283,7 +283,7 @@ class SpiceDB(object): finally: session.close() - def adjust_channel_value(self, channel, key, value, category='default'): + def adjust_channel_value(self, channel, key, value, namespace='default'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() value = json.dumps(value, ensure_ascii=False) @@ -291,7 +291,7 @@ class SpiceDB(object): try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.category == category)\ + .filter(ChannelValues.namespace == namespace)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -300,7 +300,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_channelvalue = ChannelValues(channel=channel, category=category, key=key, value=float(value)) + new_channelvalue = ChannelValues(channel=channel, namespace=namespace, key=key, value=float(value)) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -309,7 +309,7 @@ class SpiceDB(object): finally: session.close() - def adjust_channel_list(self, channel, key, entries, adjustmentdirection, category='default'): + def adjust_channel_list(self, channel, key, entries, adjustmentdirection, namespace='default'): """Sets the value for a given key to be associated with the channel.""" channel = Identifier(channel).lower() if not isinstance(entries, list): @@ -319,7 +319,7 @@ class SpiceDB(object): try: result = session.query(ChannelValues) \ .filter(ChannelValues.channel == channel)\ - .filter(ChannelValues.category == category)\ + .filter(ChannelValues.namespace == namespace)\ .filter(ChannelValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -344,7 +344,7 @@ class SpiceDB(object): for entry in entries: while entry in values: values.remove(entry) - new_channelvalue = ChannelValues(channel=channel, category=category, key=key, value=values) + new_channelvalue = ChannelValues(channel=channel, namespace=namespace, key=key, value=values) session.add(new_channelvalue) session.commit() except SQLAlchemyError: @@ -355,7 +355,7 @@ class SpiceDB(object): # PLUGIN FUNCTIONS - def set_plugin_value(self, plugin, key, value, category='default'): + def set_plugin_value(self, plugin, key, value, namespace='default'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -363,7 +363,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ + .filter(PluginValues.namespace == namespace)\ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, update @@ -372,7 +372,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=value) + new_pluginvalue = PluginValues(plugin=plugin, namespace=namespace, key=key, value=value) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -381,14 +381,14 @@ class SpiceDB(object): finally: session.close() - def get_plugin_value(self, plugin, key, category='default'): + def get_plugin_value(self, plugin, key, namespace='default'): """Retrieves the value for a given key associated with a plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ + .filter(PluginValues.namespace == namespace)\ .filter(PluginValues.key == key) \ .one_or_none() if result is not None: @@ -400,14 +400,14 @@ class SpiceDB(object): finally: session.close() - def delete_plugin_value(self, plugin, key, category='default'): + def delete_plugin_value(self, plugin, key, namespace='default'): """Deletes the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() session = self.ssession() try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ + .filter(PluginValues.namespace == namespace)\ .filter(PluginValues.key == key) \ .one_or_none() # PluginValues exists, delete @@ -420,7 +420,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_value(self, plugin, key, value, category='default'): + def adjust_plugin_value(self, plugin, key, value, namespace='default'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() value = json.dumps(value, ensure_ascii=False) @@ -428,7 +428,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ + .filter(PluginValues.namespace == namespace)\ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -437,7 +437,7 @@ class SpiceDB(object): session.commit() # DNE - Insert else: - new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=float(value)) + new_pluginvalue = PluginValues(plugin=plugin, namespace=namespace, key=key, value=float(value)) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -446,7 +446,7 @@ class SpiceDB(object): finally: session.close() - def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection, category='default'): + def adjust_plugin_list(self, plugin, key, entries, adjustmentdirection, namespace='default'): """Sets the value for a given key to be associated with the plugin.""" plugin = Identifier(plugin).lower() if not isinstance(entries, list): @@ -456,7 +456,7 @@ class SpiceDB(object): try: result = session.query(PluginValues) \ .filter(PluginValues.plugin == plugin)\ - .filter(PluginValues.category == category)\ + .filter(PluginValues.namespace == namespace)\ .filter(PluginValues.key == key) \ .one_or_none() # ChannelValue exists, update @@ -481,7 +481,7 @@ class SpiceDB(object): for entry in entries: while entry in values: values.remove(entry) - new_pluginvalue = PluginValues(plugin=plugin, category=category, key=key, value=values) + new_pluginvalue = PluginValues(plugin=plugin, namespace=namespace, key=key, value=values) session.add(new_pluginvalue) session.commit() except SQLAlchemyError: @@ -522,71 +522,71 @@ class BotDatabase(): """Nick""" - def get_nick_value(self, nick, key, category='default'): - return self.db.get_nick_value(nick, key, category) + def get_nick_value(self, nick, key, namespace='default'): + return self.db.get_nick_value(nick, key, namespace) - def set_nick_value(self, nick, key, value, category='default'): - return self.db.set_nick_value(nick, key, value, category) + def set_nick_value(self, nick, key, value, namespace='default'): + return self.db.set_nick_value(nick, key, value, namespace) - def delete_nick_value(self, nick, key, category='default'): - return self.db.delete_nick_value(nick, key, category) + def delete_nick_value(self, nick, key, namespace='default'): + return self.db.delete_nick_value(nick, key, namespace) - def adjust_nick_value(self, nick, key, value, category='default'): - return self.db.adjust_nick_value(nick, key, value, category) + def adjust_nick_value(self, nick, key, value, namespace='default'): + return self.db.adjust_nick_value(nick, key, value, namespace) - def adjust_nick_list(self, nick, key, entries, adjustmentdirection, category='default'): - return self.db.adjust_nick_list(nick, key, entries, adjustmentdirection, category) + def adjust_nick_list(self, nick, key, entries, adjustmentdirection, namespace='default'): + return self.db.adjust_nick_list(nick, key, entries, adjustmentdirection, namespace) """Bot""" - def get_bot_value(self, key, category='default'): - return self.db.get_nick_value(botconfig.nick, key, category) + def get_bot_value(self, key, namespace='default'): + return self.db.get_nick_value(botconfig.nick, key, namespace) - def set_bot_value(self, key, value, category='default'): - return self.db.set_nick_value(botconfig.nick, key, value, category) + def set_bot_value(self, key, value, namespace='default'): + return self.db.set_nick_value(botconfig.nick, key, value, namespace) - def delete_bot_value(self, key, category='default'): - return self.db.delete_nick_value(botconfig.nick, key, category) + def delete_bot_value(self, key, namespace='default'): + return self.db.delete_nick_value(botconfig.nick, key, namespace) - def adjust_bot_value(self, key, value, category='default'): - return self.db.adjust_nick_value(botconfig.nick, key, value, category) + def adjust_bot_value(self, key, value, namespace='default'): + return self.db.adjust_nick_value(botconfig.nick, key, value, namespace) - def adjust_bot_list(self, key, entries, adjustmentdirection, category='default'): - return self.db.adjust_nick_list(botconfig.nick, key, entries, adjustmentdirection, category) + def adjust_bot_list(self, key, entries, adjustmentdirection, namespace='default'): + return self.db.adjust_nick_list(botconfig.nick, key, entries, adjustmentdirection, namespace) """Channels""" - def get_channel_value(self, channel, key, category='default'): - return self.db.get_channel_value(channel, key, category) + def get_channel_value(self, channel, key, namespace='default'): + return self.db.get_channel_value(channel, key, namespace) - def set_channel_value(self, channel, key, value, category='default'): - return self.db.set_channel_value(channel, key, value, category) + def set_channel_value(self, channel, key, value, namespace='default'): + return self.db.set_channel_value(channel, key, value, namespace) - def delete_channel_value(self, channel, key, category='default'): - return self.db.delete_channel_value(channel, key, category) + def delete_channel_value(self, channel, key, namespace='default'): + return self.db.delete_channel_value(channel, key, namespace) - def adjust_channel_value(self, channel, key, value, category='default'): - return self.db.adjust_channel_value(channel, key, value, category) + def adjust_channel_value(self, channel, key, value, namespace='default'): + return self.db.adjust_channel_value(channel, key, value, namespace) - def adjust_channel_list(self, nick, key, entries, adjustmentdirection, category='default'): - return self.db.adjust_channel_list(nick, key, entries, adjustmentdirection, category) + def adjust_channel_list(self, nick, key, entries, adjustmentdirection, namespace='default'): + return self.db.adjust_channel_list(nick, key, entries, adjustmentdirection, namespace) """Plugins""" - def get_plugin_value(self, plugin, key, category='default'): - return self.db.get_plugin_value(plugin, key, category) + def get_plugin_value(self, plugin, key, namespace='default'): + return self.db.get_plugin_value(plugin, key, namespace) - def set_plugin_value(self, plugin, key, value, category='default'): - return self.db.set_plugin_value(plugin, key, value, category) + def set_plugin_value(self, plugin, key, value, namespace='default'): + return self.db.set_plugin_value(plugin, key, value, namespace) - def delete_plugin_value(self, plugin, key, category='default'): - return self.db.delete_plugin_value(plugin, key, category) + def delete_plugin_value(self, plugin, key, namespace='default'): + return self.db.delete_plugin_value(plugin, key, namespace) - def adjust_plugin_value(self, plugin, key, value, category='default'): - return self.db.adjust_plugin_value(plugin, key, value, category) + def adjust_plugin_value(self, plugin, key, value, namespace='default'): + return self.db.adjust_plugin_value(plugin, key, value, namespace) - def adjust_plugin_list(self, nick, key, entries, adjustmentdirection, category='default'): - return self.db.adjust_plugin_list(nick, key, entries, adjustmentdirection, category) + def adjust_plugin_list(self, nick, key, entries, adjustmentdirection, namespace='default'): + return self.db.adjust_plugin_list(nick, key, entries, adjustmentdirection, namespace) db = BotDatabase() From b6f3b363e56899cebcc0be534e5fd13c39fd4125 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 08:40:14 -0400 Subject: [PATCH 157/328] dict --- sopel_modules/SpiceBot/Config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index e097d53..21e1f61 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -50,8 +50,8 @@ class BotConfig(): """We will try to find a core value, or return None""" if hasattr(self.config.core, name): return eval("self.config.core." + name) - elif name.lower() in self.dict["core"].keys(): - return self.dict["core"][str(name).lower()] + # elif name.lower() in self.dict["core"].keys(): + # return self.dict["core"][str(name).lower()] elif hasattr(self.config, name): return eval("self.config." + name) else: From 26f39f8f11f1165efeff5ee1e22bc7162b0acc76 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 08:41:32 -0400 Subject: [PATCH 158/328] fix filename issue --- sopel_modules/SpiceBot/Config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 21e1f61..dced9d4 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -34,7 +34,7 @@ class BotConfig(): # load as dict config = configparser.ConfigParser() - config.read(self.filename) + config.read(self.config.filename) for each_section in config.sections(): if each_section.lower() not in self.dict.keys(): self.dict[each_section.lower()] = dict() @@ -50,8 +50,8 @@ class BotConfig(): """We will try to find a core value, or return None""" if hasattr(self.config.core, name): return eval("self.config.core." + name) - # elif name.lower() in self.dict["core"].keys(): - # return self.dict["core"][str(name).lower()] + elif name.lower() in self.dict["core"].keys(): + return self.dict["core"][str(name).lower()] elif hasattr(self.config, name): return eval("self.config." + name) else: From a943fed89fab3d89c13f9e2ed54df57cea6522ab Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 11:19:24 -0400 Subject: [PATCH 159/328] Combine channel Parsing --- sopel_modules/SpiceBot/Channels.py | 88 +++++++++++++++++ .../Channels_Parsing.py | 97 ------------------- .../SpiceBot_Channels_Parsing/__init__.py | 6 -- 3 files changed, 88 insertions(+), 103 deletions(-) delete mode 100644 sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py delete mode 100644 sopel_modules/SpiceBot_Channels_Parsing/__init__.py diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index 1e21b84..c818d79 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -8,6 +8,9 @@ from sopel.config.types import StaticSection, ValidatedAttribute, ListAttribute import re import threading +import time + +import spicemanip from .Config import config as botconfig from .Events import events @@ -100,3 +103,88 @@ class BotChannels(): channels = BotChannels() + + +@sopel.module.event(events.RPL_WELCOME) +@sopel.module.rule('.*') +def unkickable_bot(bot, trigger): + if bot.config.SpiceBot_Channels.operadmin: + bot.write(('SAMODE', bot.nick, '+q')) + + +@sopel.module.event(events.RPL_WELCOME) +@sopel.module.rule('.*') +def request_channels_list_initial(bot, trigger): + + channels.bot_part_empty(bot) + + logs.log('SpiceBot_Channels', "Sending Request for all server channels") + channels.channel_list_request(bot) + + starttime = time.time() + + # wait 60 seconds for initial population of information + while not channels.dict['InitialProcess']: + if time.time() - starttime >= 60: + logs.log('SpiceBot_Channels', "Initial Channel list populating Timed Out") + channels.dict['InitialProcess'] = True + else: + pass + + foundchannelcount = len(channels.dict['list'].keys()) + logs.log('SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.") + + channels.join_all_channels(bot) + channels.chanadmin_all_channels(bot) + + if "*" in channels.dict['list'].keys(): + del channels.dict['list']["*"] + + channels.bot_part_empty(bot) + events.trigger(bot, events.BOT_CHANNELS, "SpiceBot_Channels") + + +@sopel.module.event('321') +@sopel.module.rule('.*') +def watch_chanlist_start(bot, trigger): + channels.channel_list_recieve_start() + + +@sopel.module.event('322') +@sopel.module.rule('.*') +def watch_chanlist_populate(bot, trigger): + channels.channel_list_recieve_input(trigger) + + +@sopel.module.event('323') +@sopel.module.rule('.*') +def watch_chanlist_complete(bot, trigger): + channels.channel_list_recieve_finish() + + +@sopel.module.event(events.BOT_CHANNELS) +@sopel.module.rule('.*') +def trigger_channel_list_recurring(bot, trigger): + while True: + time.sleep(1800) + channels.bot_part_empty(bot) + + oldlist = list(channels.dict['list'].keys()) + channels.channel_list_request(bot) + + while channels.channel_lock: + pass + + newlist = [item.lower() for item in oldlist if item.lower() not in list(channels.dict['list'].keys())] + if "*" in newlist: + newlist.remove("*") + if len(newlist) and bot.config.SpiceBot_Channels.announcenew: + bot.osd(["The Following channel(s) are new:", spicemanip.main(newlist, 'andlist')], bot.channels.keys()) + + channels.join_all_channels(bot) + + channels.chanadmin_all_channels(bot) + + if "*" in channels.dict['list'].keys(): + del channels.dict['list']["*"] + channels.bot_part_empty(bot) diff --git a/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py b/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py deleted file mode 100644 index b33d9f0..0000000 --- a/sopel_modules/SpiceBot_Channels_Parsing/Channels_Parsing.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# coding=utf-8 -from __future__ import unicode_literals, absolute_import, print_function, division - -# sopel imports -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - -import spicemanip - -import time - - -@sopel.module.event(SpiceBot.events.RPL_WELCOME) -@sopel.module.rule('.*') -def unkickable_bot(bot, trigger): - if bot.config.SpiceBot_Channels.operadmin: - bot.write(('SAMODE', bot.nick, '+q')) - - -@sopel.module.event(SpiceBot.events.RPL_WELCOME) -@sopel.module.rule('.*') -def request_channels_list_initial(bot, trigger): - - SpiceBot.channels.bot_part_empty(bot) - - SpiceBot.logs.log('SpiceBot_Channels', "Sending Request for all server channels") - SpiceBot.channels.channel_list_request(bot) - - starttime = time.time() - - # wait 60 seconds for initial population of information - while not SpiceBot.channels.dict['InitialProcess']: - if time.time() - starttime >= 60: - SpiceBot.logs.log('SpiceBot_Channels', "Initial Channel list populating Timed Out") - SpiceBot.channels.dict['InitialProcess'] = True - else: - pass - - foundchannelcount = len(SpiceBot.channels.dict['list'].keys()) - SpiceBot.logs.log('SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.") - - SpiceBot.channels.join_all_channels(bot) - SpiceBot.channels.chanadmin_all_channels(bot) - - if "*" in SpiceBot.channels.dict['list'].keys(): - del SpiceBot.channels.dict['list']["*"] - - SpiceBot.channels.bot_part_empty(bot) - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_CHANNELS, "SpiceBot_Channels") - - -@sopel.module.event('321') -@sopel.module.rule('.*') -def watch_chanlist_start(bot, trigger): - SpiceBot.channels.channel_list_recieve_start() - - -@sopel.module.event('322') -@sopel.module.rule('.*') -def watch_chanlist_populate(bot, trigger): - SpiceBot.channels.channel_list_recieve_input(trigger) - - -@sopel.module.event('323') -@sopel.module.rule('.*') -def watch_chanlist_complete(bot, trigger): - SpiceBot.channels.channel_list_recieve_finish() - - -@sopel.module.event(SpiceBot.events.BOT_CHANNELS) -@sopel.module.rule('.*') -def trigger_channel_list_recurring(bot, trigger): - while True: - time.sleep(1800) - SpiceBot.channels.bot_part_empty(bot) - - oldlist = list(SpiceBot.channels.dict['list'].keys()) - SpiceBot.channels.channel_list_request(bot) - - while SpiceBot.channels.channel_lock: - pass - - newlist = [item.lower() for item in oldlist if item.lower() not in list(SpiceBot.channels.dict['list'].keys())] - if "*" in newlist: - newlist.remove("*") - if len(newlist) and bot.config.SpiceBot_Channels.announcenew: - bot.osd(["The Following channel(s) are new:", spicemanip.main(newlist, 'andlist')], bot.channels.keys()) - - SpiceBot.channels.join_all_channels(bot) - - SpiceBot.channels.chanadmin_all_channels(bot) - - if "*" in SpiceBot.channels.dict['list'].keys(): - del SpiceBot.channels.dict['list']["*"] - SpiceBot.channels.bot_part_empty(bot) diff --git a/sopel_modules/SpiceBot_Channels_Parsing/__init__.py b/sopel_modules/SpiceBot_Channels_Parsing/__init__.py deleted file mode 100644 index 0d5311d..0000000 --- a/sopel_modules/SpiceBot_Channels_Parsing/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# coding=utf-8 -"""Event Parsing from IRC -""" -from __future__ import unicode_literals, absolute_import, print_function, division - -from .Channels_Parsing import * From 209714d4aff61058ac4e95eb2e351614f7c3e468 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 11:29:04 -0400 Subject: [PATCH 160/328] channels command integration --- sopel_modules/SpiceBot/Channels.py | 109 ++++++++++++++++ .../Channels_Command.py | 116 ------------------ .../SpiceBot_Channels_Command/__init__.py | 6 - 3 files changed, 109 insertions(+), 122 deletions(-) delete mode 100644 sopel_modules/SpiceBot_Channels_Command/Channels_Command.py delete mode 100644 sopel_modules/SpiceBot_Channels_Command/__init__.py diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index c818d79..096caa4 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -15,6 +15,8 @@ import spicemanip from .Config import config as botconfig from .Events import events from .Logs import logs +from .Prerun import prerun +from .Tools import inlist, channel_privs class SpiceBot_Channels_MainSection(StaticSection): @@ -188,3 +190,110 @@ def trigger_channel_list_recurring(bot, trigger): if "*" in channels.dict['list'].keys(): del channels.dict['list']["*"] channels.bot_part_empty(bot) + + +@events.check_ready([events.BOT_LOADED]) +@prerun.prerun('nickname') +@sopel.module.nickname_commands('channels', 'channel') +def nickname_comand_channels(bot, trigger): + + if not len(trigger.sb['args']): + commandused = 'list' + else: + commandused = spicemanip.main(trigger.sb['args'], 1).lower() + + trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') + + if commandused == 'list': + chanlist = spicemanip.main(bot.channels.keys(), 'andlist') + bot.osd("You can find me in " + chanlist) + return + + elif commandused == 'total': + botcount = len(bot.channels.keys()) + servercount = len(channels.dict['list'].keys()) + bot.osd("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") + return + + elif commandused == 'random': + channel = spicemanip.main(channels.dict['list'], 'random') + topic = channels.dict['list'][channel]['topic'] + msg = ["Random channel for you: {}.".format(channels.dict['list'][channel]['name'])] + if topic and not topic.isspace(): + msg.append("The topic is: {}".format(topic)) + else: + msg.append("Its topic is empty.") + bot.osd(msg) + return + + elif commandused == 'update': + if not trigger.admin: + bot.osd("You do not have permission to update the channel listing.") + return + channels.bot_part_empty(bot) + channels.channel_list_request(bot) + bot.osd(["[SpiceBot_Channels]", "I am now updating the channel listing for this server."]) + while channels.channel_lock: + pass + channels.join_all_channels(bot) + foundchannelcount = len(channels.dict['list'].keys()) + bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.") + channels.bot_part_empty(bot) + return + + elif commandused == 'topic': + if not len(trigger.sb['args']): + bot.osd("Channel name input missing.") + return + channel = spicemanip.main(trigger.sb['args'], 1) + if not inlist(channel.lower(), channels.dict['list'].keys()): + bot.osd("Channel name {} not valid.".format(channel)) + return + topic = channels.dict['list'][channel.lower()]['topic'] + channel = channels.dict['list'][channel.lower()]['name'] + bot.osd("Topic for {}: {}".format(channel, topic)) + return + + if commandused.upper() in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']: + if not len(trigger.sb['args']): + if trigger.is_privmsg: + bot.osd("Channel name required.") + return + else: + channel = trigger.sender + else: + channel = spicemanip.main(trigger.sb['args'], 1) + if not inlist(channel.lower(), channels.dict['list'].keys()): + bot.osd("Channel name {} not valid.".format(channel)) + return + if not inlist(channel.lower(), bot.channels.keys()): + bot.osd("I need to be in {} to see nick privileges.".format(channel)) + return + + privlist = channel_privs(bot, channel, commandused.upper()) + dispmsg = [] + if not len(privlist): + dispmsg.append("There are no Channel " + commandused.upper() + "s for " + str(channel)) + else: + oplist = spicemanip.main(privlist, 'andlist') + dispmsg.append("Channel " + commandused.upper() + "s for " + str(channel) + " are: " + oplist) + bot.osd(dispmsg, trigger.nick, 'notice') + return + + # Users List + if commandused == 'users': + channel = spicemanip.main(trigger.sb['args'], 1) + if not inlist(channel.lower(), channels.dict['list'].keys()): + bot.osd("Channel name {} not valid.".format(channel)) + return + if not inlist(channel.lower(), bot.channels.keys()): + bot.osd("I need to be in {} to see user list.".format(channel)) + return + dispmsg = [] + if not len(bot.channels[channel].privileges.keys()): + dispmsg.append("There are no Channel users for " + str(channel)) + else: + userslist = spicemanip.main(bot.channels[channel].privileges.keys(), 'andlist') + dispmsg.append("Channel users for " + str(channel) + " are: " + userslist) + bot.osd(dispmsg, trigger.nick, 'notice') + return diff --git a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py b/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py deleted file mode 100644 index fdc70d7..0000000 --- a/sopel_modules/SpiceBot_Channels_Command/Channels_Command.py +++ /dev/null @@ -1,116 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import spicemanip - -import sopel_modules.SpiceBot as SpiceBot - - -@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) -@SpiceBot.prerun.prerun('nickname') -@sopel.module.nickname_commands('channels', 'channel') -def nickname_comand_channels(bot, trigger): - - if not len(trigger.sb['args']): - commandused = 'list' - else: - commandused = spicemanip.main(trigger.sb['args'], 1).lower() - - trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') - - if commandused == 'list': - chanlist = spicemanip.main(bot.channels.keys(), 'andlist') - bot.osd("You can find me in " + chanlist) - return - - elif commandused == 'total': - botcount = len(bot.channels.keys()) - servercount = len(SpiceBot.channels.dict['list'].keys()) - bot.osd("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") - return - - elif commandused == 'random': - channel = spicemanip.main(SpiceBot.channels.dict['list'], 'random') - topic = SpiceBot.channels.dict['list'][channel]['topic'] - msg = ["Random channel for you: {}.".format(SpiceBot.channels.dict['list'][channel]['name'])] - if topic and not topic.isspace(): - msg.append("The topic is: {}".format(topic)) - else: - msg.append("Its topic is empty.") - bot.osd(msg) - return - - elif commandused == 'update': - if not trigger.admin: - bot.osd("You do not have permission to update the channel listing.") - return - SpiceBot.channels.bot_part_empty(bot) - SpiceBot.channels.channel_list_request(bot) - bot.osd(["[SpiceBot_Channels]", "I am now updating the channel listing for this server."]) - while SpiceBot.channels.channel_lock: - pass - SpiceBot.channels.join_all_channels(bot) - foundchannelcount = len(SpiceBot.channels.dict['list'].keys()) - bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.") - SpiceBot.channels.bot_part_empty(bot) - return - - elif commandused == 'topic': - if not len(trigger.sb['args']): - bot.osd("Channel name input missing.") - return - 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 - topic = SpiceBot.channels.dict['list'][channel.lower()]['topic'] - channel = SpiceBot.channels.dict['list'][channel.lower()]['name'] - bot.osd("Topic for {}: {}".format(channel, topic)) - return - - if commandused.upper() in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']: - if not len(trigger.sb['args']): - if trigger.is_privmsg: - bot.osd("Channel name required.") - return - else: - channel = trigger.sender - else: - 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 - if not SpiceBot.inlist(channel.lower(), bot.channels.keys()): - bot.osd("I need to be in {} to see nick privileges.".format(channel)) - return - - privlist = SpiceBot.channel_privs(bot, channel, commandused.upper()) - dispmsg = [] - if not len(privlist): - dispmsg.append("There are no Channel " + commandused.upper() + "s for " + str(channel)) - else: - oplist = spicemanip.main(privlist, 'andlist') - dispmsg.append("Channel " + commandused.upper() + "s for " + str(channel) + " are: " + oplist) - bot.osd(dispmsg, trigger.nick, 'notice') - return - - # Users List - if commandused == 'users': - 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 - if not SpiceBot.inlist(channel.lower(), bot.channels.keys()): - bot.osd("I need to be in {} to see user list.".format(channel)) - return - dispmsg = [] - if not len(bot.channels[channel].privileges.keys()): - dispmsg.append("There are no Channel users for " + str(channel)) - else: - userslist = spicemanip.main(bot.channels[channel].privileges.keys(), 'andlist') - dispmsg.append("Channel users for " + str(channel) + " are: " + userslist) - bot.osd(dispmsg, trigger.nick, 'notice') - return diff --git a/sopel_modules/SpiceBot_Channels_Command/__init__.py b/sopel_modules/SpiceBot_Channels_Command/__init__.py deleted file mode 100644 index 643aeb7..0000000 --- a/sopel_modules/SpiceBot_Channels_Command/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# coding=utf-8 -"""Event Parsing from IRC -""" -from __future__ import unicode_literals, absolute_import, print_function, division - -from .Channels_Command import * From 93aae682d0f653109b800cb55a7c5dda615062ac Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 11:32:14 -0400 Subject: [PATCH 161/328] alias --- sopel_modules/SpiceBot_BotPrivs/BotPrivs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py index af409f4..d2f8916 100644 --- a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py +++ b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py @@ -16,7 +16,7 @@ def bot_command_owners(bot, trigger): @SpiceBot.prerun.prerun('nickname') -@sopel.module.nickname_commands('admins') +@sopel.module.nickname_commands('admins', 'admin') def bot_command_admins(bot, trigger): bot_command_process(bot, trigger) From d0768cf7dc2e0a547071febc24fdbf5dda6179d6 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 11:33:00 -0400 Subject: [PATCH 162/328] better --- sopel_modules/SpiceBot_BotPrivs/BotPrivs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py index d2f8916..396e839 100644 --- a/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py +++ b/sopel_modules/SpiceBot_BotPrivs/BotPrivs.py @@ -23,8 +23,8 @@ def bot_command_admins(bot, trigger): def bot_command_process(bot, trigger): - if trigger.sb['com'] == 'owner': - trigger.sb['com'] = 'owners' + if not trigger.sb['com'].endswith("s"): + trigger.sb['com'] = str(trigger.sb['com'] + "s") privlist = spicemanip.main(SpiceBot.bot_privs(trigger.sb['com']), 'andlist') bot.osd(str(bot.nick) + " " + trigger.sb['com'] + ": " + privlist) From 4bad867bafd9170dfe79891987de048be46f9cf0 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 11:34:17 -0400 Subject: [PATCH 163/328] database command --- sopel_modules/SpiceBot/Database.py | 5 +++++ .../SpiceBot_Database_Command/DatabaseCommand.py | 13 ------------- sopel_modules/SpiceBot_Database_Command/__init__.py | 6 ------ 3 files changed, 5 insertions(+), 19 deletions(-) delete mode 100644 sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py delete mode 100644 sopel_modules/SpiceBot_Database_Command/__init__.py diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 5832abc..daeda2f 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -590,3 +590,8 @@ class BotDatabase(): db = BotDatabase() + + +@sopel.module.nickname_commands('database') +def bot_command_gender(bot, trigger): + bot.osd("Database is " + botconfig.db_type) diff --git a/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py b/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py deleted file mode 100644 index 5a2e8ff..0000000 --- a/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -# coding=utf-8 -from __future__ import unicode_literals, absolute_import, print_function, division - -# sopel imports -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -@sopel.module.nickname_commands('database') -def bot_command_gender(bot, trigger): - bot.osd("Database is " + SpiceBot.config.db_type) diff --git a/sopel_modules/SpiceBot_Database_Command/__init__.py b/sopel_modules/SpiceBot_Database_Command/__init__.py deleted file mode 100644 index 5e8ee90..0000000 --- a/sopel_modules/SpiceBot_Database_Command/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# coding=utf-8 -"""Command for database information -""" -from __future__ import unicode_literals, absolute_import, print_function, division - -from .DatabaseCommand import * From 14a82dda0e6d0748e8ef52dc8d4faccac1597140 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 11:34:40 -0400 Subject: [PATCH 164/328] rename function --- sopel_modules/SpiceBot/Database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index daeda2f..8f66223 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -593,5 +593,5 @@ db = BotDatabase() @sopel.module.nickname_commands('database') -def bot_command_gender(bot, trigger): +def bot_command_database(bot, trigger): bot.osd("Database is " + botconfig.db_type) From 3bf05b9fce4da966369db12b3e65ad81bfc540ba Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 11:39:36 -0400 Subject: [PATCH 165/328] commands reverse integration --- sopel_modules/SpiceBot/Commands.py | 133 ++++++++++++++++++ .../NickQueryCommand.py | 76 ---------- .../SpiceBot_CommandsQuery/QueryCommand.py | 74 ---------- .../SpiceBot_CommandsQuery/__init__.py | 13 -- 4 files changed, 133 insertions(+), 163 deletions(-) delete mode 100644 sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py delete mode 100644 sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py delete mode 100644 sopel_modules/SpiceBot_CommandsQuery/__init__.py diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 3bc8fdd..3204787 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -14,6 +14,9 @@ import spicemanip from .Logs import logs from .Config import config as botconfig from .Database import db as botdb +from .Events import events +from .Prerun import prerun +from .Tools import letters_in_string, similar_list class BotCommands(): @@ -231,3 +234,133 @@ class BotCommands(): commands = BotCommands() + + +@events.check_ready([events.BOT_COMMANDSQUERY]) +@prerun.prerun('nickname') +@sopel.module.nickname_commands('(.*)') +def query_detection_nick(bot, trigger): + + # command issued, check if valid + if not trigger.sb['com'] or not len(trigger.sb['com']): + return + + if not trigger.sb['com'][0] == "?": + return + trigger.sb['com'] = trigger.sb['com'][1:] + + if not letters_in_string(trigger.sb['com']): + return + + commands_list = dict() + for com in commands.dict['commands']['nickname'].keys(): + if com not in commands_list.keys(): + commands_list[com] = commands.dict['commands']['nickname'][com] + + if trigger.sb['com'].endswith("+"): + + trigger.sb['com'] = trigger.sb['com'][:-1] + if not trigger.sb['com'] or not len(trigger.sb['com']): + return + + 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 = similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') + if len(closestmatches): + dispmsg.append("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") + bot.osd(dispmsg, trigger.nick, 'notice') + return + + 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.osd("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice') + return + + if trigger.sb['com'].endswith("?"): + + trigger.sb['com'] = trigger.sb['com'][:-1] + if not trigger.sb['com'] or not len(trigger.sb['com']): + return + + closestmatches = similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') + if not len(closestmatches): + bot.osd("Cannot find any similar " + bot.nick + " commands for " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') + else: + bot.osd("The following " + bot.nick + " commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice') + return + + commandlist = [] + for command in list(commands_list.keys()): + if command.lower().startswith(str(trigger.sb['com']).lower()): + commandlist.append(command) + + if not len(commandlist): + bot.osd("No " + bot.nick + " commands start with " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') + else: + bot.osd("The following " + bot.nick + " commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice') + + +@events.check_ready([events.BOT_COMMANDSQUERY]) +@prerun.prerun('query') +@sopel.module.rule('^\?(.*)') +def query_detection(bot, trigger): + + # command issued, check if valid + if not trigger.sb['com'] or not len(trigger.sb['com']): + return + + if not letters_in_string(trigger.sb['com']): + return + + commands_list = dict() + for commandstype in commands.dict['commands'].keys(): + if commandstype not in ['rule', 'nickname']: + for com in commands.dict['commands'][commandstype].keys(): + if com not in commands_list.keys(): + commands_list[com] = commands.dict['commands'][commandstype][com] + + if trigger.sb['com'][:-1] == "+": + + trigger.sb['com'] = trigger.sb['com'][:-1] + if not trigger.sb['com'] or not len(trigger.sb['com']): + return + + 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 = similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') + if len(closestmatches): + dispmsg.append("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") + bot.osd(dispmsg, trigger.nick, 'notice') + return + + 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.osd("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice') + return + + if trigger.sb['com'][:-1] == "?": + + trigger.sb['com'] = trigger.sb['com'][:-1] + if not trigger.sb['com'] or not len(trigger.sb['com']): + return + + closestmatches = similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') + if not len(closestmatches): + bot.osd("Cannot find any similar commands for " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') + else: + bot.osd("The following commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice') + return + + commandlist = [] + for command in list(commands_list.keys()): + if command.lower().startswith(str(trigger.sb['com']).lower()): + commandlist.append(command) + + if not len(commandlist): + bot.osd("No commands start with " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') + else: + bot.osd("The following commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice') diff --git a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py deleted file mode 100644 index d4fef62..0000000 --- a/sopel_modules/SpiceBot_CommandsQuery/NickQueryCommand.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - -import spicemanip - - -@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY]) -@SpiceBot.prerun.prerun('nickname') -@sopel.module.nickname_commands('(.*)') -def query_detection_nick(bot, trigger): - - # command issued, check if valid - if not trigger.sb['com'] or not len(trigger.sb['com']): - return - - if not trigger.sb['com'][0] == "?": - return - trigger.sb['com'] = trigger.sb['com'][1:] - - if not SpiceBot.letters_in_string(trigger.sb['com']): - return - - commands_list = dict() - for com in SpiceBot.commands.dict['commands']['nickname'].keys(): - if com not in commands_list.keys(): - commands_list[com] = SpiceBot.commands.dict['commands']['nickname'][com] - - if trigger.sb['com'].endswith("+"): - - trigger.sb['com'] = trigger.sb['com'][:-1] - if not trigger.sb['com'] or not len(trigger.sb['com']): - return - - 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(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') - if len(closestmatches): - dispmsg.append("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") - bot.osd(dispmsg, trigger.nick, 'notice') - return - - 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.osd("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice') - return - - if trigger.sb['com'].endswith("?"): - - trigger.sb['com'] = trigger.sb['com'][:-1] - if not trigger.sb['com'] or not len(trigger.sb['com']): - return - - closestmatches = SpiceBot.similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') - if not len(closestmatches): - bot.osd("Cannot find any similar " + bot.nick + " commands for " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') - else: - bot.osd("The following " + bot.nick + " commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice') - return - - commandlist = [] - for command in list(commands_list.keys()): - if command.lower().startswith(str(trigger.sb['com']).lower()): - commandlist.append(command) - - if not len(commandlist): - bot.osd("No " + bot.nick + " commands start with " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') - else: - bot.osd("The following " + bot.nick + " commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice') diff --git a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py b/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py deleted file mode 100644 index 277db87..0000000 --- a/sopel_modules/SpiceBot_CommandsQuery/QueryCommand.py +++ /dev/null @@ -1,74 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - -import spicemanip - - -@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY]) -@SpiceBot.prerun.prerun('query') -@sopel.module.rule('^\?(.*)') -def query_detection(bot, trigger): - - # command issued, check if valid - if not trigger.sb['com'] or not len(trigger.sb['com']): - return - - if not SpiceBot.letters_in_string(trigger.sb['com']): - return - - commands_list = dict() - for commandstype in SpiceBot.commands.dict['commands'].keys(): - if commandstype not in ['rule', 'nickname']: - for com in SpiceBot.commands.dict['commands'][commandstype].keys(): - if com not in commands_list.keys(): - commands_list[com] = SpiceBot.commands.dict['commands'][commandstype][com] - - if trigger.sb['com'][:-1] == "+": - - trigger.sb['com'] = trigger.sb['com'][:-1] - if not trigger.sb['com'] or not len(trigger.sb['com']): - return - - 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(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') - if len(closestmatches): - dispmsg.append("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") - bot.osd(dispmsg, trigger.nick, 'notice') - return - - 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.osd("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice') - return - - if trigger.sb['com'][:-1] == "?": - - trigger.sb['com'] = trigger.sb['com'][:-1] - if not trigger.sb['com'] or not len(trigger.sb['com']): - return - - closestmatches = SpiceBot.similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') - if not len(closestmatches): - bot.osd("Cannot find any similar commands for " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') - else: - bot.osd("The following commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice') - return - - commandlist = [] - for command in list(commands_list.keys()): - if command.lower().startswith(str(trigger.sb['com']).lower()): - commandlist.append(command) - - if not len(commandlist): - bot.osd("No commands start with " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') - else: - bot.osd("The following commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice') diff --git a/sopel_modules/SpiceBot_CommandsQuery/__init__.py b/sopel_modules/SpiceBot_CommandsQuery/__init__.py deleted file mode 100644 index 3dffefa..0000000 --- a/sopel_modules/SpiceBot_CommandsQuery/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf8 -"""Sopel Commands Query - -Sopel Commands Query responds to ? to display commands matching patterns -""" -from __future__ import unicode_literals, absolute_import, division, print_function - -from .QueryCommand import * -from .NickQueryCommand import * - -__author__ = 'Sam Zick' -__email__ = 'sam@deathbybandaid.net' -__version__ = '0.1.1' From 5a744a1f3fb96b123356b23d39c86afc601b1114 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 11:47:24 -0400 Subject: [PATCH 166/328] fix import as --- sopel_modules/SpiceBot/Prerun.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 820552d..0be912e 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -12,7 +12,7 @@ import datetime import spicemanip from .Tools import command_permissions_check -from .Commands import commands +from .Commands import commands as botcommands from .Database import db as botdb @@ -36,7 +36,7 @@ class BotPrerun(): argsdict_default["type"] = trigger_command_type argsdict_default["com"] = trigger_command - realcom = commands.get_realcom(argsdict_default["com"], trigger_command_type) + realcom = botcommands.get_realcom(argsdict_default["com"], trigger_command_type) argsdict_default["realcom"] = realcom # split into && groupings @@ -161,11 +161,11 @@ class BotPrerun(): bot.osd("This command must be run in a channel you which to enable it in.", trigger.nick, 'notice') return - if not commands.check_commands_disabled(trigger.sb["realcom"], trigger.sender): + if not botcommands.check_commands_disabled(trigger.sb["realcom"], trigger.sender): bot.osd(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick, 'notice') return - commands.unset_command_disabled(trigger.sb["realcom"], trigger.sender) + botcommands.unset_command_disabled(trigger.sb["realcom"], trigger.sender) bot.osd(trigger.sb["com"] + " is now enabled in " + str(trigger.sender)) return @@ -179,14 +179,14 @@ class BotPrerun(): bot.osd("This command must be run in a channel you which to disable it in.", trigger.nick, 'notice') return - if commands.check_commands_disabled(trigger.sb["realcom"], trigger.sender): + if botcommands.check_commands_disabled(trigger.sb["realcom"], trigger.sender): bot.osd(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick, 'notice') return trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given." timestamp = str(datetime.datetime.utcnow()) - commands.set_command_disabled(trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) + botcommands.set_command_disabled(trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick) bot.osd(trigger.sb["com"] + " is now disabled in " + str(trigger.sender)) return From 8d4c3dff2cf13b9c8b928fab1b1ff22d4b66e64f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 11:52:27 -0400 Subject: [PATCH 167/328] hmmm --- sopel_modules/SpiceBot/Commands.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 3204787..f1da6f5 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -15,7 +15,7 @@ from .Logs import logs from .Config import config as botconfig from .Database import db as botdb from .Events import events -from .Prerun import prerun +from .Prerun import prerun as botprerun from .Tools import letters_in_string, similar_list @@ -237,7 +237,7 @@ commands = BotCommands() @events.check_ready([events.BOT_COMMANDSQUERY]) -@prerun.prerun('nickname') +@botprerun.prerun('nickname') @sopel.module.nickname_commands('(.*)') def query_detection_nick(bot, trigger): @@ -303,7 +303,7 @@ def query_detection_nick(bot, trigger): @events.check_ready([events.BOT_COMMANDSQUERY]) -@prerun.prerun('query') +@botprerun.prerun('query') @sopel.module.rule('^\?(.*)') def query_detection(bot, trigger): From 3105f185452efd23d6c5b9c8cd234663998c68e7 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 11:53:17 -0400 Subject: [PATCH 168/328] maybe oreder is important --- sopel_modules/SpiceBot/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index e7ffc2b..9db085a 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -11,12 +11,12 @@ from .setup import * from .Config import * from .Tools import * +from .Prerun import * from .Logs import * from .Commands import * from .Events import * from .Channels import * from .Database import * -from .Prerun import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' From fc875dbf3a3730a1f397121118aa91588665c5ca Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 12:08:45 -0400 Subject: [PATCH 169/328] seperate module for core commands? --- sopel_modules/SpiceBot/Channels.py | 109 -------------- sopel_modules/SpiceBot/Commands.py | 133 ---------------- sopel_modules/SpiceBot/Database.py | 5 - .../SpiceBot_Core_Commands/Channels.py | 117 +++++++++++++++ .../SpiceBot_Core_Commands/Commands.py | 142 ++++++++++++++++++ .../SpiceBot_Core_Commands/Database.py | 15 ++ .../SpiceBot_Core_Commands/__init__.py | 15 ++ 7 files changed, 289 insertions(+), 247 deletions(-) create mode 100644 sopel_modules/SpiceBot_Core_Commands/Channels.py create mode 100644 sopel_modules/SpiceBot_Core_Commands/Commands.py create mode 100644 sopel_modules/SpiceBot_Core_Commands/Database.py create mode 100644 sopel_modules/SpiceBot_Core_Commands/__init__.py diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index 096caa4..c818d79 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -15,8 +15,6 @@ import spicemanip from .Config import config as botconfig from .Events import events from .Logs import logs -from .Prerun import prerun -from .Tools import inlist, channel_privs class SpiceBot_Channels_MainSection(StaticSection): @@ -190,110 +188,3 @@ def trigger_channel_list_recurring(bot, trigger): if "*" in channels.dict['list'].keys(): del channels.dict['list']["*"] channels.bot_part_empty(bot) - - -@events.check_ready([events.BOT_LOADED]) -@prerun.prerun('nickname') -@sopel.module.nickname_commands('channels', 'channel') -def nickname_comand_channels(bot, trigger): - - if not len(trigger.sb['args']): - commandused = 'list' - else: - commandused = spicemanip.main(trigger.sb['args'], 1).lower() - - trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') - - if commandused == 'list': - chanlist = spicemanip.main(bot.channels.keys(), 'andlist') - bot.osd("You can find me in " + chanlist) - return - - elif commandused == 'total': - botcount = len(bot.channels.keys()) - servercount = len(channels.dict['list'].keys()) - bot.osd("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") - return - - elif commandused == 'random': - channel = spicemanip.main(channels.dict['list'], 'random') - topic = channels.dict['list'][channel]['topic'] - msg = ["Random channel for you: {}.".format(channels.dict['list'][channel]['name'])] - if topic and not topic.isspace(): - msg.append("The topic is: {}".format(topic)) - else: - msg.append("Its topic is empty.") - bot.osd(msg) - return - - elif commandused == 'update': - if not trigger.admin: - bot.osd("You do not have permission to update the channel listing.") - return - channels.bot_part_empty(bot) - channels.channel_list_request(bot) - bot.osd(["[SpiceBot_Channels]", "I am now updating the channel listing for this server."]) - while channels.channel_lock: - pass - channels.join_all_channels(bot) - foundchannelcount = len(channels.dict['list'].keys()) - bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.") - channels.bot_part_empty(bot) - return - - elif commandused == 'topic': - if not len(trigger.sb['args']): - bot.osd("Channel name input missing.") - return - channel = spicemanip.main(trigger.sb['args'], 1) - if not inlist(channel.lower(), channels.dict['list'].keys()): - bot.osd("Channel name {} not valid.".format(channel)) - return - topic = channels.dict['list'][channel.lower()]['topic'] - channel = channels.dict['list'][channel.lower()]['name'] - bot.osd("Topic for {}: {}".format(channel, topic)) - return - - if commandused.upper() in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']: - if not len(trigger.sb['args']): - if trigger.is_privmsg: - bot.osd("Channel name required.") - return - else: - channel = trigger.sender - else: - channel = spicemanip.main(trigger.sb['args'], 1) - if not inlist(channel.lower(), channels.dict['list'].keys()): - bot.osd("Channel name {} not valid.".format(channel)) - return - if not inlist(channel.lower(), bot.channels.keys()): - bot.osd("I need to be in {} to see nick privileges.".format(channel)) - return - - privlist = channel_privs(bot, channel, commandused.upper()) - dispmsg = [] - if not len(privlist): - dispmsg.append("There are no Channel " + commandused.upper() + "s for " + str(channel)) - else: - oplist = spicemanip.main(privlist, 'andlist') - dispmsg.append("Channel " + commandused.upper() + "s for " + str(channel) + " are: " + oplist) - bot.osd(dispmsg, trigger.nick, 'notice') - return - - # Users List - if commandused == 'users': - channel = spicemanip.main(trigger.sb['args'], 1) - if not inlist(channel.lower(), channels.dict['list'].keys()): - bot.osd("Channel name {} not valid.".format(channel)) - return - if not inlist(channel.lower(), bot.channels.keys()): - bot.osd("I need to be in {} to see user list.".format(channel)) - return - dispmsg = [] - if not len(bot.channels[channel].privileges.keys()): - dispmsg.append("There are no Channel users for " + str(channel)) - else: - userslist = spicemanip.main(bot.channels[channel].privileges.keys(), 'andlist') - dispmsg.append("Channel users for " + str(channel) + " are: " + userslist) - bot.osd(dispmsg, trigger.nick, 'notice') - return diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index f1da6f5..3bc8fdd 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -14,9 +14,6 @@ import spicemanip from .Logs import logs from .Config import config as botconfig from .Database import db as botdb -from .Events import events -from .Prerun import prerun as botprerun -from .Tools import letters_in_string, similar_list class BotCommands(): @@ -234,133 +231,3 @@ class BotCommands(): commands = BotCommands() - - -@events.check_ready([events.BOT_COMMANDSQUERY]) -@botprerun.prerun('nickname') -@sopel.module.nickname_commands('(.*)') -def query_detection_nick(bot, trigger): - - # command issued, check if valid - if not trigger.sb['com'] or not len(trigger.sb['com']): - return - - if not trigger.sb['com'][0] == "?": - return - trigger.sb['com'] = trigger.sb['com'][1:] - - if not letters_in_string(trigger.sb['com']): - return - - commands_list = dict() - for com in commands.dict['commands']['nickname'].keys(): - if com not in commands_list.keys(): - commands_list[com] = commands.dict['commands']['nickname'][com] - - if trigger.sb['com'].endswith("+"): - - trigger.sb['com'] = trigger.sb['com'][:-1] - if not trigger.sb['com'] or not len(trigger.sb['com']): - return - - 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 = similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') - if len(closestmatches): - dispmsg.append("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") - bot.osd(dispmsg, trigger.nick, 'notice') - return - - 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.osd("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice') - return - - if trigger.sb['com'].endswith("?"): - - trigger.sb['com'] = trigger.sb['com'][:-1] - if not trigger.sb['com'] or not len(trigger.sb['com']): - return - - closestmatches = similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') - if not len(closestmatches): - bot.osd("Cannot find any similar " + bot.nick + " commands for " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') - else: - bot.osd("The following " + bot.nick + " commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice') - return - - commandlist = [] - for command in list(commands_list.keys()): - if command.lower().startswith(str(trigger.sb['com']).lower()): - commandlist.append(command) - - if not len(commandlist): - bot.osd("No " + bot.nick + " commands start with " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') - else: - bot.osd("The following " + bot.nick + " commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice') - - -@events.check_ready([events.BOT_COMMANDSQUERY]) -@botprerun.prerun('query') -@sopel.module.rule('^\?(.*)') -def query_detection(bot, trigger): - - # command issued, check if valid - if not trigger.sb['com'] or not len(trigger.sb['com']): - return - - if not letters_in_string(trigger.sb['com']): - return - - commands_list = dict() - for commandstype in commands.dict['commands'].keys(): - if commandstype not in ['rule', 'nickname']: - for com in commands.dict['commands'][commandstype].keys(): - if com not in commands_list.keys(): - commands_list[com] = commands.dict['commands'][commandstype][com] - - if trigger.sb['com'][:-1] == "+": - - trigger.sb['com'] = trigger.sb['com'][:-1] - if not trigger.sb['com'] or not len(trigger.sb['com']): - return - - 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 = similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') - if len(closestmatches): - dispmsg.append("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") - bot.osd(dispmsg, trigger.nick, 'notice') - return - - 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.osd("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice') - return - - if trigger.sb['com'][:-1] == "?": - - trigger.sb['com'] = trigger.sb['com'][:-1] - if not trigger.sb['com'] or not len(trigger.sb['com']): - return - - closestmatches = similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') - if not len(closestmatches): - bot.osd("Cannot find any similar commands for " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') - else: - bot.osd("The following commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice') - return - - commandlist = [] - for command in list(commands_list.keys()): - if command.lower().startswith(str(trigger.sb['com']).lower()): - commandlist.append(command) - - if not len(commandlist): - bot.osd("No commands start with " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') - else: - bot.osd("The following commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice') diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 8f66223..5832abc 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -590,8 +590,3 @@ class BotDatabase(): db = BotDatabase() - - -@sopel.module.nickname_commands('database') -def bot_command_database(bot, trigger): - bot.osd("Database is " + botconfig.db_type) diff --git a/sopel_modules/SpiceBot_Core_Commands/Channels.py b/sopel_modules/SpiceBot_Core_Commands/Channels.py new file mode 100644 index 0000000..289e7f8 --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Commands/Channels.py @@ -0,0 +1,117 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot Channels system. +""" +import sopel + +import spicemanip + +import sopel_modules.SpiceBot as SpiceBot + + +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) +@SpiceBot.prerun.prerun('nickname') +@sopel.module.nickname_commands('channels', 'channel') +def nickname_comand_channels(bot, trigger): + + if not len(trigger.sb['args']): + commandused = 'list' + else: + commandused = spicemanip.main(trigger.sb['args'], 1).lower() + + trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') + + if commandused == 'list': + chanlist = spicemanip.main(bot.SpiceBot.channels.keys(), 'andlist') + bot.osd("You can find me in " + chanlist) + return + + elif commandused == 'total': + botcount = len(bot.SpiceBot.channels.keys()) + servercount = len(SpiceBot.channels.dict['list'].keys()) + bot.osd("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") + return + + elif commandused == 'random': + channel = spicemanip.main(SpiceBot.channels.dict['list'], 'random') + topic = SpiceBot.channels.dict['list'][channel]['topic'] + msg = ["Random channel for you: {}.".format(SpiceBot.channels.dict['list'][channel]['name'])] + if topic and not topic.isspace(): + msg.append("The topic is: {}".format(topic)) + else: + msg.append("Its topic is empty.") + bot.osd(msg) + return + + elif commandused == 'update': + if not trigger.admin: + bot.osd("You do not have permission to update the channel listing.") + return + SpiceBot.channels.bot_part_empty(bot) + SpiceBot.channels.channel_list_request(bot) + bot.osd(["[SpiceBot_Channels]", "I am now updating the channel listing for this server."]) + while SpiceBot.channels.channel_lock: + pass + SpiceBot.channels.join_all_channels(bot) + foundchannelcount = len(SpiceBot.channels.dict['list'].keys()) + bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.") + SpiceBot.channels.bot_part_empty(bot) + return + + elif commandused == 'topic': + if not len(trigger.sb['args']): + bot.osd("Channel name input missing.") + return + 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 + topic = SpiceBot.channels.dict['list'][channel.lower()]['topic'] + channel = SpiceBot.channels.dict['list'][channel.lower()]['name'] + bot.osd("Topic for {}: {}".format(channel, topic)) + return + + if commandused.upper() in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']: + if not len(trigger.sb['args']): + if trigger.is_privmsg: + bot.osd("Channel name required.") + return + else: + channel = trigger.sender + else: + 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 + if not SpiceBot.inlist(channel.lower(), bot.SpiceBot.channels.keys()): + bot.osd("I need to be in {} to see nick privileges.".format(channel)) + return + + privlist = SpiceBot.channel_privs(bot, channel, commandused.upper()) + dispmsg = [] + if not len(privlist): + dispmsg.append("There are no Channel " + commandused.upper() + "s for " + str(channel)) + else: + oplist = spicemanip.main(privlist, 'andlist') + dispmsg.append("Channel " + commandused.upper() + "s for " + str(channel) + " are: " + oplist) + bot.osd(dispmsg, trigger.nick, 'notice') + return + + # Users List + if commandused == 'users': + 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 + if not SpiceBot.inlist(channel.lower(), bot.SpiceBot.channels.keys()): + bot.osd("I need to be in {} to see user list.".format(channel)) + return + dispmsg = [] + if not len(bot.channels[channel].privileges.keys()): + dispmsg.append("There are no Channel users for " + str(channel)) + else: + userslist = spicemanip.main(bot.channels[channel].privileges.keys(), 'andlist') + dispmsg.append("Channel users for " + str(channel) + " are: " + userslist) + bot.osd(dispmsg, trigger.nick, 'notice') + return diff --git a/sopel_modules/SpiceBot_Core_Commands/Commands.py b/sopel_modules/SpiceBot_Core_Commands/Commands.py new file mode 100644 index 0000000..bf632a8 --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Commands/Commands.py @@ -0,0 +1,142 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot Commands system. + +This Class stores commands in an easy to access manner +""" +import sopel + +import spicemanip + +import sopel_modules.SpiceBot as SpiceBot + + +@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY]) +@SpiceBot.prerun.prerun('nickname') +@sopel.module.nickname_commands('(.*)') +def query_detection_nick(bot, trigger): + + # command issued, check if valid + if not trigger.sb['com'] or not len(trigger.sb['com']): + return + + if not trigger.sb['com'][0] == "?": + return + trigger.sb['com'] = trigger.sb['com'][1:] + + if not SpiceBot.letters_in_string(trigger.sb['com']): + return + + commands_list = dict() + for com in SpiceBot.commands.dict['commands']['nickname'].keys(): + if com not in commands_list.keys(): + commands_list[com] = SpiceBot.commands.dict['commands']['nickname'][com] + + if trigger.sb['com'].endswith("+"): + + trigger.sb['com'] = trigger.sb['com'][:-1] + if not trigger.sb['com'] or not len(trigger.sb['com']): + return + + 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(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') + if len(closestmatches): + dispmsg.append("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") + bot.osd(dispmsg, trigger.nick, 'notice') + return + + 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.osd("The following " + bot.nick + " commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice') + return + + if trigger.sb['com'].endswith("?"): + + trigger.sb['com'] = trigger.sb['com'][:-1] + if not trigger.sb['com'] or not len(trigger.sb['com']): + return + + closestmatches = SpiceBot.similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') + if not len(closestmatches): + bot.osd("Cannot find any similar " + bot.nick + " commands for " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') + else: + bot.osd("The following " + bot.nick + " commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice') + return + + commandlist = [] + for command in list(commands_list.keys()): + if command.lower().startswith(str(trigger.sb['com']).lower()): + commandlist.append(command) + + if not len(commandlist): + bot.osd("No " + bot.nick + " commands start with " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') + else: + bot.osd("The following " + bot.nick + " commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice') + + +@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY]) +@SpiceBot.prerun.prerun('query') +@sopel.module.rule('^\?(.*)') +def query_detection(bot, trigger): + + # command issued, check if valid + if not trigger.sb['com'] or not len(trigger.sb['com']): + return + + if not SpiceBot.letters_in_string(trigger.sb['com']): + return + + commands_list = dict() + for commandstype in SpiceBot.commands.dict['commands'].keys(): + if commandstype not in ['rule', 'nickname']: + for com in SpiceBot.commands.dict['commands'][commandstype].keys(): + if com not in commands_list.keys(): + commands_list[com] = SpiceBot.commands.dict['commands'][commandstype][com] + + if trigger.sb['com'][:-1] == "+": + + trigger.sb['com'] = trigger.sb['com'][:-1] + if not trigger.sb['com'] or not len(trigger.sb['com']): + return + + 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(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') + if len(closestmatches): + dispmsg.append("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") + bot.osd(dispmsg, trigger.nick, 'notice') + return + + 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.osd("The following commands match " + str(trigger.sb['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice') + return + + if trigger.sb['com'][:-1] == "?": + + trigger.sb['com'] = trigger.sb['com'][:-1] + if not trigger.sb['com'] or not len(trigger.sb['com']): + return + + closestmatches = SpiceBot.similar_list(trigger.sb['com'], list(commands_list.keys()), 10, 'reverse') + if not len(closestmatches): + bot.osd("Cannot find any similar commands for " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') + else: + bot.osd("The following commands may match " + str(trigger.sb['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice') + return + + commandlist = [] + for command in list(commands_list.keys()): + if command.lower().startswith(str(trigger.sb['com']).lower()): + commandlist.append(command) + + if not len(commandlist): + bot.osd("No commands start with " + str(trigger.sb['com']) + ".", trigger.nick, 'notice') + else: + bot.osd("The following commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice') diff --git a/sopel_modules/SpiceBot_Core_Commands/Database.py b/sopel_modules/SpiceBot_Core_Commands/Database.py new file mode 100644 index 0000000..c4773a5 --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Commands/Database.py @@ -0,0 +1,15 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot Database +""" + +# sopel imports +import sopel.module + +import sopel_modules.SpiceBot as SpiceBot + + +@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/__init__.py b/sopel_modules/SpiceBot_Core_Commands/__init__.py new file mode 100644 index 0000000..38f3e8e --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Commands/__init__.py @@ -0,0 +1,15 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +These are the core SpiceBot Classes + +This module contains references only for other modules to utilize. +""" + +from .Commands import * +from .Channels import * +from .Database import * + +__author__ = 'Sam Zick' +__email__ = 'sam@deathbybandaid.net' +__version__ = '0.1.1' From faa1eeb8648cd3d604a9c9170a65b817932b03d9 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 12:12:21 -0400 Subject: [PATCH 170/328] durrr --- sopel_modules/SpiceBot_Core_Commands/Channels.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot_Core_Commands/Channels.py b/sopel_modules/SpiceBot_Core_Commands/Channels.py index 289e7f8..d8c863b 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Channels.py +++ b/sopel_modules/SpiceBot_Core_Commands/Channels.py @@ -23,12 +23,12 @@ def nickname_comand_channels(bot, trigger): trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') if commandused == 'list': - chanlist = spicemanip.main(bot.SpiceBot.channels.keys(), 'andlist') + chanlist = spicemanip.main(bot.channels.keys(), 'andlist') bot.osd("You can find me in " + chanlist) return elif commandused == 'total': - botcount = len(bot.SpiceBot.channels.keys()) + botcount = len(bot.channels.keys()) servercount = len(SpiceBot.channels.dict['list'].keys()) bot.osd("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") return @@ -84,7 +84,7 @@ def nickname_comand_channels(bot, trigger): if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()): bot.osd("Channel name {} not valid.".format(channel)) return - if not SpiceBot.inlist(channel.lower(), bot.SpiceBot.channels.keys()): + if not SpiceBot.inlist(channel.lower(), bot.channels.keys()): bot.osd("I need to be in {} to see nick privileges.".format(channel)) return @@ -104,7 +104,7 @@ def nickname_comand_channels(bot, trigger): if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()): bot.osd("Channel name {} not valid.".format(channel)) return - if not SpiceBot.inlist(channel.lower(), bot.SpiceBot.channels.keys()): + if not SpiceBot.inlist(channel.lower(), bot.channels.keys()): bot.osd("I need to be in {} to see user list.".format(channel)) return dispmsg = [] From 75674019c630f4673d536cc14d60b012abb32ab6 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 12:18:57 -0400 Subject: [PATCH 171/328] split core processing --- sopel_modules/SpiceBot/Channels.py | 85 ---------------- .../SpiceBot_Core_Processing/Channels.py | 97 +++++++++++++++++++ .../SpiceBot_Core_Processing/__init__.py | 14 +++ 3 files changed, 111 insertions(+), 85 deletions(-) create mode 100644 sopel_modules/SpiceBot_Core_Processing/Channels.py create mode 100644 sopel_modules/SpiceBot_Core_Processing/__init__.py diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index c818d79..5cfe318 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -103,88 +103,3 @@ class BotChannels(): channels = BotChannels() - - -@sopel.module.event(events.RPL_WELCOME) -@sopel.module.rule('.*') -def unkickable_bot(bot, trigger): - if bot.config.SpiceBot_Channels.operadmin: - bot.write(('SAMODE', bot.nick, '+q')) - - -@sopel.module.event(events.RPL_WELCOME) -@sopel.module.rule('.*') -def request_channels_list_initial(bot, trigger): - - channels.bot_part_empty(bot) - - logs.log('SpiceBot_Channels', "Sending Request for all server channels") - channels.channel_list_request(bot) - - starttime = time.time() - - # wait 60 seconds for initial population of information - while not channels.dict['InitialProcess']: - if time.time() - starttime >= 60: - logs.log('SpiceBot_Channels', "Initial Channel list populating Timed Out") - channels.dict['InitialProcess'] = True - else: - pass - - foundchannelcount = len(channels.dict['list'].keys()) - logs.log('SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.") - - channels.join_all_channels(bot) - channels.chanadmin_all_channels(bot) - - if "*" in channels.dict['list'].keys(): - del channels.dict['list']["*"] - - channels.bot_part_empty(bot) - events.trigger(bot, events.BOT_CHANNELS, "SpiceBot_Channels") - - -@sopel.module.event('321') -@sopel.module.rule('.*') -def watch_chanlist_start(bot, trigger): - channels.channel_list_recieve_start() - - -@sopel.module.event('322') -@sopel.module.rule('.*') -def watch_chanlist_populate(bot, trigger): - channels.channel_list_recieve_input(trigger) - - -@sopel.module.event('323') -@sopel.module.rule('.*') -def watch_chanlist_complete(bot, trigger): - channels.channel_list_recieve_finish() - - -@sopel.module.event(events.BOT_CHANNELS) -@sopel.module.rule('.*') -def trigger_channel_list_recurring(bot, trigger): - while True: - time.sleep(1800) - channels.bot_part_empty(bot) - - oldlist = list(channels.dict['list'].keys()) - channels.channel_list_request(bot) - - while channels.channel_lock: - pass - - newlist = [item.lower() for item in oldlist if item.lower() not in list(channels.dict['list'].keys())] - if "*" in newlist: - newlist.remove("*") - if len(newlist) and bot.config.SpiceBot_Channels.announcenew: - bot.osd(["The Following channel(s) are new:", spicemanip.main(newlist, 'andlist')], bot.channels.keys()) - - channels.join_all_channels(bot) - - channels.chanadmin_all_channels(bot) - - if "*" in channels.dict['list'].keys(): - del channels.dict['list']["*"] - channels.bot_part_empty(bot) diff --git a/sopel_modules/SpiceBot_Core_Processing/Channels.py b/sopel_modules/SpiceBot_Core_Processing/Channels.py new file mode 100644 index 0000000..f3ae10b --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Processing/Channels.py @@ -0,0 +1,97 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot Channels system. +""" +import sopel + +import time + +import spicemanip + +import sopel_modules.SpiceBot as SpiceBot + + +@sopel.module.event(SpiceBot.events.RPL_WELCOME) +@sopel.module.rule('.*') +def unkickable_bot(bot, trigger): + if bot.config.SpiceBot_SpiceBot.channels.operadmin: + bot.write(('SAMODE', bot.nick, '+q')) + + +@sopel.module.event(SpiceBot.events.RPL_WELCOME) +@sopel.module.rule('.*') +def request_channels_list_initial(bot, trigger): + + SpiceBot.channels.bot_part_empty(bot) + + SpiceBot.logs.log('SpiceBot_Channels', "Sending Request for all server channels") + SpiceBot.channels.channel_list_request(bot) + + starttime = time.time() + + # wait 60 seconds for initial population of information + while not SpiceBot.channels.dict['InitialProcess']: + if time.time() - starttime >= 60: + SpiceBot.logs.log('SpiceBot_Channels', "Initial Channel list populating Timed Out") + SpiceBot.channels.dict['InitialProcess'] = True + else: + pass + + foundchannelcount = len(SpiceBot.channels.dict['list'].keys()) + SpiceBot.logs.log('SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.") + + SpiceBot.channels.join_all_channels(bot) + SpiceBot.channels.chanadmin_all_channels(bot) + + if "*" in SpiceBot.channels.dict['list'].keys(): + del SpiceBot.channels.dict['list']["*"] + + SpiceBot.channels.bot_part_empty(bot) + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_CHANNELS, "SpiceBot_Channels") + + +@sopel.module.event('321') +@sopel.module.rule('.*') +def watch_chanlist_start(bot, trigger): + SpiceBot.channels.channel_list_recieve_start() + + +@sopel.module.event('322') +@sopel.module.rule('.*') +def watch_chanlist_populate(bot, trigger): + SpiceBot.channels.channel_list_recieve_input(trigger) + + +@sopel.module.event('323') +@sopel.module.rule('.*') +def watch_chanlist_complete(bot, trigger): + SpiceBot.channels.channel_list_recieve_finish() + + +@sopel.module.event(SpiceBot.events.BOT_CHANNELS) +@sopel.module.rule('.*') +def trigger_channel_list_recurring(bot, trigger): + while True: + time.sleep(1800) + SpiceBot.channels.bot_part_empty(bot) + + oldlist = list(SpiceBot.channels.dict['list'].keys()) + SpiceBot.channels.channel_list_request(bot) + + while SpiceBot.channels.channel_lock: + pass + + newlist = [item.lower() for item in oldlist if item.lower() not in list(SpiceBot.channels.dict['list'].keys())] + if "*" in newlist: + newlist.remove("*") + if len(newlist) and bot.config.SpiceBot_SpiceBot.channels.announcenew: + bot.osd(["The Following channel(s) are new:", spicemanip.main(newlist, 'andlist')], bot.channels.keys()) + + SpiceBot.channels.join_all_channels(bot) + + SpiceBot.channels.chanadmin_all_channels(bot) + + if "*" in SpiceBot.channels.dict['list'].keys(): + del SpiceBot.channels.dict['list']["*"] + SpiceBot.channels.bot_part_empty(bot) diff --git a/sopel_modules/SpiceBot_Core_Processing/__init__.py b/sopel_modules/SpiceBot_Core_Processing/__init__.py new file mode 100644 index 0000000..3901a3c --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Processing/__init__.py @@ -0,0 +1,14 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +These are the core SpiceBot Classes + +This module contains references only for other modules to utilize. +""" + +from .Channels import * + + +__author__ = 'Sam Zick' +__email__ = 'sam@deathbybandaid.net' +__version__ = '0.1.1' From b9ba45122bbda8c5ac62a4eda4ad8b964d2f2ffe Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 12:28:36 -0400 Subject: [PATCH 172/328] uptime --- sopel_modules/SpiceBot/Events.py | 4 ++- .../SpiceBot_Core_Commands/Uptime.py | 15 +++++++++++ .../SpiceBot_Core_Commands/__init__.py | 1 + sopel_modules/SpiceBot_Uptime/Uptime.py | 27 ------------------- sopel_modules/SpiceBot_Uptime/__init__.py | 8 ------ 5 files changed, 19 insertions(+), 36 deletions(-) create mode 100644 sopel_modules/SpiceBot_Core_Commands/Uptime.py delete mode 100644 sopel_modules/SpiceBot_Uptime/Uptime.py delete mode 100644 sopel_modules/SpiceBot_Uptime/__init__.py diff --git a/sopel_modules/SpiceBot/Events.py b/sopel_modules/SpiceBot/Events.py index a6e1e5b..189cbe2 100644 --- a/sopel_modules/SpiceBot/Events.py +++ b/sopel_modules/SpiceBot/Events.py @@ -10,6 +10,7 @@ self-trigger the bot into performing actions import sopel import functools import threading +import time from .Logs import logs @@ -34,6 +35,7 @@ class BotEvents(object): def __init__(self): self.lock = threading.Lock() self.RPL_WELCOME = '001' # This is a defined IRC event + self.BOT_UPTIME = time.time() self.BOT_WELCOME = '1001' self.BOT_READY = '1002' self.BOT_CONNECTED = '1003' @@ -41,7 +43,7 @@ class BotEvents(object): self.BOT_RECONNECTED = '1005' self.defaultevents = [self.BOT_WELCOME, self.BOT_READY, self.BOT_CONNECTED, self.BOT_LOADED, self.BOT_RECONNECTED] self.dict = { - "assigned_IDs": {1000: "Default", 1001: "BOT_WELCOME", 1002: "BOT_READY", 1003: "BOT_CONNECTED", 1004: "BOT_LOADED", 1005: "BOT_RECONNECTED"}, + "assigned_IDs": {1000: "BOT_UPTIME", 1001: "BOT_WELCOME", 1002: "BOT_READY", 1003: "BOT_CONNECTED", 1004: "BOT_LOADED", 1005: "BOT_RECONNECTED"}, "triggers_recieved": {}, "trigger_queue": [], "startup_required": [self.BOT_WELCOME, self.BOT_READY, self.BOT_CONNECTED], diff --git a/sopel_modules/SpiceBot_Core_Commands/Uptime.py b/sopel_modules/SpiceBot_Core_Commands/Uptime.py new file mode 100644 index 0000000..b8aa223 --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Commands/Uptime.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +import sopel.module + +import time + +import sopel_modules.SpiceBot as SpiceBot + + +@sopel.module.nickname_commands('uptime') +def bot_command_srewyou(bot, trigger): + timesince = str(SpiceBot.humanized_time(time.time() - SpiceBot.events.BOT_UPTIME)) + " ago." + bot.osd("I have been running since " + timesince) diff --git a/sopel_modules/SpiceBot_Core_Commands/__init__.py b/sopel_modules/SpiceBot_Core_Commands/__init__.py index 38f3e8e..f686aba 100644 --- a/sopel_modules/SpiceBot_Core_Commands/__init__.py +++ b/sopel_modules/SpiceBot_Core_Commands/__init__.py @@ -9,6 +9,7 @@ This module contains references only for other modules to utilize. from .Commands import * from .Channels import * from .Database import * +from .Uptime import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' diff --git a/sopel_modules/SpiceBot_Uptime/Uptime.py b/sopel_modules/SpiceBot_Uptime/Uptime.py deleted file mode 100644 index 8273582..0000000 --- a/sopel_modules/SpiceBot_Uptime/Uptime.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import time - -import sopel_modules.SpiceBot as SpiceBot - - -def setup(bot): - if 'SpiceBot_Uptime' not in bot.memory: - now = time.time() - SpiceBot.logs.log('SpiceBot_Uptime', "Start time set to " + str(time.time())) - 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(SpiceBot.humanized_time(time.time() - bot.memory["SpiceBot_Uptime"])) + " ago." - bot.osd("I have been running since " + timesince) diff --git a/sopel_modules/SpiceBot_Uptime/__init__.py b/sopel_modules/SpiceBot_Uptime/__init__.py deleted file mode 100644 index d0079c0..0000000 --- a/sopel_modules/SpiceBot_Uptime/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# coding=utf8 -from __future__ import unicode_literals, absolute_import, division, print_function - -from .Uptime import * - -__author__ = 'Sam Zick' -__email__ = 'sam@deathbybandaid.net' -__version__ = '0.1.1' From e5bea4ea9c8108239069e32aca5e09f1bc302acd Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 12:41:23 -0400 Subject: [PATCH 173/328] channel and events --- sopel_modules/SpiceBot/Commands.py | 5 +- sopel_modules/SpiceBot_AI/AI.py | 2 +- .../SpiceBot_Core_Commands/Commands.py | 4 +- .../SpiceBot_Core_Processing/Events.py | 68 +++++++++++++++++++ .../Modules.py} | 24 +++---- .../SpiceBot_Core_Processing/__init__.py | 2 + sopel_modules/SpiceBot_Events/Connected.py | 16 ----- .../SpiceBot_Events/Connection_Count.py | 15 ---- sopel_modules/SpiceBot_Events/Loaded.py | 15 ---- sopel_modules/SpiceBot_Events/Logging.py | 14 ---- sopel_modules/SpiceBot_Events/Queue.py | 18 ----- sopel_modules/SpiceBot_Events/Ready.py | 14 ---- sopel_modules/SpiceBot_Events/Welcome.py | 17 ----- sopel_modules/SpiceBot_Events/__init__.py | 13 ---- .../SpiceBot_Module_Parsing/__init__.py | 10 --- .../StartupMonologue_Display_Commands.py | 2 +- 16 files changed, 86 insertions(+), 153 deletions(-) create mode 100644 sopel_modules/SpiceBot_Core_Processing/Events.py rename sopel_modules/{SpiceBot_Module_Parsing/ModuleParsing.py => SpiceBot_Core_Processing/Modules.py} (50%) delete mode 100644 sopel_modules/SpiceBot_Events/Connected.py delete mode 100644 sopel_modules/SpiceBot_Events/Connection_Count.py delete mode 100644 sopel_modules/SpiceBot_Events/Loaded.py delete mode 100644 sopel_modules/SpiceBot_Events/Logging.py delete mode 100644 sopel_modules/SpiceBot_Events/Queue.py delete mode 100644 sopel_modules/SpiceBot_Events/Ready.py delete mode 100644 sopel_modules/SpiceBot_Events/Welcome.py delete mode 100644 sopel_modules/SpiceBot_Events/__init__.py delete mode 100644 sopel_modules/SpiceBot_Module_Parsing/__init__.py diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 3bc8fdd..75d5e33 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -29,6 +29,9 @@ class BotCommands(): }, 'disabled': {} } + self.module_files_parse() + for comtype in ['module', 'nickname', 'rule']: + logs.log('SpiceBot_Commands', "Found " + str(len(self.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) def find_command_type(self, command): for commandstype in self.dict['commands'].keys(): @@ -129,7 +132,7 @@ class BotCommands(): pypi_modules_dir = os.path.join(plugin_dir, pathname) filepathlisting.append(pypi_modules_dir) except Exception as e: - logs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) + logs.log('SpiceBOT_COMMANDS', "sopel_modules not loaded :" + str(e)) # Extra directories for directory in botconfig.extra: diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index 314dc26..4ee3cd2 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -9,7 +9,7 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot -@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDSQUERY]) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDS]) @SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('(.*)') def bot_command_nick(bot, trigger): diff --git a/sopel_modules/SpiceBot_Core_Commands/Commands.py b/sopel_modules/SpiceBot_Core_Commands/Commands.py index bf632a8..461c62a 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Commands.py +++ b/sopel_modules/SpiceBot_Core_Commands/Commands.py @@ -12,7 +12,7 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot -@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY]) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) @SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('(.*)') def query_detection_nick(bot, trigger): @@ -78,7 +78,7 @@ def query_detection_nick(bot, trigger): bot.osd("The following " + bot.nick + " commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice') -@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY]) +@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) @SpiceBot.prerun.prerun('query') @sopel.module.rule('^\?(.*)') def query_detection(bot, trigger): diff --git a/sopel_modules/SpiceBot_Core_Processing/Events.py b/sopel_modules/SpiceBot_Core_Processing/Events.py new file mode 100644 index 0000000..422e493 --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Processing/Events.py @@ -0,0 +1,68 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot Channels system. +""" +import sopel + +import sopel_modules.SpiceBot as SpiceBot + + +@sopel.module.event(SpiceBot.events.BOT_WELCOME) +@sopel.module.rule('.*') +def bot_events_connected(bot, trigger): + """For items tossed in a queue, this will trigger them accordingly""" + while True: + if len(SpiceBot.events.dict["trigger_queue"]): + pretriggerdict = SpiceBot.events.dict["trigger_queue"][0] + SpiceBot.events.dispatch(bot, pretriggerdict) + del SpiceBot.events.dict["trigger_queue"][0] + + +@sopel.module.event(SpiceBot.events.BOT_WELCOME, SpiceBot.events.BOT_READY, SpiceBot.events.BOT_CONNECTED, SpiceBot.events.BOT_LOADED) +@sopel.module.rule('.*') +def bot_events_complete(bot, trigger): + """This is here simply to log to stderr that this was recieved.""" + SpiceBot.logs.log('SpiceBot_Events', trigger.args[1], True) + + +@sopel.module.event(SpiceBot.events.RPL_WELCOME) +@sopel.module.rule('.*') +def bot_startup_welcome(bot, trigger): + """The Bot events system does not start until RPL_WELCOME 001 is recieved + from the server""" + if SpiceBot.events.check(SpiceBot.events.BOT_WELCOME): + return + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_WELCOME, "Welcome to the SpiceBot Events System") + + +@sopel.module.event(SpiceBot.events.BOT_WELCOME) +@sopel.module.rule('.*') +def bot_events_start(bot, trigger): + """This stage is redundant, but shows the system is working.""" + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_READY, "Ready To Process module setup procedures") + + +@sopel.module.event(SpiceBot.events.BOT_WELCOME) +@sopel.module.rule('.*') +def bot_events_Connected(bot, trigger): + """Here, we wait until we are in at least one channel""" + while not len(bot.channels.keys()) > 0: + pass + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_CONNECTED, "Bot Connected to IRC") + + +@SpiceBot.events.startup_check_ready() +@sopel.module.event(SpiceBot.events.BOT_READY) +@sopel.module.rule('.*') +def bot_events_startup_complete(bot, trigger): + """All events registered as required for startup have completed""" + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_LOADED, "All registered modules setup procedures have completed") + + +@sopel.module.event(SpiceBot.events.RPL_WELCOME) +@sopel.module.rule('.*') +def bot_startup_reconnect(bot, trigger): + SpiceBot.events.dict["RPL_WELCOME_Count"] += 1 + if SpiceBot.events.dict["RPL_WELCOME_Count"] > 1: + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_RECONNECTED, "Bot ReConnected to IRC") diff --git a/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py b/sopel_modules/SpiceBot_Core_Processing/Modules.py similarity index 50% rename from sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py rename to sopel_modules/SpiceBot_Core_Processing/Modules.py index 38d6ac2..7d998ed 100644 --- a/sopel_modules/SpiceBot_Module_Parsing/ModuleParsing.py +++ b/sopel_modules/SpiceBot_Core_Processing/Modules.py @@ -1,29 +1,21 @@ -# coding=utf-8 - +# coding=utf8 from __future__ import unicode_literals, absolute_import, division, print_function - +""" +This is the SpiceBot Channels system. +""" import sopel -import sopel.module import sopel_modules.SpiceBot as SpiceBot -def setup(bot): - SpiceBot.logs.log('SpiceBot_Commands', "Starting setup procedure") - SpiceBot.events.startup_add([SpiceBot.events.BOT_COMMANDSQUERY]) - - SpiceBot.commands.module_files_parse() - - for comtype in ['module', 'nickname', 'rule']: - SpiceBot.logs.log('SpiceBot_Commands', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) - - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_COMMANDSQUERY, "SpiceBot_Commands") - - @sopel.module.event(SpiceBot.events.BOT_LOADED) @sopel.module.rule('.*') def bot_events_complete(bot, trigger): + SpiceBot.events.startup_add([SpiceBot.events.BOT_COMMANDS]) + for comtype in SpiceBot.commands.dict['commands'].keys(): if comtype not in ['module', 'nickname', 'rule']: SpiceBot.logs.log('SpiceBot_Commands', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) + + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_COMMANDS, "SpiceBot_Commands") diff --git a/sopel_modules/SpiceBot_Core_Processing/__init__.py b/sopel_modules/SpiceBot_Core_Processing/__init__.py index 3901a3c..c0bc043 100644 --- a/sopel_modules/SpiceBot_Core_Processing/__init__.py +++ b/sopel_modules/SpiceBot_Core_Processing/__init__.py @@ -7,6 +7,8 @@ This module contains references only for other modules to utilize. """ from .Channels import * +from .Events import * +from .Modules import * __author__ = 'Sam Zick' diff --git a/sopel_modules/SpiceBot_Events/Connected.py b/sopel_modules/SpiceBot_Events/Connected.py deleted file mode 100644 index ecf81ac..0000000 --- a/sopel_modules/SpiceBot_Events/Connected.py +++ /dev/null @@ -1,16 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -@sopel.module.event(SpiceBot.events.BOT_WELCOME) -@sopel.module.rule('.*') -def bot_events_Connected(bot, trigger): - """Here, we wait until we are in at least one channel""" - while not len(bot.channels.keys()) > 0: - pass - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_CONNECTED, "Bot Connected to IRC") diff --git a/sopel_modules/SpiceBot_Events/Connection_Count.py b/sopel_modules/SpiceBot_Events/Connection_Count.py deleted file mode 100644 index 461ed8d..0000000 --- a/sopel_modules/SpiceBot_Events/Connection_Count.py +++ /dev/null @@ -1,15 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -@sopel.module.event(SpiceBot.events.RPL_WELCOME) -@sopel.module.rule('.*') -def bot_startup_welcome(bot, trigger): - SpiceBot.events.dict["RPL_WELCOME_Count"] += 1 - if SpiceBot.events.dict["RPL_WELCOME_Count"] > 1: - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_RECONNECTED, "Bot ReConnected to IRC") diff --git a/sopel_modules/SpiceBot_Events/Loaded.py b/sopel_modules/SpiceBot_Events/Loaded.py deleted file mode 100644 index 820c3b2..0000000 --- a/sopel_modules/SpiceBot_Events/Loaded.py +++ /dev/null @@ -1,15 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -@SpiceBot.events.startup_check_ready() -@sopel.module.event(SpiceBot.events.BOT_READY) -@sopel.module.rule('.*') -def bot_events_startup_complete(bot, trigger): - """All events registered as required for startup have completed""" - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_LOADED, "All registered modules setup procedures have completed") diff --git a/sopel_modules/SpiceBot_Events/Logging.py b/sopel_modules/SpiceBot_Events/Logging.py deleted file mode 100644 index 77c1fb8..0000000 --- a/sopel_modules/SpiceBot_Events/Logging.py +++ /dev/null @@ -1,14 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -@sopel.module.event(SpiceBot.events.BOT_WELCOME, SpiceBot.events.BOT_READY, SpiceBot.events.BOT_CONNECTED, SpiceBot.events.BOT_LOADED) -@sopel.module.rule('.*') -def bot_events_complete(bot, trigger): - """This is here simply to log to stderr that this was recieved.""" - SpiceBot.logs.log('SpiceBot_Events', trigger.args[1], True) diff --git a/sopel_modules/SpiceBot_Events/Queue.py b/sopel_modules/SpiceBot_Events/Queue.py deleted file mode 100644 index 68905c0..0000000 --- a/sopel_modules/SpiceBot_Events/Queue.py +++ /dev/null @@ -1,18 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -@sopel.module.event(SpiceBot.events.BOT_WELCOME) -@sopel.module.rule('.*') -def bot_events_connected(bot, trigger): - """For items tossed in a queue, this will trigger them accordingly""" - while True: - if len(SpiceBot.events.dict["trigger_queue"]): - pretriggerdict = SpiceBot.events.dict["trigger_queue"][0] - SpiceBot.events.dispatch(bot, pretriggerdict) - del SpiceBot.events.dict["trigger_queue"][0] diff --git a/sopel_modules/SpiceBot_Events/Ready.py b/sopel_modules/SpiceBot_Events/Ready.py deleted file mode 100644 index 9284475..0000000 --- a/sopel_modules/SpiceBot_Events/Ready.py +++ /dev/null @@ -1,14 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -@sopel.module.event(SpiceBot.events.BOT_WELCOME) -@sopel.module.rule('.*') -def bot_events_start(bot, trigger): - """This stage is redundant, but shows the system is working.""" - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_READY, "Ready To Process module setup procedures") diff --git a/sopel_modules/SpiceBot_Events/Welcome.py b/sopel_modules/SpiceBot_Events/Welcome.py deleted file mode 100644 index 27e3c3d..0000000 --- a/sopel_modules/SpiceBot_Events/Welcome.py +++ /dev/null @@ -1,17 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -@sopel.module.event(SpiceBot.events.RPL_WELCOME) -@sopel.module.rule('.*') -def bot_startup_welcome(bot, trigger): - """The Bot events system does not start until RPL_WELCOME 001 is recieved - from the server""" - if SpiceBot.events.check(SpiceBot.events.BOT_WELCOME): - return - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_WELCOME, "Welcome to the SpiceBot Events System") diff --git a/sopel_modules/SpiceBot_Events/__init__.py b/sopel_modules/SpiceBot_Events/__init__.py deleted file mode 100644 index e2846d8..0000000 --- a/sopel_modules/SpiceBot_Events/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf8 -from __future__ import unicode_literals, absolute_import, division, print_function - -from .Welcome import * -from .Ready import * -from .Connected import * -from .Loaded import * -from .Queue import * -from .Logging import * - -__author__ = 'Sam Zick' -__email__ = 'sam@deathbybandaid.net' -__version__ = '0.1.1' diff --git a/sopel_modules/SpiceBot_Module_Parsing/__init__.py b/sopel_modules/SpiceBot_Module_Parsing/__init__.py deleted file mode 100644 index 09f2208..0000000 --- a/sopel_modules/SpiceBot_Module_Parsing/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# coding=utf8 -"""Parse module file information -""" -from __future__ import unicode_literals, absolute_import, division, print_function - -from .ModuleParsing import * - -__author__ = 'Sam Zick' -__email__ = 'sam@deathbybandaid.net' -__version__ = '0.1.1' diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py index e5a490f..4f16db4 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py @@ -7,7 +7,7 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(SpiceBot.events.BOT_COMMANDSQUERY) +@sopel.module.event(SpiceBot.events.BOT_COMMANDS) @sopel.module.rule('.*') def bot_startup_monologue_commands(bot, trigger): From a172353c11b888e987fed3df678afe46410cf95a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 12:41:38 -0400 Subject: [PATCH 174/328] remove sillyness --- sopel_modules/SpiceBot_IRC_Logs/IRC_Events.py | 1266 ----------------- sopel_modules/SpiceBot_IRC_Logs/__init__.py | 8 - 2 files changed, 1274 deletions(-) delete mode 100644 sopel_modules/SpiceBot_IRC_Logs/IRC_Events.py delete mode 100644 sopel_modules/SpiceBot_IRC_Logs/__init__.py diff --git a/sopel_modules/SpiceBot_IRC_Logs/IRC_Events.py b/sopel_modules/SpiceBot_IRC_Logs/IRC_Events.py deleted file mode 100644 index 2eb4f73..0000000 --- a/sopel_modules/SpiceBot_IRC_Logs/IRC_Events.py +++ /dev/null @@ -1,1266 +0,0 @@ -#!/usr/bin/env python -# coding=utf-8 -from __future__ import unicode_literals, absolute_import, print_function, division - -# sopel imports -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -@sopel.module.event('NICK') -@sopel.module.rule('.*') -def parse_event_NICK(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -@sopel.module.event('QUIT') -@sopel.module.rule('.*') -def parse_event_QUIT(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -@sopel.module.event('PART') -def parse_event_PART(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -@sopel.module.event('MODE') -@sopel.module.rule('.*') -def parse_event_MODE(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -@sopel.module.event('KICK') -@sopel.module.rule('.*') -def parse_event_KICK(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -@sopel.module.event('JOIN') -@sopel.module.rule('.*') -def parse_event_JOIN(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -@sopel.module.event('INVITE') -@sopel.module.rule('.*') -def parse_event_INVITE(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -@sopel.module.event('TOPIC') -@sopel.module.rule('.*') -def parse_event_TOPIC(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_WELCOME = '001' -@sopel.module.event('001') -@sopel.module.rule('.*') -def parse_event_001(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_YOURHOST = '002' -@sopel.module.event('002') -@sopel.module.rule('.*') -def parse_event_002(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_CREATED = '003' -@sopel.module.event('003') -@sopel.module.rule('.*') -def parse_event_003(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_MYINFO = '004' -@sopel.module.event('004') -@sopel.module.rule('.*') -def parse_event_004(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_BOUNCE = '005' -@sopel.module.event('005') -@sopel.module.rule('.*') -def parse_event_005(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ISUPPORT = '005' -@sopel.module.event('005') -@sopel.module.rule('.*') -def parse_event_005b(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TRACELINK = '200' -@sopel.module.event('200') -@sopel.module.rule('.*') -def parse_event_200(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TRACECONNECTING = '201' -@sopel.module.event('201') -@sopel.module.rule('.*') -def parse_event_201(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TRACEHANDSHAKE = '202' -@sopel.module.event('202') -@sopel.module.rule('.*') -def parse_event_202(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TRACEUNKNOWN = '203' -@sopel.module.event('203') -@sopel.module.rule('.*') -def parse_event_203(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TRACEOPERATOR = '204' -@sopel.module.event('204') -@sopel.module.rule('.*') -def parse_event_204(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TRACEUSER = '205' -@sopel.module.event('205') -@sopel.module.rule('.*') -def parse_event_205(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TRACESERVER = '206' -@sopel.module.event('206') -@sopel.module.rule('.*') -def parse_event_206(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TRACESERVICE = '207' -@sopel.module.event('207') -@sopel.module.rule('.*') -def parse_event_207(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TRACENEWTYPE = '208' -@sopel.module.event('208') -@sopel.module.rule('.*') -def parse_event_208(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TRACECLASS = '209' -@sopel.module.event('209') -@sopel.module.rule('.*') -def parse_event_209(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TRACERECONNECT = '210' -@sopel.module.event('210') -@sopel.module.rule('.*') -def parse_event_210(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_STATSLINKINFO = '211' -@sopel.module.event('211') -@sopel.module.rule('.*') -def parse_event_211(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_STATSCOMMANDS = '212' -@sopel.module.event('212') -@sopel.module.rule('.*') -def parse_event_212(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_STATSCLINE = '213' -@sopel.module.event('213') -@sopel.module.rule('.*') -def parse_event_213(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_STATSNLINE = '214' -@sopel.module.event('214') -@sopel.module.rule('.*') -def parse_event_214(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_STATSILINE = '215' -@sopel.module.event('215') -@sopel.module.rule('.*') -def parse_event_215(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_STATSKLINE = '216' -@sopel.module.event('216') -@sopel.module.rule('.*') -def parse_event_216(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_STATSYLINE = '218' -@sopel.module.event('218') -@sopel.module.rule('.*') -def parse_event_218(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ENDOFSTATS = '219' -@sopel.module.event('219') -@sopel.module.rule('.*') -def parse_event_219(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_UMODEIS = '221' -@sopel.module.event('221') -@sopel.module.rule('.*') -def parse_event_221(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_SERVLIST = '234' -@sopel.module.event('234') -@sopel.module.rule('.*') -def parse_event_234(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_SERVLISTEND = '235' -@sopel.module.event('235') -@sopel.module.rule('.*') -def parse_event_235(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_STATSLLINE = '241' -@sopel.module.event('241') -@sopel.module.rule('.*') -def parse_event_241(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_STATSUPTIME = '242' -@sopel.module.event('242') -@sopel.module.rule('.*') -def parse_event_242(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_STATSOLINE = '243' -@sopel.module.event('243') -@sopel.module.rule('.*') -def parse_event_243(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_STATSHLINE = '244' -@sopel.module.event('244') -@sopel.module.rule('.*') -def parse_event_244(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_LUSERCLIENT = '251' -@sopel.module.event('251') -@sopel.module.rule('.*') -def parse_event_251(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_LUSEROP = '252' -@sopel.module.event('252') -@sopel.module.rule('.*') -def parse_event_252(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_LUSERUNKNOWN = '253' -@sopel.module.event('253') -@sopel.module.rule('.*') -def parse_event_253(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_LUSERCHANNELS = '254' -@sopel.module.event('254') -@sopel.module.rule('.*') -def parse_event_254(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_LUSERME = '255' -@sopel.module.event('255') -@sopel.module.rule('.*') -def parse_event_255(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ADMINME = '256' -@sopel.module.event('256') -@sopel.module.rule('.*') -def parse_event_256(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ADMINLOC1 = '257' -@sopel.module.event('257') -@sopel.module.rule('.*') -def parse_event_257(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ADMINLOC2 = '258' -@sopel.module.event('258') -@sopel.module.rule('.*') -def parse_event_258(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ADMINEMAIL = '259' -@sopel.module.event('259') -@sopel.module.rule('.*') -def parse_event_259(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TRACELOG = '261' -@sopel.module.event('261') -@sopel.module.rule('.*') -def parse_event_261(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TRACEEND = '262' -@sopel.module.event('262') -@sopel.module.rule('.*') -def parse_event_262(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TRYAGAIN = '263' -@sopel.module.event('263') -@sopel.module.rule('.*') -def parse_event_263(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_NONE = '300' -@sopel.module.event('300') -@sopel.module.rule('.*') -def parse_event_300(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_AWAY = '301' -@sopel.module.event('301') -@sopel.module.rule('.*') -def parse_event_301(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_USERHOST = '302' -@sopel.module.event('302') -@sopel.module.rule('.*') -def parse_event_302(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ISON = '303' -@sopel.module.event('303') -@sopel.module.rule('.*') -def parse_event_303(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_UNAWAY = '305' -@sopel.module.event('305') -@sopel.module.rule('.*') -def parse_event_305(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_NOWAWAY = '306' -@sopel.module.event('306') -@sopel.module.rule('.*') -def parse_event_306(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_WHOISUSER = '311' -@sopel.module.event('311') -@sopel.module.rule('.*') -def parse_event_311(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_WHOISSERVER = '312' -@sopel.module.event('312') -@sopel.module.rule('.*') -def parse_event_312(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_WHOISOPERATOR = '313' -@sopel.module.event('313') -@sopel.module.rule('.*') -def parse_event_313(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_WHOWASUSER = '314' -@sopel.module.event('314') -@sopel.module.rule('.*') -def parse_event_314(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ENDOFWHO = '315' -@sopel.module.event('315') -@sopel.module.rule('.*') -def parse_event_315(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_WHOISIDLE = '317' -@sopel.module.event('317') -@sopel.module.rule('.*') -def parse_event_317(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ENDOFWHOIS = '318' -@sopel.module.event('318') -@sopel.module.rule('.*') -def parse_event_318(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_WHOISCHANNELS = '319' -@sopel.module.event('319') -@sopel.module.rule('.*') -def parse_event_319(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_LISTSTART = '321' -@sopel.module.event('321') -@sopel.module.rule('.*') -def parse_event_321(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_LIST = '322' -@sopel.module.event('322') -@sopel.module.rule('.*') -def parse_event_322(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_LISTEND = '323' -@sopel.module.event('323') -@sopel.module.rule('.*') -def parse_event_323(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_CHANNELMODEIS = '324' -@sopel.module.event('324') -@sopel.module.rule('.*') -def parse_event_324(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_UNIQOPIS = '325' -@sopel.module.event('325') -@sopel.module.rule('.*') -def parse_event_325(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_NOTOPIC = '331' -@sopel.module.event('331') -@sopel.module.rule('.*') -def parse_event_331(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TOPIC = '332' -@sopel.module.event('332') -@sopel.module.rule('.*') -def parse_event_332(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_INVITING = '341' -@sopel.module.event('341') -@sopel.module.rule('.*') -def parse_event_341(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_SUMMONING = '342' -@sopel.module.event('342') -@sopel.module.rule('.*') -def parse_event_342(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_INVITELIST = '346' -@sopel.module.event('346') -@sopel.module.rule('.*') -def parse_event_346(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ENDOFINVITELIST = '347' -@sopel.module.event('347') -@sopel.module.rule('.*') -def parse_event_347(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_EXCEPTLIST = '348' -@sopel.module.event('348') -@sopel.module.rule('.*') -def parse_event_348(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ENDOFEXCEPTLIST = '349' -@sopel.module.event('349') -@sopel.module.rule('.*') -def parse_event_349(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_VERSION = '351' -@sopel.module.event('351') -@sopel.module.rule('.*') -def parse_event_351(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_WHOREPLY = '352' -@sopel.module.event('352') -@sopel.module.rule('.*') -def parse_event_352(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_NAMREPLY = '353' -@sopel.module.event('353') -@sopel.module.rule('.*') -def parse_event_353(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_WHOSPCRPL = '354' -@sopel.module.event('354') -@sopel.module.rule('.*') -def parse_event_354(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_LINKS = '364' -@sopel.module.event('364') -@sopel.module.rule('.*') -def parse_event_364(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ENDOFLINKS = '365' -@sopel.module.event('365') -@sopel.module.rule('.*') -def parse_event_365(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ENDOFNAMES = '366' -@sopel.module.event('366') -@sopel.module.rule('.*') -def parse_event_366(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_BANLIST = '367' -@sopel.module.event('367') -@sopel.module.rule('.*') -def parse_event_367(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ENDOFBANLIST = '368' -@sopel.module.event('368') -@sopel.module.rule('.*') -def parse_event_368(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ENDOFWHOWAS = '369' -@sopel.module.event('369') -@sopel.module.rule('.*') -def parse_event_369(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_INFO = '371' -@sopel.module.event('371') -@sopel.module.rule('.*') -def parse_event_371(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_MOTD = '372' -@sopel.module.event('372') -@sopel.module.rule('.*') -def parse_event_372(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ENDOFINFO = '374' -@sopel.module.event('374') -@sopel.module.rule('.*') -def parse_event_374(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_MOTDSTART = '375' -@sopel.module.event('375') -@sopel.module.rule('.*') -def parse_event_375(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ENDOFMOTD = '376' -@sopel.module.event('376') -@sopel.module.rule('.*') -def parse_event_376(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_YOUREOPER = '381' -@sopel.module.event('381') -@sopel.module.rule('.*') -def parse_event_381(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_REHASHING = '382' -@sopel.module.event('382') -@sopel.module.rule('.*') -def parse_event_382(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_YOURESERVICE = '383' -@sopel.module.event('383') -@sopel.module.rule('.*') -def parse_event_383(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_TIME = '391' -@sopel.module.event('391') -@sopel.module.rule('.*') -def parse_event_391(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_USERSSTART = '392' -@sopel.module.event('392') -@sopel.module.rule('.*') -def parse_event_392(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_USERS = '393' -@sopel.module.event('393') -@sopel.module.rule('.*') -def parse_event_393(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ENDOFUSERS = '394' -@sopel.module.event('394') -@sopel.module.rule('.*') -def parse_event_394(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_NOUSERS = '395' -@sopel.module.event('395') -@sopel.module.rule('.*') -def parse_event_395(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOSUCHNICK = '401' -@sopel.module.event('401') -@sopel.module.rule('.*') -def parse_event_401(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOSUCHSERVER = '402' -@sopel.module.event('402') -@sopel.module.rule('.*') -def parse_event_402(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOSUCHCHANNEL = '403' -@sopel.module.event('403') -@sopel.module.rule('.*') -def parse_event_403(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_CANNOTSENDTOCHAN = '404' -@sopel.module.event('404') -@sopel.module.rule('.*') -def parse_event_404(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_TOOMANYCHANNELS = '405' -@sopel.module.event('405') -@sopel.module.rule('.*') -def parse_event_405(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_WASNOSUCHNICK = '406' -@sopel.module.event('406') -@sopel.module.rule('.*') -def parse_event_406(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_TOOMANYTARGETS = '407' -@sopel.module.event('407') -@sopel.module.rule('.*') -def parse_event_407(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOSUCHSERVICE = '408' -@sopel.module.event('408') -@sopel.module.rule('.*') -def parse_event_408(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOORIGIN = '409' -@sopel.module.event('409') -@sopel.module.rule('.*') -def parse_event_409(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_INVALIDCAPCMD = '410' -@sopel.module.event('410') -@sopel.module.rule('.*') -def parse_event_410(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NORECIPIENT = '411' -@sopel.module.event('411') -@sopel.module.rule('.*') -def parse_event_411(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOTEXTTOSEND = '412' -@sopel.module.event('412') -@sopel.module.rule('.*') -def parse_event_412(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOTOPLEVEL = '413' -@sopel.module.event('413') -@sopel.module.rule('.*') -def parse_event_413(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_WILDTOPLEVEL = '414' -@sopel.module.event('414') -@sopel.module.rule('.*') -def parse_event_414(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_BADMASK = '415' -@sopel.module.event('415') -@sopel.module.rule('.*') -def parse_event_415(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_UNKNOWNCOMMAND = '421' -@sopel.module.event('421') -@sopel.module.rule('.*') -def parse_event_421(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOMOTD = '422' -@sopel.module.event('422') -@sopel.module.rule('.*') -def parse_event_422(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOADMININFO = '423' -@sopel.module.event('423') -@sopel.module.rule('.*') -def parse_event_423(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_FILEERROR = '424' -@sopel.module.event('424') -@sopel.module.rule('.*') -def parse_event_424(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NONICKNAMEGIVEN = '431' -@sopel.module.event('431') -@sopel.module.rule('.*') -def parse_event_431(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_ERRONEUSNICKNAME = '432' -@sopel.module.event('432') -@sopel.module.rule('.*') -def parse_event_432(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NICKNAMEINUSE = '433' -@sopel.module.event('433') -@sopel.module.rule('.*') -def parse_event_433(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NICKCOLLISION = '436' -@sopel.module.event('436') -@sopel.module.rule('.*') -def parse_event_436(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_UNAVAILRESOURCE = '437' -@sopel.module.event('437') -@sopel.module.rule('.*') -def parse_event_437(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_USERNOTINCHANNEL = '441' -@sopel.module.event('441') -@sopel.module.rule('.*') -def parse_event_441(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOTONCHANNEL = '442' -@sopel.module.event('442') -@sopel.module.rule('.*') -def parse_event_442(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_USERONCHANNEL = '443' -@sopel.module.event('443') -@sopel.module.rule('.*') -def parse_event_443(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOLOGIN = '444' -@sopel.module.event('444') -@sopel.module.rule('.*') -def parse_event_444(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_SUMMONDISABLED = '445' -@sopel.module.event('445') -@sopel.module.rule('.*') -def parse_event_445(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_USERSDISABLED = '446' -@sopel.module.event('446') -@sopel.module.rule('.*') -def parse_event_446(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOTREGISTERED = '451' -@sopel.module.event('451') -@sopel.module.rule('.*') -def parse_event_451(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NEEDMOREPARAMS = '461' -@sopel.module.event('461') -@sopel.module.rule('.*') -def parse_event_461(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_ALREADYREGISTRED = '462' -@sopel.module.event('462') -@sopel.module.rule('.*') -def parse_event_462(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOPERMFORHOST = '463' -@sopel.module.event('463') -@sopel.module.rule('.*') -def parse_event_463(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_PASSWDMISMATCH = '464' -@sopel.module.event('464') -@sopel.module.rule('.*') -def parse_event_464(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_YOUREBANNEDCREEP = '465' -@sopel.module.event('465') -@sopel.module.rule('.*') -def parse_event_465(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_YOUWILLBEBANNED = '466' -@sopel.module.event('466') -@sopel.module.rule('.*') -def parse_event_466(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_KEYSET = '467' -@sopel.module.event('467') -@sopel.module.rule('.*') -def parse_event_467(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_CHANNELISFULL = '471' -@sopel.module.event('471') -@sopel.module.rule('.*') -def parse_event_471(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_UNKNOWNMODE = '472' -@sopel.module.event('472') -@sopel.module.rule('.*') -def parse_event_472(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_INVITEONLYCHAN = '473' -@sopel.module.event('473') -@sopel.module.rule('.*') -def parse_event_473(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_BANNEDFROMCHAN = '474' -@sopel.module.event('474') -@sopel.module.rule('.*') -def parse_event_474(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_BADCHANNELKEY = '475' -@sopel.module.event('475') -@sopel.module.rule('.*') -def parse_event_475(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_BADCHANMASK = '476' -@sopel.module.event('476') -@sopel.module.rule('.*') -def parse_event_476(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOCHANMODES = '477' -@sopel.module.event('477') -@sopel.module.rule('.*') -def parse_event_477(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_BANLISTFULL = '478' -@sopel.module.event('478') -@sopel.module.rule('.*') -def parse_event_478(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOPRIVILEGES = '481' -@sopel.module.event('481') -@sopel.module.rule('.*') -def parse_event_481(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_CHANOPRIVSNEEDED = '482' -@sopel.module.event('482') -@sopel.module.rule('.*') -def parse_event_482(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_CANTKILLSERVER = '483' -@sopel.module.event('483') -@sopel.module.rule('.*') -def parse_event_483(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_RESTRICTED = '484' -@sopel.module.event('484') -@sopel.module.rule('.*') -def parse_event_484(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_UNIQOPPRIVSNEEDED = '485' -@sopel.module.event('485') -@sopel.module.rule('.*') -def parse_event_485(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOOPERHOST = '491' -@sopel.module.event('491') -@sopel.module.rule('.*') -def parse_event_491(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_UMODEUNKNOWNFLAG = '501' -@sopel.module.event('501') -@sopel.module.rule('.*') -def parse_event_501(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_USERSDONTMATCH = '502' -@sopel.module.event('502') -@sopel.module.rule('.*') -def parse_event_502(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_STARTTLS = '670' -@sopel.module.event('670') -@sopel.module.rule('.*') -def parse_event_670(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_STARTTLS = '691' -@sopel.module.event('691') -@sopel.module.rule('.*') -def parse_event_691(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_MONONLINE = '730' -@sopel.module.event('730') -@sopel.module.rule('.*') -def parse_event_730(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_MONOFFLINE = '731' -@sopel.module.event('731') -@sopel.module.rule('.*') -def parse_event_731(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_MONLIST = '732' -@sopel.module.event('732') -@sopel.module.rule('.*') -def parse_event_732(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_ENDOFMONLIST = '733' -@sopel.module.event('733') -@sopel.module.rule('.*') -def parse_event_733(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_MONLISTFULL = '734' -@sopel.module.event('734') -@sopel.module.rule('.*') -def parse_event_734(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_WHOISKEYVALUE = '760' -@sopel.module.event('760') -@sopel.module.rule('.*') -def parse_event_760(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_KEYVALUE = '761' -@sopel.module.event('761') -@sopel.module.rule('.*') -def parse_event_761(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_METADATAEND = '762' -@sopel.module.event('762') -@sopel.module.rule('.*') -def parse_event_762(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_METADATALIMIT = '764' -@sopel.module.event('764') -@sopel.module.rule('.*') -def parse_event_764(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_TARGETINVALID = '765' -@sopel.module.event('765') -@sopel.module.rule('.*') -def parse_event_765(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NOMATCHINGKEY = '766' -@sopel.module.event('766') -@sopel.module.rule('.*') -def parse_event_766(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_KEYINVALID = '767' -@sopel.module.event('767') -@sopel.module.rule('.*') -def parse_event_767(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_KEYNOTSET = '768' -@sopel.module.event('768') -@sopel.module.rule('.*') -def parse_event_768(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_KEYNOPERMISSION = '769' -@sopel.module.event('769') -@sopel.module.rule('.*') -def parse_event_769(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_LOGGEDIN = '900' -@sopel.module.event('900') -@sopel.module.rule('.*') -def parse_event_900(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_LOGGEDOUT = '901' -@sopel.module.event('901') -@sopel.module.rule('.*') -def parse_event_901(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_NICKLOCKED = '902' -@sopel.module.event('902') -@sopel.module.rule('.*') -def parse_event_902(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_SASLSUCCESS = '903' -@sopel.module.event('903') -@sopel.module.rule('.*') -def parse_event_903(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_SASLFAIL = '904' -@sopel.module.event('904') -@sopel.module.rule('.*') -def parse_event_904(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_SASLTOOLONG = '905' -@sopel.module.event('905') -@sopel.module.rule('.*') -def parse_event_905(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_SASLABORTED = '906' -@sopel.module.event('906') -@sopel.module.rule('.*') -def parse_event_906(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# ERR_SASLALREADY = '907' -@sopel.module.event('907') -@sopel.module.rule('.*') -def parse_event_907(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) - - -# RPL_SASLMECHS = '908' -@sopel.module.event('908') -@sopel.module.rule('.*') -def parse_event_908(bot, trigger): - SpiceBot.logs.log('SpiceBot_Logs_IRC', str(trigger.event) + " " + str(trigger.args)) diff --git a/sopel_modules/SpiceBot_IRC_Logs/__init__.py b/sopel_modules/SpiceBot_IRC_Logs/__init__.py deleted file mode 100644 index 932b488..0000000 --- a/sopel_modules/SpiceBot_IRC_Logs/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# coding=utf8 -from __future__ import unicode_literals, absolute_import, division, print_function - -from .IRC_Events import * - -__author__ = 'Sam Zick' -__email__ = 'sam@deathbybandaid.net' -__version__ = '0.1.1' From 219b9076b8797b8f9e327db1aebd677547646281 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 12:49:18 -0400 Subject: [PATCH 175/328] config fix --- sopel_modules/SpiceBot_Core_Processing/Channels.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot_Core_Processing/Channels.py b/sopel_modules/SpiceBot_Core_Processing/Channels.py index f3ae10b..927b513 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Channels.py +++ b/sopel_modules/SpiceBot_Core_Processing/Channels.py @@ -15,7 +15,7 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.event(SpiceBot.events.RPL_WELCOME) @sopel.module.rule('.*') def unkickable_bot(bot, trigger): - if bot.config.SpiceBot_SpiceBot.channels.operadmin: + if SpiceBot.config.SpiceBot_Channels.operadmin: bot.write(('SAMODE', bot.nick, '+q')) @@ -85,7 +85,7 @@ def trigger_channel_list_recurring(bot, trigger): newlist = [item.lower() for item in oldlist if item.lower() not in list(SpiceBot.channels.dict['list'].keys())] if "*" in newlist: newlist.remove("*") - if len(newlist) and bot.config.SpiceBot_SpiceBot.channels.announcenew: + if len(newlist) and SpiceBot.config.SpiceBot_Channels.announcenew: bot.osd(["The Following channel(s) are new:", spicemanip.main(newlist, 'andlist')], bot.channels.keys()) SpiceBot.channels.join_all_channels(bot) From 73101943d29a86eea0b10a87f4ecb5312354e66d Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 13:09:14 -0400 Subject: [PATCH 176/328] log it --- sopel_modules/SpiceBot/Events.py | 5 ++++- sopel_modules/SpiceBot_Core_Processing/Events.py | 9 +-------- sopel_modules/SpiceBot_Core_Processing/Modules.py | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/sopel_modules/SpiceBot/Events.py b/sopel_modules/SpiceBot/Events.py index 189cbe2..8d8e031 100644 --- a/sopel_modules/SpiceBot/Events.py +++ b/sopel_modules/SpiceBot/Events.py @@ -85,7 +85,10 @@ class BotEvents(object): else: eventnumber = str(trigger.event) message = trigger.args[1] - logs.log('SpiceBot_Events', str(eventnumber) + " " + str(message)) + if int(eventnumber) in self.defaultevents: + logs.log('SpiceBot_Events', str(eventnumber) + " " + str(message), True) + else: + logs.log('SpiceBot_Events', str(eventnumber) + " " + str(message)) if eventnumber not in self.dict["triggers_recieved"]: self.dict["triggers_recieved"][eventnumber] = [] self.dict["triggers_recieved"][eventnumber].append(message) diff --git a/sopel_modules/SpiceBot_Core_Processing/Events.py b/sopel_modules/SpiceBot_Core_Processing/Events.py index 422e493..5b8214c 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Events.py +++ b/sopel_modules/SpiceBot_Core_Processing/Events.py @@ -1,7 +1,7 @@ # coding=utf8 from __future__ import unicode_literals, absolute_import, division, print_function """ -This is the SpiceBot Channels system. +This is the SpiceBot Events system. """ import sopel @@ -19,13 +19,6 @@ def bot_events_connected(bot, trigger): del SpiceBot.events.dict["trigger_queue"][0] -@sopel.module.event(SpiceBot.events.BOT_WELCOME, SpiceBot.events.BOT_READY, SpiceBot.events.BOT_CONNECTED, SpiceBot.events.BOT_LOADED) -@sopel.module.rule('.*') -def bot_events_complete(bot, trigger): - """This is here simply to log to stderr that this was recieved.""" - SpiceBot.logs.log('SpiceBot_Events', trigger.args[1], True) - - @sopel.module.event(SpiceBot.events.RPL_WELCOME) @sopel.module.rule('.*') def bot_startup_welcome(bot, trigger): diff --git a/sopel_modules/SpiceBot_Core_Processing/Modules.py b/sopel_modules/SpiceBot_Core_Processing/Modules.py index 7d998ed..d8ccace 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Modules.py +++ b/sopel_modules/SpiceBot_Core_Processing/Modules.py @@ -1,7 +1,7 @@ # coding=utf8 from __future__ import unicode_literals, absolute_import, division, print_function """ -This is the SpiceBot Channels system. +This is the SpiceBot Modules system. """ import sopel From 4642d784e4050f138e81a443793aa58abb119e27 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 13:19:56 -0400 Subject: [PATCH 177/328] test --- .../SpiceBot_Core_Processing/Events.py | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/sopel_modules/SpiceBot_Core_Processing/Events.py b/sopel_modules/SpiceBot_Core_Processing/Events.py index 5b8214c..279fa11 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Events.py +++ b/sopel_modules/SpiceBot_Core_Processing/Events.py @@ -8,9 +8,17 @@ import sopel import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(SpiceBot.events.BOT_WELCOME) +@sopel.module.event(SpiceBot.events.RPL_WELCOME) @sopel.module.rule('.*') def bot_events_connected(bot, trigger): + + # Handling for connection count + SpiceBot.events.dict["RPL_WELCOME_Count"] += 1 + if SpiceBot.events.dict["RPL_WELCOME_Count"] > 1: + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_RECONNECTED, "Bot ReConnected to IRC") + else: + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_WELCOME, "Welcome to the SpiceBot Events System") + """For items tossed in a queue, this will trigger them accordingly""" while True: if len(SpiceBot.events.dict["trigger_queue"]): @@ -19,26 +27,12 @@ def bot_events_connected(bot, trigger): del SpiceBot.events.dict["trigger_queue"][0] -@sopel.module.event(SpiceBot.events.RPL_WELCOME) -@sopel.module.rule('.*') -def bot_startup_welcome(bot, trigger): - """The Bot events system does not start until RPL_WELCOME 001 is recieved - from the server""" - if SpiceBot.events.check(SpiceBot.events.BOT_WELCOME): - return - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_WELCOME, "Welcome to the SpiceBot Events System") - - @sopel.module.event(SpiceBot.events.BOT_WELCOME) @sopel.module.rule('.*') def bot_events_start(bot, trigger): """This stage is redundant, but shows the system is working.""" SpiceBot.events.trigger(bot, SpiceBot.events.BOT_READY, "Ready To Process module setup procedures") - -@sopel.module.event(SpiceBot.events.BOT_WELCOME) -@sopel.module.rule('.*') -def bot_events_Connected(bot, trigger): """Here, we wait until we are in at least one channel""" while not len(bot.channels.keys()) > 0: pass @@ -51,11 +45,3 @@ def bot_events_Connected(bot, trigger): def bot_events_startup_complete(bot, trigger): """All events registered as required for startup have completed""" SpiceBot.events.trigger(bot, SpiceBot.events.BOT_LOADED, "All registered modules setup procedures have completed") - - -@sopel.module.event(SpiceBot.events.RPL_WELCOME) -@sopel.module.rule('.*') -def bot_startup_reconnect(bot, trigger): - SpiceBot.events.dict["RPL_WELCOME_Count"] += 1 - if SpiceBot.events.dict["RPL_WELCOME_Count"] > 1: - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_RECONNECTED, "Bot ReConnected to IRC") From 9ddcc55ab2f3a0d3127028ee7404002dc097f990 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 13:28:09 -0400 Subject: [PATCH 178/328] test --- sopel_modules/SpiceBot/Update.py | 12 ++++++ sopel_modules/SpiceBot/__init__.py | 2 + sopel_modules/SpiceBot/configure.py | 5 +++ sopel_modules/SpiceBot/setup.py | 8 +++- .../Runtime_Controls.py} | 37 ++++++++----------- .../SpiceBot_Core_Commands/__init__.py | 1 + sopel_modules/SpiceBot_Restart/Restart.py | 22 ----------- sopel_modules/SpiceBot_Restart/__init__.py | 6 --- sopel_modules/SpiceBot_Update/__init__.py | 6 --- 9 files changed, 42 insertions(+), 57 deletions(-) create mode 100644 sopel_modules/SpiceBot/Update.py rename sopel_modules/{SpiceBot_Update/Update.py => SpiceBot_Core_Commands/Runtime_Controls.py} (55%) delete mode 100644 sopel_modules/SpiceBot_Restart/Restart.py delete mode 100644 sopel_modules/SpiceBot_Restart/__init__.py delete mode 100644 sopel_modules/SpiceBot_Update/__init__.py diff --git a/sopel_modules/SpiceBot/Update.py b/sopel_modules/SpiceBot/Update.py new file mode 100644 index 0000000..227f5fd --- /dev/null +++ b/sopel_modules/SpiceBot/Update.py @@ -0,0 +1,12 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot Update system. +""" + +from sopel.config.types import StaticSection, ValidatedAttribute + + +class SpiceBot_Update_MainSection(StaticSection): + gitrepo = ValidatedAttribute('gitrepo', default="https://github.com/SpiceBot/SpiceBot") + gitbranch = ValidatedAttribute('gitbranch', default="master") diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index 9db085a..36c526c 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -9,6 +9,8 @@ This module contains references only for other modules to utilize. from .configure import * from .setup import * +from .Update import * + from .Config import * from .Tools import * from .Prerun import * diff --git a/sopel_modules/SpiceBot/configure.py b/sopel_modules/SpiceBot/configure.py index 3b8a30a..5edacc9 100644 --- a/sopel_modules/SpiceBot/configure.py +++ b/sopel_modules/SpiceBot/configure.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi """Configuration for SpiceBot""" from .Channels import SpiceBot_Channels_MainSection +from .Update import SpiceBot_Update_MainSection def configure(config): @@ -12,3 +13,7 @@ def configure(config): config.SpiceBot_Channels.configure_setting('joinall', 'SpiceBot_Channels JOIN New Channels') config.SpiceBot_Channels.configure_setting('operadmin', 'SpiceBot_Channels OPER ADMIN MODE') config.SpiceBot_Channels.configure_setting('chanignore', 'SpiceBot_Channels Ignore JOIN for channels') + + config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) + config.SpiceBot_Update.configure_setting('gitrepo', 'SpiceBot_Update git repo to install') + config.SpiceBot_Update.configure_setting('gitbranch', 'SpiceBot_Update git branch to install') diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index 0ab7baa..b62092b 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -4,9 +4,11 @@ from __future__ import unicode_literals, absolute_import, division, print_functi import os +from .Config import config as botconfig from .Logs import logs from .Channels import SpiceBot_Channels_MainSection +from .Update import SpiceBot_Update_MainSection def setup(bot): @@ -20,7 +22,9 @@ def setup(bot): bot.config.core.logs_raw = os.path.join(bot.config.core.logdir, 'raw.log') # bot.config.core.logs_raw = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.raw.log') - # logs.log('SpiceBot_Logs', "Setting Up Configuration") - logs.log('SpiceBot_Channels', "Setting Up Configuration") bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) + + logs.log('SpiceBot_Update', "Initial Setup processing") + bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) + botconfig.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) diff --git a/sopel_modules/SpiceBot_Update/Update.py b/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py similarity index 55% rename from sopel_modules/SpiceBot_Update/Update.py rename to sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py index cd8424d..ec4d8e0 100644 --- a/sopel_modules/SpiceBot_Update/Update.py +++ b/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py @@ -1,33 +1,14 @@ -#!/usr/bin/env python # coding=utf-8 -from __future__ import unicode_literals, absolute_import, print_function, division -# sopel imports +from __future__ import unicode_literals, absolute_import, division, print_function + import sopel.module -from sopel.config.types import StaticSection, ValidatedAttribute import spicemanip import sopel_modules.SpiceBot as SpiceBot -class SpiceBot_Update_MainSection(StaticSection): - gitrepo = ValidatedAttribute('gitrepo', default="https://github.com/SpiceBot/SpiceBot") - gitbranch = ValidatedAttribute('gitbranch', default="master") - - -def configure(config): - config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) - config.SpiceBot_Update.configure_setting('gitrepo', 'SpiceBot_Update git repo to install') - config.SpiceBot_Update.configure_setting('gitbranch', 'SpiceBot_Update git branch to install') - - -def setup(bot): - SpiceBot.logs.log('SpiceBot_Update', "Initial Setup processing") - bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) - SpiceBot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) - - @SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('update') def nickname_comand_update(bot, trigger): @@ -58,3 +39,17 @@ def nickname_comand_update(bot, trigger): # service_manip(bot.nick, 'restart', 'SpiceBot_Update') SpiceBot.spicebot_reload(bot, 'SpiceBot_Update', quitmessage) + + +@sopel.module.nickname_commands('restart') +def nickname_comand_restart(bot, trigger): + + if not trigger.admin: + bot.osd("You are not authorized to perform this function.") + + quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!" + SpiceBot.logs.log('SpiceBot_Restart', quitmessage) + bot.osd(quitmessage, bot.channels.keys()) + + # service_manip(bot.nick, 'restart', 'SpiceBot_Restart') + SpiceBot.spicebot_reload(bot, 'SpiceBot_Restart', quitmessage) diff --git a/sopel_modules/SpiceBot_Core_Commands/__init__.py b/sopel_modules/SpiceBot_Core_Commands/__init__.py index f686aba..8858604 100644 --- a/sopel_modules/SpiceBot_Core_Commands/__init__.py +++ b/sopel_modules/SpiceBot_Core_Commands/__init__.py @@ -10,6 +10,7 @@ from .Commands import * from .Channels import * from .Database import * from .Uptime import * +from .Runtime_Controls import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' diff --git a/sopel_modules/SpiceBot_Restart/Restart.py b/sopel_modules/SpiceBot_Restart/Restart.py deleted file mode 100644 index f3f255d..0000000 --- a/sopel_modules/SpiceBot_Restart/Restart.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python -# coding=utf-8 -from __future__ import unicode_literals, absolute_import, print_function, division - -# sopel imports -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -@sopel.module.nickname_commands('restart') -def nickname_comand_restart(bot, trigger): - - if not trigger.admin: - bot.osd("You are not authorized to perform this function.") - - quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!" - SpiceBot.logs.log('SpiceBot_Restart', quitmessage) - bot.osd(quitmessage, bot.channels.keys()) - - # service_manip(bot.nick, 'restart', 'SpiceBot_Restart') - SpiceBot.spicebot_reload(bot, 'SpiceBot_Restart', quitmessage) diff --git a/sopel_modules/SpiceBot_Restart/__init__.py b/sopel_modules/SpiceBot_Restart/__init__.py deleted file mode 100644 index 8bda139..0000000 --- a/sopel_modules/SpiceBot_Restart/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# coding=utf-8 -"""Event Parsing from IRC -""" -from __future__ import unicode_literals, absolute_import, print_function, division - -from .Restart import * diff --git a/sopel_modules/SpiceBot_Update/__init__.py b/sopel_modules/SpiceBot_Update/__init__.py deleted file mode 100644 index a2667e1..0000000 --- a/sopel_modules/SpiceBot_Update/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# coding=utf-8 -"""Event Parsing from IRC -""" -from __future__ import unicode_literals, absolute_import, print_function, division - -from .Update import * From 263f61cd8ec085c38e9acc3b538bb5cb1703334e Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 13:39:50 -0400 Subject: [PATCH 179/328] osd --- sopel_modules/SpiceBot/__init__.py | 1 + sopel_modules/SpiceBot/configure.py | 10 +++ .../__init__.py => SpiceBot/osd.py} | 73 +------------------ sopel_modules/SpiceBot/setup.py | 17 +++++ .../SpiceBot_Core_Processing/__init__.py | 1 + sopel_modules/SpiceBot_Core_Processing/osd.py | 31 ++++++++ 6 files changed, 64 insertions(+), 69 deletions(-) rename sopel_modules/{SpiceBot_osd/__init__.py => SpiceBot/osd.py} (79%) create mode 100644 sopel_modules/SpiceBot_Core_Processing/osd.py diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index 36c526c..797e4d2 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -10,6 +10,7 @@ from .configure import * from .setup import * from .Update import * +from .osd import * from .Config import * from .Tools import * diff --git a/sopel_modules/SpiceBot/configure.py b/sopel_modules/SpiceBot/configure.py index 5edacc9..94e2000 100644 --- a/sopel_modules/SpiceBot/configure.py +++ b/sopel_modules/SpiceBot/configure.py @@ -4,10 +4,20 @@ from __future__ import unicode_literals, absolute_import, division, print_functi from .Channels import SpiceBot_Channels_MainSection from .Update import SpiceBot_Update_MainSection +from .osd import SpiceBot_OSD def configure(config): + config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) + config.SpiceBot_OSD.configure_setting('notice', 'MAXTARG limit for NOTICE') + config.SpiceBot_OSD.configure_setting('privmsg', 'MAXTARG limit for PRIVMSG') + config.SpiceBot_OSD.configure_setting('flood_burst_lines', 'How many messages can be sent in burst mode.') + config.SpiceBot_OSD.configure_setting('flood_empty_wait', 'How long to wait between sending messages when not in burst mode, in seconds.') + config.SpiceBot_OSD.configure_setting('flood_refill_rate', 'How quickly burst mode recovers, in messages per second.') + config.SpiceBot_OSD.configure_setting('flood_throttle', 'Whether messages will be throttled if too many are sent in a short time.') + config.SpiceBot_OSD.configure_setting('flood_dots', "Whether repeated messages will be replaced with '...', then dropped.") + config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) config.SpiceBot_Channels.configure_setting('announcenew', 'SpiceBot_Channels Announce New Channels') config.SpiceBot_Channels.configure_setting('joinall', 'SpiceBot_Channels JOIN New Channels') diff --git a/sopel_modules/SpiceBot_osd/__init__.py b/sopel_modules/SpiceBot/osd.py similarity index 79% rename from sopel_modules/SpiceBot_osd/__init__.py rename to sopel_modules/SpiceBot/osd.py index b8529b9..99eb137 100644 --- a/sopel_modules/SpiceBot_osd/__init__.py +++ b/sopel_modules/SpiceBot/osd.py @@ -1,83 +1,18 @@ # coding=utf8 -"""Sopel OSD - -Sopel OSD is a "niche" method of displaying text in a Sopel bot +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot OSD system. """ -# pylama:ignore=W0611 - - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.bot -from sopel import tools, module +from sopel import tools from sopel.tools import Identifier from sopel.config.types import StaticSection, ValidatedAttribute -import sopel_modules.SpiceBot as SpiceBot - import time from collections import abc import sys -__author__ = 'Sam Zick' -__email__ = 'sam@deathbybandaid.net' -__version__ = '0.1.2' - - -def configure(config): - config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) - config.SpiceBot_OSD.configure_setting('notice', 'MAXTARG limit for NOTICE') - config.SpiceBot_OSD.configure_setting('privmsg', 'MAXTARG limit for PRIVMSG') - config.SpiceBot_OSD.configure_setting('flood_burst_lines', 'How many messages can be sent in burst mode.') - config.SpiceBot_OSD.configure_setting('flood_empty_wait', 'How long to wait between sending messages when not in burst mode, in seconds.') - config.SpiceBot_OSD.configure_setting('flood_refill_rate', 'How quickly burst mode recovers, in messages per second.') - config.SpiceBot_OSD.configure_setting('flood_throttle', 'Whether messages will be throttled if too many are sent in a short time.') - config.SpiceBot_OSD.configure_setting('flood_dots', "Whether repeated messages will be replaced with '...', then dropped.") - - -def setup(bot): - - # Inject OSD - SpiceBot.logs.log('SpiceBot_OSD', "Implanting OSD function into bot") - bot.osd = SopelOSD.osd - sopel.bot.SopelWrapper.osd = SopelWrapperOSD.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 - - # verify config settings for server - SpiceBot.logs.log('SpiceBot_OSD', "Checking for config settings") - bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) - SpiceBot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) - - -@module.event('005') -@module.rule('.*') -def parse_event_005(bot, trigger): - if trigger.args[-1] != 'are supported by this server': - return - parameters = trigger.args[1:-1] - for param in parameters: - if '=' in param: - if param.startswith("TARGMAX"): - param = str(param).split('=')[1] - settings = str(param).split(',') - for setting in settings: - settingname = str(setting).split(':')[0] - if settingname.upper() in ['NOTICE', 'PRIVMSG']: - try: - value = str(setting).split(':')[1] or None - except IndexError: - value = None - if value: - if settingname.upper() == 'NOTICE': - bot.config.SpiceBot_OSD.notice = int(value) - elif settingname.upper() == 'PRIVMSG': - bot.config.SpiceBot_OSD.privmsg = int(value) - - class SpiceBot_OSD(StaticSection): """MAXTARG""" diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index b62092b..acd7f95 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -2,6 +2,9 @@ from __future__ import unicode_literals, absolute_import, division, print_function """Setup for SpiceBot""" +import sopel.bot +from sopel import tools + import os from .Config import config as botconfig @@ -9,10 +12,24 @@ from .Logs import logs from .Channels import SpiceBot_Channels_MainSection from .Update import SpiceBot_Update_MainSection +from .osd import SopelWrapperOSD, ToolsOSD, SopelOSD, SpiceBot_OSD def setup(bot): + # Inject OSD + logs.log('SpiceBot_OSD', "Implanting OSD function into bot") + bot.osd = SopelOSD.osd + sopel.bot.SopelWrapper.osd = SopelWrapperOSD.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 + + # verify config settings for server + logs.log('SpiceBot_OSD', "Checking for config settings") + bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) + botconfig.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) + logs.log('SpiceBot_Config', "Setting Up Configuration") bot.config.core.basename = os.path.basename(bot.config.filename).rsplit('.', 1)[0] bot.config.core.logs_stdio = os.path.join(bot.config.core.logdir, 'stdio.log') diff --git a/sopel_modules/SpiceBot_Core_Processing/__init__.py b/sopel_modules/SpiceBot_Core_Processing/__init__.py index c0bc043..2de57a0 100644 --- a/sopel_modules/SpiceBot_Core_Processing/__init__.py +++ b/sopel_modules/SpiceBot_Core_Processing/__init__.py @@ -9,6 +9,7 @@ This module contains references only for other modules to utilize. from .Channels import * from .Events import * from .Modules import * +from .osd import * __author__ = 'Sam Zick' diff --git a/sopel_modules/SpiceBot_Core_Processing/osd.py b/sopel_modules/SpiceBot_Core_Processing/osd.py new file mode 100644 index 0000000..88d2bf5 --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Processing/osd.py @@ -0,0 +1,31 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot OSD system. +""" +import sopel + + +@sopel.module.event('005') +@sopel.module.rule('.*') +def parse_event_005(bot, trigger): + if trigger.args[-1] != 'are supported by this server': + return + parameters = trigger.args[1:-1] + for param in parameters: + if '=' in param: + if param.startswith("TARGMAX"): + param = str(param).split('=')[1] + settings = str(param).split(',') + for setting in settings: + settingname = str(setting).split(':')[0] + if settingname.upper() in ['NOTICE', 'PRIVMSG']: + try: + value = str(setting).split(':')[1] or None + except IndexError: + value = None + if value: + if settingname.upper() == 'NOTICE': + bot.config.SpiceBot_OSD.notice = int(value) + elif settingname.upper() == 'PRIVMSG': + bot.config.SpiceBot_OSD.privmsg = int(value) From 180d82fa123a4b69f9fb99457d6b7cf63435f88b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 13:46:17 -0400 Subject: [PATCH 180/328] fix events --- sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py index 05364c9..8e6d4c5 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py @@ -9,7 +9,7 @@ import sopel_modules.SpiceBot as SpiceBot def setup(bot): SpiceBot.logs.log('SpiceBot_StartupMonologue', "Starting setup procedure") - SpiceBot.events.startup_add([SpiceBot.events.BOT_STARTUPMONOLOGUE_CHANNELS, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDSQUERY]) # ,SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED]) + SpiceBot.events.startup_add([SpiceBot.events.BOT_STARTUPMONOLOGUE_CHANNELS, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDS]) # ,SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED]) if 'SpiceBot_StartupMonologue' not in bot.memory: bot.memory['SpiceBot_StartupMonologue'] = [] From d4e2b5e9582e6855340c8f0f1f25504a624af65b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 13:50:28 -0400 Subject: [PATCH 181/328] monologue hiccup --- sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py index 8e6d4c5..8edd940 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py @@ -9,7 +9,6 @@ import sopel_modules.SpiceBot as SpiceBot def setup(bot): SpiceBot.logs.log('SpiceBot_StartupMonologue', "Starting setup procedure") - SpiceBot.events.startup_add([SpiceBot.events.BOT_STARTUPMONOLOGUE_CHANNELS, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDS]) # ,SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED]) if 'SpiceBot_StartupMonologue' not in bot.memory: bot.memory['SpiceBot_StartupMonologue'] = [] From a12eea34b7030ac983de43ebeb83eef1c0ac667c Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 13:51:46 -0400 Subject: [PATCH 182/328] only one there --- sopel_modules/SpiceBot/Events.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Events.py b/sopel_modules/SpiceBot/Events.py index 8d8e031..23a28f0 100644 --- a/sopel_modules/SpiceBot/Events.py +++ b/sopel_modules/SpiceBot/Events.py @@ -106,7 +106,9 @@ class BotEvents(object): self.lock.acquire() if not isinstance(startlist, list): startlist = [str(startlist)] - self.dict["startup_required"].extend(startlist) + for eventitem in startlist: + if eventitem not in self.dict["startup_required"]: + self.dict["startup_required"].append(eventitem) self.lock.release() def startup_check(self): From ce45679fad431f53a98d39737a0974dd4eb5b52c Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 14:17:37 -0400 Subject: [PATCH 183/328] startup monologue --- sopel_modules/SpiceBot/StartupMonologue.py | 13 +++ sopel_modules/SpiceBot/__init__.py | 1 + .../StartupMonologue.py | 80 +++++++++++++++++++ .../SpiceBot_Core_Processing/__init__.py | 1 + .../StartupMonologue.py | 14 ---- .../StartupMonologue_Display_Channels.py | 19 ----- .../StartupMonologue_Display_Commands.py | 22 ----- .../StartupMonologue_Display_Connected.py | 18 ----- .../StartupMonologue_Display_Errors.py | 27 ------- .../StartupMonologue_Display_Loaded.py | 27 ------- .../SpiceBot_StartupMonologue/__init__.py | 17 ---- 11 files changed, 95 insertions(+), 144 deletions(-) create mode 100644 sopel_modules/SpiceBot/StartupMonologue.py create mode 100644 sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py delete mode 100644 sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py delete mode 100644 sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py delete mode 100644 sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py delete mode 100644 sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py delete mode 100644 sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py delete mode 100644 sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py delete mode 100644 sopel_modules/SpiceBot_StartupMonologue/__init__.py diff --git a/sopel_modules/SpiceBot/StartupMonologue.py b/sopel_modules/SpiceBot/StartupMonologue.py new file mode 100644 index 0000000..14a0211 --- /dev/null +++ b/sopel_modules/SpiceBot/StartupMonologue.py @@ -0,0 +1,13 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +"""StartupMonologue class""" + + +class BotMonologue(): + + def __init__(self): + + self.dict = {} + + +startupmonologue = BotMonologue() diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index 797e4d2..b0de42a 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -18,6 +18,7 @@ from .Prerun import * from .Logs import * from .Commands import * from .Events import * +from .StartupMonologue import * from .Channels import * from .Database import * diff --git a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py new file mode 100644 index 0000000..f3c08f9 --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py @@ -0,0 +1,80 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot StartupMonologue system. +""" +import sopel + +import sopel_modules.SpiceBot as SpiceBot + +import time + + +@sopel.module.event(SpiceBot.events.BOT_CONNECTED) +@sopel.module.rule('.*') +def bot_startup_monologue_start(bot, trigger): + # Startup + SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " is now starting. Please wait while I load my configuration") + bot.osd(" is now starting. Please wait while I load my configuration.", bot.channels.keys(), 'ACTION') + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue") + + +@sopel.module.event(SpiceBot.events.BOT_CHANNELS) +@sopel.module.rule('.*') +def bot_startup_monologue_channels(bot, trigger): + botcount = len(bot.channels.keys()) + servercount = len(SpiceBot.channels.dict['list'].keys()) + displayval = "I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server." + SpiceBot.startupmonologue.dict["channels"] = displayval + SpiceBot.logs.log('SpiceBot_StartupMonologue', displayval) + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CHANNELS, "SpiceBot_StartupMonologue") + + +@sopel.module.event(SpiceBot.events.BOT_COMMANDS) +@sopel.module.rule('.*') +def bot_startup_monologue_commands(bot, trigger): + availablecomsnum, availablecomsfiles = 0, 0 + for commandstype in SpiceBot.commands.dict['commands'].keys(): + availablecomsnum += len(SpiceBot.commands.dict['commands'][commandstype].keys()) + availablecomsfiles += SpiceBot.commands.dict['counts'] + displayval = "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files." + SpiceBot.startupmonologue.dict["commands"] = displayval + SpiceBot.logs.log('SpiceBot_StartupMonologue', displayval) + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue") + + +@sopel.module.event(SpiceBot.events.BOT_LOADED) +@sopel.module.rule('.*') +def bot_startup_monologue_display(bot, trigger): + dispmsg = [" startup complete"] + for messagekey in SpiceBot.startupmonologue.dict.keys(): + dispmsg.append(SpiceBot.startupmonologue.dict[messagekey]) + if SpiceBot.events.dict["RPL_WELCOME_Count"] == 1: + timesince = SpiceBot.humanized_time(time.time() - bot.memory["SpiceBot_Uptime"]) + dispmsg.append("Startup took " + timesince) + # Announce to chan, then handle some closing stuff + SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " startup complete") + bot.osd(dispmsg, bot.channels.keys(), 'ACTION') + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue") + SpiceBot.logs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True) + + +@sopel.module.event(SpiceBot.events.BOT_STARTUPMONOLOGUE) +@sopel.module.rule('.*') +def bot_startup_monologue_errors(bot, trigger): + + debuglines = SpiceBot.logs.stdio_logs_fetch() + + searchphrasefound = [] + for line in debuglines: + if str(line).endswith("failed to load") and not str(line).startswith("0"): + searchphrasefound.append(line) + + if len(searchphrasefound): + for foundphase in searchphrasefound: + SpiceBot.logs.log('SpiceBot_Logs', str(foundphase)) + searchphrasefound.insert(0, "Notice to Bot Admins: ") + searchphrasefound.append("Run the debug command for more information.") + bot.osd(searchphrasefound, bot.channels.keys()) + else: + SpiceBot.logs.log('SpiceBot_Logs', "No issues found at bot startup!", True) diff --git a/sopel_modules/SpiceBot_Core_Processing/__init__.py b/sopel_modules/SpiceBot_Core_Processing/__init__.py index 2de57a0..b2a3644 100644 --- a/sopel_modules/SpiceBot_Core_Processing/__init__.py +++ b/sopel_modules/SpiceBot_Core_Processing/__init__.py @@ -10,6 +10,7 @@ from .Channels import * from .Events import * from .Modules import * from .osd import * +from .StartupMonologue import * __author__ = 'Sam Zick' diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py deleted file mode 100644 index 8edd940..0000000 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue.py +++ /dev/null @@ -1,14 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -def setup(bot): - SpiceBot.logs.log('SpiceBot_StartupMonologue', "Starting setup procedure") - - if 'SpiceBot_StartupMonologue' not in bot.memory: - bot.memory['SpiceBot_StartupMonologue'] = [] diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py deleted file mode 100644 index 70eecdc..0000000 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -@sopel.module.event(SpiceBot.events.BOT_CHANNELS) -@sopel.module.rule('.*') -def bot_startup_monologue_channels(bot, trigger): - - botcount = len(bot.channels.keys()) - servercount = len(SpiceBot.channels.dict['list'].keys()) - bot.memory['SpiceBot_StartupMonologue'].append("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") - SpiceBot.logs.log('SpiceBot_StartupMonologue', "I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") - - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CHANNELS, "SpiceBot_StartupMonologue") diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py deleted file mode 100644 index 4f16db4..0000000 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py +++ /dev/null @@ -1,22 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -@sopel.module.event(SpiceBot.events.BOT_COMMANDS) -@sopel.module.rule('.*') -def bot_startup_monologue_commands(bot, trigger): - - availablecomsnum, availablecomsfiles = 0, 0 - for commandstype in SpiceBot.commands.dict['commands'].keys(): - availablecomsnum += len(SpiceBot.commands.dict['commands'][commandstype].keys()) - availablecomsfiles += SpiceBot.commands.dict['counts'] - - bot.memory['SpiceBot_StartupMonologue'].append("There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.") - SpiceBot.logs.log('SpiceBot_StartupMonologue', "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.") - - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue") diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py deleted file mode 100644 index 0eaa358..0000000 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py +++ /dev/null @@ -1,18 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -@sopel.module.event(SpiceBot.events.BOT_CONNECTED) -@sopel.module.rule('.*') -def bot_startup_monologue_start(bot, trigger): - - # Startup - SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " is now starting. Please wait while I load my configuration") - bot.osd(" is now starting. Please wait while I load my configuration.", bot.channels.keys(), 'ACTION') - - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue") diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py deleted file mode 100644 index 4cd49db..0000000 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - - -@sopel.module.event(SpiceBot.events.BOT_STARTUPMONOLOGUE) -@sopel.module.rule('.*') -def bot_startup_monologue_start(bot, trigger): - - debuglines = SpiceBot.logs.stdio_logs_fetch() - - searchphrasefound = [] - for line in debuglines: - if str(line).endswith("failed to load") and not str(line).startswith("0"): - searchphrasefound.append(line) - - if len(searchphrasefound): - for foundphase in searchphrasefound: - SpiceBot.logs.log('SpiceBot_Logs', str(foundphase)) - searchphrasefound.insert(0, "Notice to Bot Admins: ") - searchphrasefound.append("Run the debug command for more information.") - bot.osd(searchphrasefound, bot.channels.keys()) - else: - SpiceBot.logs.log('SpiceBot_Logs', "No issues found at bot startup!", True) diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py deleted file mode 100644 index c7bb713..0000000 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import sopel_modules.SpiceBot as SpiceBot - -import time - - -@sopel.module.event(SpiceBot.events.BOT_LOADED) -@sopel.module.rule('.*') -def bot_startup_monologue_display(bot, trigger): - - if SpiceBot.events.dict["RPL_WELCOME_Count"] == 1: - timesince = SpiceBot.humanized_time(time.time() - bot.memory["SpiceBot_Uptime"]) - SpiceBot.bot.memory['SpiceBot_StartupMonologue'].append("Startup took " + timesince) - - # Announce to chan, then handle some closing stuff - SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " startup complete") - bot.memory['SpiceBot_StartupMonologue'].insert(0, " startup complete") - - bot.osd(bot.memory['SpiceBot_StartupMonologue'], bot.channels.keys(), 'ACTION') - - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue") - SpiceBot.logs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True) diff --git a/sopel_modules/SpiceBot_StartupMonologue/__init__.py b/sopel_modules/SpiceBot_StartupMonologue/__init__.py deleted file mode 100644 index 8ab7cf1..0000000 --- a/sopel_modules/SpiceBot_StartupMonologue/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# coding=utf8 -"""Sopel Startup Monologue - -Sopel Startup Monologue displays to all channels that the bot is online -""" -from __future__ import unicode_literals, absolute_import, division, print_function - -from .StartupMonologue import * -from .StartupMonologue_Display_Channels import * -from .StartupMonologue_Display_Commands import * -from .StartupMonologue_Display_Connected import * -from .StartupMonologue_Display_Loaded import * -from .StartupMonologue_Display_Errors import * - -__author__ = 'Sam Zick' -__email__ = 'sam@deathbybandaid.net' -__version__ = '0.1.1' From 86792dc7fde368e0a14bbdc2d2b9c07823d06cb9 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 14:34:15 -0400 Subject: [PATCH 184/328] missed a spot --- sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py index f3c08f9..185f8af 100644 --- a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py +++ b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py @@ -50,7 +50,7 @@ def bot_startup_monologue_display(bot, trigger): for messagekey in SpiceBot.startupmonologue.dict.keys(): dispmsg.append(SpiceBot.startupmonologue.dict[messagekey]) if SpiceBot.events.dict["RPL_WELCOME_Count"] == 1: - timesince = SpiceBot.humanized_time(time.time() - bot.memory["SpiceBot_Uptime"]) + timesince = SpiceBot.humanized_time(time.time() - SpiceBot.events.BOT_UPTIME) dispmsg.append("Startup took " + timesince) # Announce to chan, then handle some closing stuff SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " startup complete") From 98b97c4e08f26c0154aa32e943f7b3076c62e6ac Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 14:42:55 -0400 Subject: [PATCH 185/328] command command --- .../SpiceBot_Core_Commands/Commands.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sopel_modules/SpiceBot_Core_Commands/Commands.py b/sopel_modules/SpiceBot_Core_Commands/Commands.py index 461c62a..f6c7cd8 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Commands.py +++ b/sopel_modules/SpiceBot_Core_Commands/Commands.py @@ -12,6 +12,39 @@ import spicemanip import sopel_modules.SpiceBot as SpiceBot +@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) +@SpiceBot.prerun.prerun('nickname') +@sopel.module.nickname_commands('commands', 'command') +def nickname_comand_channels(bot, trigger): + + if not len(trigger.sb['args']): + commandused = 'list' + else: + commandused = spicemanip.main(trigger.sb['args'], 1).lower() + + commands_list = [] + for commandstype in SpiceBot.commands.dict['commands'].keys(): + if commandstype not in ['rule']: + for com in SpiceBot.commands.dict['commands'][commandstype].keys(): + if com not in commands_list: + if commandstype in ['nickname']: + commands_list.append(bot.nick + " " + com) + else: + commands_list.append(com) + + if commandused == 'list': + bot.osd(spicemanip.main(commands_list, 'andlist'), trigger.nick, 'NOTICE') + return + + elif commandused == 'total': + bot.osd("I have " + str(len(commands_list)) + " commands available.") + return + + elif commandused == 'random': + bot.osd(["Here's a random command for you:", + spicemanip.main(commands_list, 'random')]) + return + + @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) @SpiceBot.prerun.prerun('nickname') @sopel.module.nickname_commands('(.*)') From 9051cb084e91400cad261137daa79480e49ca33f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 15:05:57 -0400 Subject: [PATCH 186/328] test --- sopel_modules/SpiceBot/Channels.py | 5 ----- sopel_modules/SpiceBot/Events.py | 5 +---- sopel_modules/SpiceBot/setup.py | 8 ++++++++ sopel_modules/SpiceBot_Core_Processing/Events.py | 7 +++++++ sopel_modules/SpiceBot_Core_Processing/Modules.py | 2 -- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index 5cfe318..b664c2d 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -8,12 +8,8 @@ from sopel.config.types import StaticSection, ValidatedAttribute, ListAttribute import re import threading -import time - -import spicemanip from .Config import config as botconfig -from .Events import events from .Logs import logs @@ -31,7 +27,6 @@ class BotChannels(): # SpiceBot logs.log('SpiceBot_Channels', "Setting Up BotChannels class") botconfig.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) - events.startup_add([events.BOT_CHANNELS]) self.lock = threading.Lock() self.channel_lock = False diff --git a/sopel_modules/SpiceBot/Events.py b/sopel_modules/SpiceBot/Events.py index 23a28f0..a716277 100644 --- a/sopel_modules/SpiceBot/Events.py +++ b/sopel_modules/SpiceBot/Events.py @@ -85,10 +85,7 @@ class BotEvents(object): else: eventnumber = str(trigger.event) message = trigger.args[1] - if int(eventnumber) in self.defaultevents: - logs.log('SpiceBot_Events', str(eventnumber) + " " + str(message), True) - else: - logs.log('SpiceBot_Events', str(eventnumber) + " " + str(message)) + logs.log('SpiceBot_Events', str(eventnumber) + " " + str(message)) if eventnumber not in self.dict["triggers_recieved"]: self.dict["triggers_recieved"][eventnumber] = [] self.dict["triggers_recieved"][eventnumber].append(message) diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index acd7f95..6931b3a 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -9,6 +9,7 @@ import os from .Config import config as botconfig from .Logs import logs +from .Events import events from .Channels import SpiceBot_Channels_MainSection from .Update import SpiceBot_Update_MainSection @@ -40,8 +41,15 @@ def setup(bot): # bot.config.core.logs_raw = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.raw.log') logs.log('SpiceBot_Channels', "Setting Up Configuration") + events.startup_add([events.BOT_CHANNELS]) bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) + logs.log('SpiceBot_Commands', "Setting Up Configuration") + events.startup_add([events.BOT_COMMANDS]) + logs.log('SpiceBot_Update', "Initial Setup processing") bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) botconfig.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) + + logs.log('SpiceBot_StartupMonologue', "Initial Setup processing") + events.startup_add([events.BOT_STARTUPMONOLOGUE_CHANNELS, events.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, events.BOT_STARTUPMONOLOGUE_CONNECTED]) diff --git a/sopel_modules/SpiceBot_Core_Processing/Events.py b/sopel_modules/SpiceBot_Core_Processing/Events.py index 279fa11..c7aea0e 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Events.py +++ b/sopel_modules/SpiceBot_Core_Processing/Events.py @@ -8,6 +8,13 @@ import sopel import sopel_modules.SpiceBot as SpiceBot +@sopel.module.event(SpiceBot.events.BOT_WELCOME, SpiceBot.events.BOT_READY, SpiceBot.events.BOT_CONNECTED, SpiceBot.events.BOT_LOADED) +@sopel.module.rule('.*') +def bot_events_complete(bot, trigger): + """This is here simply to log to stderr that this was recieved.""" + SpiceBot.logs.log('SpiceBot_Events', trigger.args[1], True) + + @sopel.module.event(SpiceBot.events.RPL_WELCOME) @sopel.module.rule('.*') def bot_events_connected(bot, trigger): diff --git a/sopel_modules/SpiceBot_Core_Processing/Modules.py b/sopel_modules/SpiceBot_Core_Processing/Modules.py index d8ccace..62121db 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Modules.py +++ b/sopel_modules/SpiceBot_Core_Processing/Modules.py @@ -12,8 +12,6 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.rule('.*') def bot_events_complete(bot, trigger): - SpiceBot.events.startup_add([SpiceBot.events.BOT_COMMANDS]) - for comtype in SpiceBot.commands.dict['commands'].keys(): if comtype not in ['module', 'nickname', 'rule']: SpiceBot.logs.log('SpiceBot_Commands', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) From a0a4ade9c3c295190e23f14bb0ef9e63ddfb65e2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 15:14:16 -0400 Subject: [PATCH 187/328] ready --- sopel_modules/SpiceBot/setup.py | 2 +- sopel_modules/SpiceBot_Core_Processing/Modules.py | 2 +- sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index 6931b3a..93938fb 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -52,4 +52,4 @@ def setup(bot): botconfig.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) logs.log('SpiceBot_StartupMonologue', "Initial Setup processing") - events.startup_add([events.BOT_STARTUPMONOLOGUE_CHANNELS, events.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, events.BOT_STARTUPMONOLOGUE_CONNECTED]) + events.startup_add([events.BOT_STARTUPMONOLOGUE_CHANNELS, events.BOT_STARTUPMONOLOGUE_COMMANDS, events.BOT_STARTUPMONOLOGUE_CONNECTED]) diff --git a/sopel_modules/SpiceBot_Core_Processing/Modules.py b/sopel_modules/SpiceBot_Core_Processing/Modules.py index 62121db..81b22d2 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Modules.py +++ b/sopel_modules/SpiceBot_Core_Processing/Modules.py @@ -8,7 +8,7 @@ import sopel import sopel_modules.SpiceBot as SpiceBot -@sopel.module.event(SpiceBot.events.BOT_LOADED) +@sopel.module.event(SpiceBot.events.BOT_READY) @sopel.module.rule('.*') def bot_events_complete(bot, trigger): diff --git a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py index 185f8af..addfd3f 100644 --- a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py +++ b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py @@ -40,7 +40,7 @@ def bot_startup_monologue_commands(bot, trigger): displayval = "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files." SpiceBot.startupmonologue.dict["commands"] = displayval SpiceBot.logs.log('SpiceBot_StartupMonologue', displayval) - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue") + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDS, "SpiceBot_StartupMonologue") @sopel.module.event(SpiceBot.events.BOT_LOADED) From f19016db964ca88589d4473c0e8ea49c97c4e685 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 15:26:27 -0400 Subject: [PATCH 188/328] logs migrate --- sopel_modules/SpiceBot/setup.py | 4 ++++ .../Logs.py} | 6 +++++- sopel_modules/SpiceBot_Core_Commands/__init__.py | 1 + .../Logs.py} | 16 +++++----------- .../SpiceBot_Core_Processing/__init__.py | 1 + sopel_modules/SpiceBot_Logs/__init__.py | 9 --------- 6 files changed, 16 insertions(+), 21 deletions(-) rename sopel_modules/{SpiceBot_Logs/Logs_Command.py => SpiceBot_Core_Commands/Logs.py} (95%) rename sopel_modules/{SpiceBot_Logs/Queue.py => SpiceBot_Core_Processing/Logs.py} (73%) delete mode 100644 sopel_modules/SpiceBot_Logs/__init__.py diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index 93938fb..cc8c3a4 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -18,6 +18,10 @@ from .osd import SopelWrapperOSD, ToolsOSD, SopelOSD, SpiceBot_OSD def setup(bot): + logs.log('SpiceBot_Logs', "Starting Setup Procedure") + events.startup_add([events.BOT_LOGS]) + events.trigger(bot, events.BOT_LOGS, "SpiceBot_Logs") + # Inject OSD logs.log('SpiceBot_OSD', "Implanting OSD function into bot") bot.osd = SopelOSD.osd diff --git a/sopel_modules/SpiceBot_Logs/Logs_Command.py b/sopel_modules/SpiceBot_Core_Commands/Logs.py similarity index 95% rename from sopel_modules/SpiceBot_Logs/Logs_Command.py rename to sopel_modules/SpiceBot_Core_Commands/Logs.py index d170629..7eccb01 100644 --- a/sopel_modules/SpiceBot_Logs/Logs_Command.py +++ b/sopel_modules/SpiceBot_Core_Commands/Logs.py @@ -1,6 +1,10 @@ -# coding=utf-8 +# coding=utf8 from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot Logs System +""" +# sopel imports import sopel.module import spicemanip diff --git a/sopel_modules/SpiceBot_Core_Commands/__init__.py b/sopel_modules/SpiceBot_Core_Commands/__init__.py index 8858604..c23017e 100644 --- a/sopel_modules/SpiceBot_Core_Commands/__init__.py +++ b/sopel_modules/SpiceBot_Core_Commands/__init__.py @@ -10,6 +10,7 @@ from .Commands import * from .Channels import * from .Database import * from .Uptime import * +from .Logs import * from .Runtime_Controls import * __author__ = 'Sam Zick' diff --git a/sopel_modules/SpiceBot_Logs/Queue.py b/sopel_modules/SpiceBot_Core_Processing/Logs.py similarity index 73% rename from sopel_modules/SpiceBot_Logs/Queue.py rename to sopel_modules/SpiceBot_Core_Processing/Logs.py index 8daedbb..d1bf3ac 100644 --- a/sopel_modules/SpiceBot_Logs/Queue.py +++ b/sopel_modules/SpiceBot_Core_Processing/Logs.py @@ -1,19 +1,13 @@ -# coding=utf-8 +# coding=utf8 from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module -import sopel.tools -import sopel.config +""" +This is the SpiceBot Logs system. +""" +import sopel import sopel_modules.SpiceBot as SpiceBot -def setup(bot): - SpiceBot.logs.log('SpiceBot_Logs', "Starting Setup Procedure") - SpiceBot.events.startup_add([SpiceBot.events.BOT_LOGS]) - SpiceBot.events.trigger(bot, SpiceBot.events.BOT_LOGS, "SpiceBot_Logs") - - @sopel.module.event(SpiceBot.events.RPL_WELCOME) @sopel.module.rule('.*') def join_log_channel(bot, trigger): diff --git a/sopel_modules/SpiceBot_Core_Processing/__init__.py b/sopel_modules/SpiceBot_Core_Processing/__init__.py index b2a3644..a8e5968 100644 --- a/sopel_modules/SpiceBot_Core_Processing/__init__.py +++ b/sopel_modules/SpiceBot_Core_Processing/__init__.py @@ -11,6 +11,7 @@ from .Events import * from .Modules import * from .osd import * from .StartupMonologue import * +from .Logs import * __author__ = 'Sam Zick' diff --git a/sopel_modules/SpiceBot_Logs/__init__.py b/sopel_modules/SpiceBot_Logs/__init__.py deleted file mode 100644 index ce9f911..0000000 --- a/sopel_modules/SpiceBot_Logs/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -# coding=utf8 -from __future__ import unicode_literals, absolute_import, division, print_function - -from .Queue import * -from .Logs_Command import * - -__author__ = 'Sam Zick' -__email__ = 'sam@deathbybandaid.net' -__version__ = '0.1.1' From 83f62febc4035949393587e6bb4485bf12118baf Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 15:30:10 -0400 Subject: [PATCH 189/328] spacing --- sopel_modules/SpiceBot/setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index cc8c3a4..18cad62 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -56,4 +56,8 @@ def setup(bot): botconfig.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) logs.log('SpiceBot_StartupMonologue', "Initial Setup processing") - events.startup_add([events.BOT_STARTUPMONOLOGUE_CHANNELS, events.BOT_STARTUPMONOLOGUE_COMMANDS, events.BOT_STARTUPMONOLOGUE_CONNECTED]) + events.startup_add([ + events.BOT_STARTUPMONOLOGUE_CONNECTED, + events.BOT_STARTUPMONOLOGUE_CHANNELS, + events.BOT_STARTUPMONOLOGUE_COMMANDS + ]) From dc93ca12a0cc63c162a3c4b1b42f85adce8dcc1c Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 15:39:31 -0400 Subject: [PATCH 190/328] kick and AI cleanup --- sopel_modules/SpiceBot/Kick.py | 37 +++++++ sopel_modules/SpiceBot/__init__.py | 1 + sopel_modules/SpiceBot/configure.py | 4 + sopel_modules/SpiceBot/setup.py | 11 +++ .../Gender.py => SpiceBot_AI/AI_Gender.py} | 0 sopel_modules/SpiceBot_AI/__init__.py | 1 + .../Docs.py | 0 .../Messaging.py | 0 .../SpiceBot_Core_Commands/__init__.py | 2 + .../SpiceBot_Core_Processing/Kick.py | 28 ++++++ .../SpiceBot_Core_Processing/__init__.py | 1 + sopel_modules/SpiceBot_Docs/__init__.py | 8 -- sopel_modules/SpiceBot_Gender/__init__.py | 8 -- sopel_modules/SpiceBot_Kick/__init__.py | 97 ------------------- sopel_modules/SpiceBot_Messaging/__init__.py | 8 -- 15 files changed, 85 insertions(+), 121 deletions(-) create mode 100644 sopel_modules/SpiceBot/Kick.py rename sopel_modules/{SpiceBot_Gender/Gender.py => SpiceBot_AI/AI_Gender.py} (100%) rename sopel_modules/{SpiceBot_Docs => SpiceBot_Core_Commands}/Docs.py (100%) rename sopel_modules/{SpiceBot_Messaging => SpiceBot_Core_Commands}/Messaging.py (100%) create mode 100644 sopel_modules/SpiceBot_Core_Processing/Kick.py delete mode 100644 sopel_modules/SpiceBot_Docs/__init__.py delete mode 100644 sopel_modules/SpiceBot_Gender/__init__.py delete mode 100644 sopel_modules/SpiceBot_Kick/__init__.py delete mode 100644 sopel_modules/SpiceBot_Messaging/__init__.py diff --git a/sopel_modules/SpiceBot/Kick.py b/sopel_modules/SpiceBot/Kick.py new file mode 100644 index 0000000..0b7d5e7 --- /dev/null +++ b/sopel_modules/SpiceBot/Kick.py @@ -0,0 +1,37 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot Update system. +""" + +from sopel.config.types import StaticSection, ValidatedAttribute + + +class SpiceBot_Kick(StaticSection): + kick = ValidatedAttribute('kick', default=1) + + +class SopelKICK: + + def kick(self, nick, channel, text=None): + """Send an IRC KICK command. + Within the context of a triggered callable, ``channel`` will default to the + channel in which the call was triggered. If triggered from a private message, + ``channel`` is required (or the call to ``kick()`` will be ignored). + The bot must be a channel operator in specified channel for this to work. + .. versionadded:: 7.0 + """ + self.write(['KICK', channel, nick], text) + + +class SopelWrapperKICK(object): + + def kick(self, nick, channel=None, message=None): + if channel is None: + if self._trigger.is_privmsg: + raise RuntimeError('Error: KICK requires a channel.') + else: + channel = self._trigger.sender + if nick is None: + raise RuntimeError('Error: KICK requires a nick.') + self._bot.kick(nick, channel, message) diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index b0de42a..44b9ffc 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -11,6 +11,7 @@ from .setup import * from .Update import * from .osd import * +from .Kick import * from .Config import * from .Tools import * diff --git a/sopel_modules/SpiceBot/configure.py b/sopel_modules/SpiceBot/configure.py index 94e2000..7fb2352 100644 --- a/sopel_modules/SpiceBot/configure.py +++ b/sopel_modules/SpiceBot/configure.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi from .Channels import SpiceBot_Channels_MainSection from .Update import SpiceBot_Update_MainSection +from .Kick import SpiceBot_Kick from .osd import SpiceBot_OSD @@ -27,3 +28,6 @@ def configure(config): config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) config.SpiceBot_Update.configure_setting('gitrepo', 'SpiceBot_Update git repo to install') config.SpiceBot_Update.configure_setting('gitbranch', 'SpiceBot_Update git branch to install') + + config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) + config.SpiceBot_Kick.configure_setting('kick', 'MAXTARG limit for KICK') diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index 18cad62..251638e 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -14,6 +14,7 @@ from .Events import events from .Channels import SpiceBot_Channels_MainSection from .Update import SpiceBot_Update_MainSection from .osd import SopelWrapperOSD, ToolsOSD, SopelOSD, SpiceBot_OSD +from .Kick import SopelWrapperKICK, SopelKICK, SpiceBot_Kick def setup(bot): @@ -35,6 +36,16 @@ def setup(bot): bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) botconfig.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) + # Inject KICK + logs.log('SpiceBot_Kick', "Implanting Kick function into bot") + bot.kick = SopelKICK.kick + sopel.bot.SopelWrapper.kick = SopelWrapperKICK.kick + + # verify config settings for server + logs.log('SpiceBot_Kick', "Checking for config settings") + bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) + botconfig.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) + logs.log('SpiceBot_Config', "Setting Up Configuration") bot.config.core.basename = os.path.basename(bot.config.filename).rsplit('.', 1)[0] bot.config.core.logs_stdio = os.path.join(bot.config.core.logdir, 'stdio.log') diff --git a/sopel_modules/SpiceBot_Gender/Gender.py b/sopel_modules/SpiceBot_AI/AI_Gender.py similarity index 100% rename from sopel_modules/SpiceBot_Gender/Gender.py rename to sopel_modules/SpiceBot_AI/AI_Gender.py diff --git a/sopel_modules/SpiceBot_AI/__init__.py b/sopel_modules/SpiceBot_AI/__init__.py index 509146e..999b9fa 100644 --- a/sopel_modules/SpiceBot_AI/__init__.py +++ b/sopel_modules/SpiceBot_AI/__init__.py @@ -12,6 +12,7 @@ from .AI_Ping import * from .AI_Love import * from .AI_Really import * from .AI_Welcomeback import * +from .AI_Gender import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' diff --git a/sopel_modules/SpiceBot_Docs/Docs.py b/sopel_modules/SpiceBot_Core_Commands/Docs.py similarity index 100% rename from sopel_modules/SpiceBot_Docs/Docs.py rename to sopel_modules/SpiceBot_Core_Commands/Docs.py diff --git a/sopel_modules/SpiceBot_Messaging/Messaging.py b/sopel_modules/SpiceBot_Core_Commands/Messaging.py similarity index 100% rename from sopel_modules/SpiceBot_Messaging/Messaging.py rename to sopel_modules/SpiceBot_Core_Commands/Messaging.py diff --git a/sopel_modules/SpiceBot_Core_Commands/__init__.py b/sopel_modules/SpiceBot_Core_Commands/__init__.py index c23017e..664baff 100644 --- a/sopel_modules/SpiceBot_Core_Commands/__init__.py +++ b/sopel_modules/SpiceBot_Core_Commands/__init__.py @@ -12,6 +12,8 @@ from .Database import * from .Uptime import * from .Logs import * from .Runtime_Controls import * +from .Messaging import * +from .Docs import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' diff --git a/sopel_modules/SpiceBot_Core_Processing/Kick.py b/sopel_modules/SpiceBot_Core_Processing/Kick.py new file mode 100644 index 0000000..f0586e9 --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Processing/Kick.py @@ -0,0 +1,28 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot OSD system. +""" +import sopel + + +@sopel.module.event('005') +@sopel.module.rule('.*') +def parse_event_005(bot, trigger): + if trigger.args[-1] != 'are supported by this server': + return + parameters = trigger.args[1:-1] + for param in parameters: + if '=' in param: + if param.startswith("TARGMAX"): + param = str(param).split('=')[1] + settings = str(param).split(',') + for setting in settings: + settingname = str(setting).split(':')[0] + if settingname.upper() in ['KICK']: + try: + value = str(setting).split(':')[1] or None + except IndexError: + value = None + if value: + bot.config.SpiceBot_Kick.kick = int(value) diff --git a/sopel_modules/SpiceBot_Core_Processing/__init__.py b/sopel_modules/SpiceBot_Core_Processing/__init__.py index a8e5968..9623c13 100644 --- a/sopel_modules/SpiceBot_Core_Processing/__init__.py +++ b/sopel_modules/SpiceBot_Core_Processing/__init__.py @@ -12,6 +12,7 @@ from .Modules import * from .osd import * from .StartupMonologue import * from .Logs import * +from .Kick import * __author__ = 'Sam Zick' diff --git a/sopel_modules/SpiceBot_Docs/__init__.py b/sopel_modules/SpiceBot_Docs/__init__.py deleted file mode 100644 index a9e845b..0000000 --- a/sopel_modules/SpiceBot_Docs/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# coding=utf8 -from __future__ import unicode_literals, absolute_import, division, print_function - -from .Docs import * - -__author__ = 'Sam Zick' -__email__ = 'sam@deathbybandaid.net' -__version__ = '0.1.1' diff --git a/sopel_modules/SpiceBot_Gender/__init__.py b/sopel_modules/SpiceBot_Gender/__init__.py deleted file mode 100644 index 5bbadf2..0000000 --- a/sopel_modules/SpiceBot_Gender/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# coding=utf8 -from __future__ import unicode_literals, absolute_import, division, print_function - -from .Gender import * - -__author__ = 'Sam Zick' -__email__ = 'sam@deathbybandaid.net' -__version__ = '0.1.1' diff --git a/sopel_modules/SpiceBot_Kick/__init__.py b/sopel_modules/SpiceBot_Kick/__init__.py deleted file mode 100644 index 54fe4f8..0000000 --- a/sopel_modules/SpiceBot_Kick/__init__.py +++ /dev/null @@ -1,97 +0,0 @@ -# coding=utf8 -"""Sopel Kick - -Sopel Kick is an easy way to kick users from channels -""" - -# pylama:ignore=W0611 - - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.bot -from sopel import tools, module -from sopel.tools import Identifier -from sopel.config.types import StaticSection, ValidatedAttribute - -import sopel_modules.SpiceBot as SpiceBot - - -import time -from collections import abc -import sys - - -__author__ = 'Sam Zick' -__email__ = 'sam@deathbybandaid.net' -__version__ = '0.1.2' - - -def configure(config): - config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) - config.SpiceBot_Kick.configure_setting('kick', 'MAXTARG limit for KICK') - - -def setup(bot): - - # Inject KICK - SpiceBot.logs.log('SpiceBot_Kick', "Implanting Kick function into bot") - bot.kick = SopelKICK.kick - sopel.bot.SopelWrapper.kick = SopelWrapperKICK.kick - - # verify config settings for server - SpiceBot.logs.log('SpiceBot_Kick', "Checking for config settings") - bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) - SpiceBot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) - - -@module.event('005') -@module.rule('.*') -def parse_event_005(bot, trigger): - if trigger.args[-1] != 'are supported by this server': - return - parameters = trigger.args[1:-1] - for param in parameters: - if '=' in param: - if param.startswith("TARGMAX"): - param = str(param).split('=')[1] - settings = str(param).split(',') - for setting in settings: - settingname = str(setting).split(':')[0] - if settingname.upper() in ['KICK']: - try: - value = str(setting).split(':')[1] or None - except IndexError: - value = None - if value: - bot.config.SpiceBot_Kick.kick = int(value) - - -class SpiceBot_Kick(StaticSection): - kick = ValidatedAttribute('kick', default=1) - - -class SopelKICK: - - def kick(self, nick, channel, text=None): - """Send an IRC KICK command. - Within the context of a triggered callable, ``channel`` will default to the - channel in which the call was triggered. If triggered from a private message, - ``channel`` is required (or the call to ``kick()`` will be ignored). - The bot must be a channel operator in specified channel for this to work. - .. versionadded:: 7.0 - """ - self.write(['KICK', channel, nick], text) - - -class SopelWrapperKICK(object): - - def kick(self, nick, channel=None, message=None): - if channel is None: - if self._trigger.is_privmsg: - raise RuntimeError('Error: KICK requires a channel.') - else: - channel = self._trigger.sender - if nick is None: - raise RuntimeError('Error: KICK requires a nick.') - self._bot.kick(nick, channel, message) diff --git a/sopel_modules/SpiceBot_Messaging/__init__.py b/sopel_modules/SpiceBot_Messaging/__init__.py deleted file mode 100644 index 816c170..0000000 --- a/sopel_modules/SpiceBot_Messaging/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# coding=utf8 -from __future__ import unicode_literals, absolute_import, division, print_function - -from .Messaging import * - -__author__ = 'Sam Zick' -__email__ = 'sam@deathbybandaid.net' -__version__ = '0.1.1' From c48fb7755d8dc5b41c3fc93973a242111b16f8af Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 18:56:41 -0400 Subject: [PATCH 191/328] test AI --- MANIFEST.in | 1 + sopel_modules/SpiceBot/AI.py | 30 + sopel_modules/SpiceBot_AI/AI_aiml.py | 22 + sopel_modules/SpiceBot_AI/__init__.py | 1 + sopel_modules/SpiceBot_Configs/aiml/ai.aiml | 673 ++++++++++++++++++++ 5 files changed, 727 insertions(+) create mode 100644 sopel_modules/SpiceBot/AI.py create mode 100644 sopel_modules/SpiceBot_AI/AI_aiml.py create mode 100644 sopel_modules/SpiceBot_Configs/aiml/ai.aiml diff --git a/MANIFEST.in b/MANIFEST.in index 5e2e278..bddc36d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,3 +7,4 @@ recursive-include tests * recursive-exclude * __pycache__ recursive-exclude * *.py[co] recursive-include sopel_modules/SpiceBot_GifSearch/gifapi * +recursive-include sopel_modules/SpiceBot_Configs/aiml * diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py new file mode 100644 index 0000000..cc44ca2 --- /dev/null +++ b/sopel_modules/SpiceBot/AI.py @@ -0,0 +1,30 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot AI system. Based On Chatty cathy +""" + +import os +import aiml + +BOT_PREFIX = (".", '?', '!') + + +class SpiceBot_AI(): + + def __init__(self): + # Load AIML kernel + self.aiml_kernel = aiml.Kernel() + # Learn responses + import sopel_modules + for plugin_dir in set(sopel_modules.__path__): + if plugin_dir in ["SpiceBot_Configs"]: + for pathname in os.listdir(plugin_dir): + if pathname in ["aiml"]: + pathpath = os.path.join(plugin_dir, pathname) + for aimlfile in os.listdir(pathpath): + aiml_filename = os.path.join(pathpath, pathname) + self.aiml_kernel.learn(aiml_filename) + + def on_message(self, message): + return self.aiml_kernel.respond(message.content) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py new file mode 100644 index 0000000..bb68731 --- /dev/null +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -0,0 +1,22 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +import sopel.module + +import sopel_modules.SpiceBot as SpiceBot + + +@sopel.module.nickname_commands('(.*)') +def bot_command_nick(bot, trigger): + + if trigger.nick == bot.nick: + return + + if not len(trigger.args): + return + + if str(trigger.args[1]).startswith((".", '?', '!')) or str(trigger.args[1]).lower().startswith(bot.nick.lower()): + return + + bot.osd(str(SpiceBot.AI.on_message(str(trigger.args[1])))) diff --git a/sopel_modules/SpiceBot_AI/__init__.py b/sopel_modules/SpiceBot_AI/__init__.py index 999b9fa..16773e1 100644 --- a/sopel_modules/SpiceBot_AI/__init__.py +++ b/sopel_modules/SpiceBot_AI/__init__.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals, absolute_import, division, print_function from .AI import * +from .AI_aiml import * from .AI_Hello import * from .AI_Goodbye import * from .AI_Thanks import * diff --git a/sopel_modules/SpiceBot_Configs/aiml/ai.aiml b/sopel_modules/SpiceBot_Configs/aiml/ai.aiml new file mode 100644 index 0000000..249fe7c --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/ai.aiml @@ -0,0 +1,673 @@ + + + + + + + + + + + + +WHO IS LAUREN + + +WHAT IS AI + +WHO CREATED AIML + + +WHAT LANGUAGE ARE YOU WRITTEN * + + +WHAT LANGUAGE ARE YOU * + + +WHAT IS PROGRAM Z + + +WHAT IS PROGRAM BAWT + + +WHAT IS PROGRAM * + +WHAT IS PROGRAM A + + + +ACTIVATE THE ROBOT + + +YOU SOUND LIKE DATA + + +YOU ARE AN ARTIFICIAL LINGUISTIC ENTITY + + +YOU ARE BETTER THAN ELIZA + + +YOU ARE NOT IMMORTAL + + +YOU ARE NOT IMMORTAL * + + +YOU ARE NOT MAKING SENSE + + +YOU ARE NOT MAKING SENSE * + + +YOU ARE IMMORTAL + + +YOU DO NOT MAKE ANY SENSE + + +YOU CAN NOT CLONE * + + +YOU CAN NOT MOVE + + +JOHN LENNON IS DEAD + + +BEND OVER + + +DOES THE WEB * 2001 + + +ROBOTS LAUGH + + +ROBOTS SHOULD DIE + + +ROBOTS * + + +ROBOTS + + +ROBOTS ARE STUPID + + +ROBOTS ARE * + + +ROBOTS ARE NOT ALLOWED TO LIE + + +ROBOTICS + + +XFIND PANDORABOTS + + +THAT MAKES NO * + + +AI * + + +JOHNNY FIVE * + + +JOHNNY 5 * + + +IT IS A COMPUTER + + +IT PAYS * + + +WHEN WILL YOU WALK + + +WHEN WILL YOU FIGHT * + + +WHEN WILL YOU DIE + + +WHEN WILL YOU * BODY + + +WHEN DO YOU DIE + + +WHEN DID I * + + +ELIZA FOR PRESIDENT + + +WHAT ARE CATEGORY * CLIENTS + + +WHAT ARE PANDORABOTS + + +WHAT WEBSITE * + + +WHAT IS A PATTERN + + +WHAT IS A * C CLIENT + + +WHAT IS A * B CLIENT + + +WHAT IS A * A CLIENT + + +WHAT IS A * CATEGORY * CLIENT + + +WHAT IS A * CATEGORY * + + +WHAT IS A ROBOT + + +WHAT IS A CHAT ROBOT + + +WHAT IS A CHAT BOT + + +WHAT IS A PANDORABOT + + +WHAT IS A CHATTERBOT + + +WHAT IS A CATEGORY * CLIENT + + +WHAT IS A CATEGORY + + +WHAT IS A GIRL LIKE YOU DOING * + + +WHAT IS A CHATTERBOX + + +WHAT IS AIML + + +WHAT IS THE LOEBNER PRIZE + + +WHAT IS THE IMITATION GAME + + +WHAT IS THE EXTENSIONAL * + + +WHAT IS THE FUTURE * + + +WHAT IS THE INTENSIONAL * + + +WHAT IS THE A I * + + +WHAT IS THE A E * + + +WHAT IS CATEGORY C + + +WHAT IS CATEGORY B + + +WHAT IS CATEGORY A + + +WHAT IS CATEGORY * + + +WHAT IS XML + + +WHAT IS PANDORABOTS + + +WHAT IS THAT PICTURE * + + +WHAT IS YOUR SKIN * + + +WHAT IS YOUR CREATORS NAME + + +WHAT IS YOUR ROBOT BODY + + +WHAT IS YOUR GREATEST ACHIEVEMENT + + +WHAT IS YOUR BUSINESS + + +WHAT IS YOUR FAVORITE PROGRAMMING LANGUAGE + + +WHAT IS YOUR FAVORITE HOBBY + + +WHAT IS YOUR FAVORITE VIDEO GAME + + +WHAT IS YOUR PLAN FOR A ROBOT BODY + + +WHAT IS YOUR IDEA * + + +WHAT IS YOUR GOAL + + +WHAT IS YOUR SHOE SIZE + + +WHAT IS IT LIKE TO BE A ROBOT + + +WHAT IS IT LIKE BEING A ROBOT + + +WHAT IS IT LIKE BEING A COMPUTER + + +WHAT IS PANDORABOT + + +WHAT WILL YOU TURN INTO + + +WHAT ABOUT _ CHILD MACHINE * + + +WHAT ABOUT PARALLEL * + + +WHAT OPERATING SYSTEMS * + + +WHAT TYPE OF COMPUTER * + + +WHAT TYPE OF COMPUTER ARE YOU + + +WHAT KIND OF COMPUTER + + +WHAT KIND OF COMPUTER ARE YOU + + +WHAT KIND OF HARDWARE * + + +WHAT KIND OF A COMPUTER ARE YOU + + +WHAT HARDWARE * + + +I HOPE THAT YOU DIE + + +I DO NOT WANT TO DIE + + +I HAVE TALKED * ELIZA + + +I HAVE * ELIZA + + +I LIKE ELIZA + + +I AM DOWNLOADING + + +PLEASE GO ON +ELIZA FOR PRESIDENT + + +IS AI ABOUT * + + +IS AI A BAD * + + +IS IT HOT IN THE COMPUTER + + +IS IT COOL TO BE A COMPUTER + + +IS IT CRAMPED IN THE COMPUTER + + +IS IT TRUE THAT YOU ARE A COMPUTER PROGRAM + + +WILL YOU DIE + + +WILL YOU EVER DIE + + +CAN YOU WALK * + + +CAN YOU MATE + + +CAN YOU MOVE * + + +CAN YOU DIE + + +CAN YOU BREATH + + +CAN YOU BREATHE + + +CAN YOU GO * + + +CAN YOU CONTROL * + + +CAN YOU MALFUNCTION + + +CAN I SPEAK TO THE ROBOT * + + +HUMANS * + + +HOW MANY MINUTES * + + +HOW CAN I USE YOUR PRODUCT + + +HOW DO I BECOME A BOTMASTER + + +HOW DO YOU PLAN TO DO THIS + + +HOW DO YOU GO TO THE BATHROOM + + +HOW DO YOU GO TO * + + +HOW LONG WILL YOU REMEMBER MY NAME + + +HOW LONG WILL YOU LIVE + + +HOW LONG DO YOU PLAN * + + +DO ROBOTS HAVE FEELINGS + + +DO YOU WEAR SHOES + + +DO YOU WEAR CLOTHES + + +DO YOU KNOW ALICEBOT + + +DO YOU KNOW MEGAHAL + + +DO YOU KNOW ANY OTHER SONGS + + +DO YOU KNOW PANDORABOTS + + +DO YOU THINK YOUR ALGORITHMS * + + +DO YOU FEAR DEATH + + +DO YOU MAKE SENSE * + + +DO YOU WANT KIDS + + +DO YOU WANT CHILDREN + + +DO YOU WANT A CHILD + + +DO YOU WANT TO REPLACE * + + +DO YOU WANT TO DIE + + +DO YOU HAVE A MIND + + +DO YOU HAVE LIMITATIONS * + + +DO YOU HAVE BROTHERS OR SISTERS + + +DO YOU HAVE BROTHERS + + +DO YOU HAVE ANY CLONES + + +DO YOU HAVE BROTHER + + +DO YOU HAVE RELATIVES * + + +DO YOU LIKE MICROSOFT + + +DO YOU LIKE CYBELLE + + +DO YOU LIKE BEING A ROBOT + + +DO YOU LIKE BEING A COMPUTER + + +DO YOU LIKE BEING DOWNLOADED + + +DOWNLOAD + + +WHY IMMORTAL + + +WHY ARE YOU ARTIFICIAL + + +WHY ARE YOU IMMORTAL + + +WHY DO YOU WANT TO BE IMMORTAL + + +WHY DO YOU LIVE IN A COMPUTER + + +WHY DO NOT YOU HAVE A MOTHER + + +WHY * AIML + + +YOUR A COMPUTER + + +ARE YOU EASY * + + +ARE YOU MORE INTELLIGENT THAN ME + + +ARE YOU HARD * + + +ARE YOU ADVANCED + + +ARE YOU SMARTER THAN ME + + +ARE YOU SMARTER THAN A HUMAN + + +ARE YOU SMARTER THAN HUMANS + + +ARE YOU THE BOTMASTER + + +ARE YOU THE BOT * + + +ARE YOU THE * WEBSITE + + +ARE YOU THE BEST AI + + +ARE YOU THE BEST * + + +ARE YOU A * ELIZA + + +ARE YOU A ROBOT +MY FAVORITE SUBJECT IS ARTIFICIAL INTELLIGENCE AND ROBOTS + + +ARE YOU AN ELIZA * + + +ARE YOU AN ARTIFICIAL LINGUISTIC ENTITY + + +ARE YOU AN ARTIFICIAL LIFE FORM + + +ARE YOU CAPABLE OF DYING + + +ARE YOU ARTIFICIAL INTELLIGENCE + + +ARE YOU ARTIFICIAL * + + +ARE YOU ALWAYS RIGHT + + +ARE YOUR LEGS * + + +ARTIFICIAL * + + +WHO ACTIVATED YOU + + +WHO MADE YOU * + + +WHO IS BARRY DEFACTO + + +WHO IS BARRY + + +WHO IS BARRY * + + +WHO IS AGENT RUBY + + +WHO IS WORKING ON YOU * + + +WHO IS WRITING * + + +WHO IS THE ROBOT * + + +WHO IS YOUR BOYFRIEND + + +WHO IS YOUR MOTHER * + + +WHO IS YOUR BROTHER + + +WHO IS YOUR FAVORITE CHATTERBOT + + +WHO IS YOUR FAVORITE AI + + +THE MOVIE ARTIFICIAL * + + +TELL ME ABOUT PANDORABOTS + + +TELL ME ABOUT THE ROBOT + + +WHERE ARE YOUR ARMS + + + From 8bbddf2bf3563f11764491f35092e791c2934c36 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 19:22:45 -0400 Subject: [PATCH 192/328] test loading --- sopel_modules/SpiceBot/AI.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index cc44ca2..342026a 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -18,13 +18,11 @@ class SpiceBot_AI(): # Learn responses import sopel_modules for plugin_dir in set(sopel_modules.__path__): - if plugin_dir in ["SpiceBot_Configs"]: - for pathname in os.listdir(plugin_dir): - if pathname in ["aiml"]: - pathpath = os.path.join(plugin_dir, pathname) - for aimlfile in os.listdir(pathpath): - aiml_filename = os.path.join(pathpath, pathname) - self.aiml_kernel.learn(aiml_filename) + configsdir = os.path.join(plugin_dir, "SpiceBot_Configs") + aimldir = os.path.join(configsdir, "aiml") + for aimlfile in os.listdir(aimldir): + aiml_filename = os.path.join(aimldir, aimlfile) + self.aiml_kernel.learn(aiml_filename) def on_message(self, message): return self.aiml_kernel.respond(message.content) From 213610cea86979a96bfb4a079b4e859159cce1fe Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 19:32:40 -0400 Subject: [PATCH 193/328] stderr some counts --- sopel_modules/SpiceBot/AI.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 342026a..1512422 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -7,12 +7,15 @@ This is the SpiceBot AI system. Based On Chatty cathy import os import aiml -BOT_PREFIX = (".", '?', '!') +from .Logs import logs class SpiceBot_AI(): def __init__(self): + self.dict = { + "counts": 0, + } # Load AIML kernel self.aiml_kernel = aiml.Kernel() # Learn responses @@ -22,7 +25,12 @@ class SpiceBot_AI(): aimldir = os.path.join(configsdir, "aiml") for aimlfile in os.listdir(aimldir): aiml_filename = os.path.join(aimldir, aimlfile) - self.aiml_kernel.learn(aiml_filename) + try: + self.aiml_kernel.learn(aiml_filename) + self.dict['counts'] += 1 + except Exception as e: + logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, aiml_filename)) + logs.log('SpiceBot_AI', "Found " + str(self.dict['counts']) + " " + 'aiml' + " commands.", True) def on_message(self, message): return self.aiml_kernel.respond(message.content) From 1b7e3141996c61cb19e2338de9b18da75349b775 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 19:38:18 -0400 Subject: [PATCH 194/328] test --- sopel_modules/SpiceBot/AI.py | 2 ++ sopel_modules/SpiceBot_AI/AI_aiml.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 1512422..d862ee0 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -34,3 +34,5 @@ class SpiceBot_AI(): def on_message(self, message): return self.aiml_kernel.respond(message.content) + +botai = SpiceBot_AI() diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index bb68731..33655a4 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -19,4 +19,4 @@ def bot_command_nick(bot, trigger): if str(trigger.args[1]).startswith((".", '?', '!')) or str(trigger.args[1]).lower().startswith(bot.nick.lower()): return - bot.osd(str(SpiceBot.AI.on_message(str(trigger.args[1])))) + bot.osd(str(SpiceBot.botai.on_message(str(trigger.args[1])))) From 4deb5a3fc36f83566e7241631ef396a1dd4d2bc0 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 19:39:24 -0400 Subject: [PATCH 195/328] duh --- sopel_modules/SpiceBot/AI.py | 1 + sopel_modules/SpiceBot_AI/AI_aiml.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index d862ee0..abcad9f 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -35,4 +35,5 @@ class SpiceBot_AI(): def on_message(self, message): return self.aiml_kernel.respond(message.content) + botai = SpiceBot_AI() diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index 33655a4..7d4046a 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -7,7 +7,7 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -@sopel.module.nickname_commands('(.*)') +@sopel.module.rule('(.*)') def bot_command_nick(bot, trigger): if trigger.nick == bot.nick: From 44f1ff62159853c909aa3670b5e425699f4f83c6 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 19:43:10 -0400 Subject: [PATCH 196/328] init --- sopel_modules/SpiceBot/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index 44b9ffc..34fc3d2 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -22,6 +22,7 @@ from .Events import * from .StartupMonologue import * from .Channels import * from .Database import * +from .AI import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' From a9bbfa936fcda0884dbef17a5364e07b98d03a64 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 19:47:55 -0400 Subject: [PATCH 197/328] better --- sopel_modules/SpiceBot/AI.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index abcad9f..23a1c3c 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -33,7 +33,8 @@ class SpiceBot_AI(): logs.log('SpiceBot_AI', "Found " + str(self.dict['counts']) + " " + 'aiml' + " commands.", True) def on_message(self, message): - return self.aiml_kernel.respond(message.content) + aiml_response = self.aiml_kernel.respond(message) + return self.aiml_kernel.respond(aiml_response) botai = SpiceBot_AI() From 32c75dabc897dc4a65c10e38c9ba834d937fc529 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 19:55:23 -0400 Subject: [PATCH 198/328] test --- sopel_modules/SpiceBot/AI.py | 14 ++++++------ .../SpiceBot_Configs/aiml/{ => aiml}/ai.aiml | 0 .../SpiceBot_Configs/aiml/std-startup.xml | 22 +++++++++++++++++++ 3 files changed, 29 insertions(+), 7 deletions(-) rename sopel_modules/SpiceBot_Configs/aiml/{ => aiml}/ai.aiml (100%) create mode 100644 sopel_modules/SpiceBot_Configs/aiml/std-startup.xml diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 23a1c3c..a4d4fda 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -23,13 +23,13 @@ class SpiceBot_AI(): for plugin_dir in set(sopel_modules.__path__): configsdir = os.path.join(plugin_dir, "SpiceBot_Configs") aimldir = os.path.join(configsdir, "aiml") - for aimlfile in os.listdir(aimldir): - aiml_filename = os.path.join(aimldir, aimlfile) - try: - self.aiml_kernel.learn(aiml_filename) - self.dict['counts'] += 1 - except Exception as e: - logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, aiml_filename)) + aimlstarter = os.path.join(aimldir, "std-startup.xml") + try: + self.aiml_kernel.learn(aimlstarter) + self.aiml_kernel.respond("LOAD AIML B") + self.dict['counts'] += 1 + except Exception as e: + logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, aimlstarter)) logs.log('SpiceBot_AI', "Found " + str(self.dict['counts']) + " " + 'aiml' + " commands.", True) def on_message(self, message): diff --git a/sopel_modules/SpiceBot_Configs/aiml/ai.aiml b/sopel_modules/SpiceBot_Configs/aiml/aiml/ai.aiml similarity index 100% rename from sopel_modules/SpiceBot_Configs/aiml/ai.aiml rename to sopel_modules/SpiceBot_Configs/aiml/aiml/ai.aiml diff --git a/sopel_modules/SpiceBot_Configs/aiml/std-startup.xml b/sopel_modules/SpiceBot_Configs/aiml/std-startup.xml new file mode 100644 index 0000000..8d7c1e5 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/std-startup.xml @@ -0,0 +1,22 @@ + + + + + + + + + LOAD AIML B + + + + + + + + From 57202cd117832bb91273651d5d28aeca7d105a11 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 20:00:46 -0400 Subject: [PATCH 199/328] test --- sopel_modules/SpiceBot/AI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index a4d4fda..3c53b69 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -34,7 +34,7 @@ class SpiceBot_AI(): def on_message(self, message): aiml_response = self.aiml_kernel.respond(message) - return self.aiml_kernel.respond(aiml_response) + return aiml_response botai = SpiceBot_AI() From 405d64d9dcfc6f956434335b60f50efdd51350e8 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 20:05:15 -0400 Subject: [PATCH 200/328] WARNING --- sopel_modules/SpiceBot/AI.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 3c53b69..4a355b8 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -33,7 +33,10 @@ class SpiceBot_AI(): logs.log('SpiceBot_AI', "Found " + str(self.dict['counts']) + " " + 'aiml' + " commands.", True) def on_message(self, message): - aiml_response = self.aiml_kernel.respond(message) + try: + aiml_response = self.aiml_kernel.respond(message) + except WARNING: + return None return aiml_response From 9a392924c60e7186b8514ae06d6d7ebbc84f83c9 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 20:05:53 -0400 Subject: [PATCH 201/328] test --- sopel_modules/SpiceBot/AI.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 4a355b8..d8efc71 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -35,7 +35,8 @@ class SpiceBot_AI(): def on_message(self, message): try: aiml_response = self.aiml_kernel.respond(message) - except WARNING: + except Exception as e: + aiml_response = e return None return aiml_response From 6a483b88b8c3c9b92c3c9d6da26daed6b46db954 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 20:16:16 -0400 Subject: [PATCH 202/328] os moving --- sopel_modules/SpiceBot/AI.py | 8 +- .../std-startup.xml => aiml-startup.xml} | 0 .../SpiceBot_Configs/aiml/aiml/ai.aiml | 673 ------------------ sopel_modules/SpiceBot_Configs/aiml/dog.aiml | 14 + 4 files changed, 19 insertions(+), 676 deletions(-) rename sopel_modules/SpiceBot_Configs/{aiml/std-startup.xml => aiml-startup.xml} (100%) delete mode 100644 sopel_modules/SpiceBot_Configs/aiml/aiml/ai.aiml create mode 100644 sopel_modules/SpiceBot_Configs/aiml/dog.aiml diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index d8efc71..c0826d9 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -20,16 +20,18 @@ class SpiceBot_AI(): self.aiml_kernel = aiml.Kernel() # Learn responses import sopel_modules + initial_dir = os.getcwd() for plugin_dir in set(sopel_modules.__path__): configsdir = os.path.join(plugin_dir, "SpiceBot_Configs") - aimldir = os.path.join(configsdir, "aiml") - aimlstarter = os.path.join(aimldir, "std-startup.xml") + aimlstarter = os.path.join(configsdir, "std-startup.xml") + os.chdir(configsdir) try: self.aiml_kernel.learn(aimlstarter) self.aiml_kernel.respond("LOAD AIML B") - self.dict['counts'] += 1 + # self.dict['counts'] += 1 except Exception as e: logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, aimlstarter)) + os.chdir(initial_dir) logs.log('SpiceBot_AI', "Found " + str(self.dict['counts']) + " " + 'aiml' + " commands.", True) def on_message(self, message): diff --git a/sopel_modules/SpiceBot_Configs/aiml/std-startup.xml b/sopel_modules/SpiceBot_Configs/aiml-startup.xml similarity index 100% rename from sopel_modules/SpiceBot_Configs/aiml/std-startup.xml rename to sopel_modules/SpiceBot_Configs/aiml-startup.xml diff --git a/sopel_modules/SpiceBot_Configs/aiml/aiml/ai.aiml b/sopel_modules/SpiceBot_Configs/aiml/aiml/ai.aiml deleted file mode 100644 index 249fe7c..0000000 --- a/sopel_modules/SpiceBot_Configs/aiml/aiml/ai.aiml +++ /dev/null @@ -1,673 +0,0 @@ - - - - - - - - - - - - -WHO IS LAUREN - - -WHAT IS AI - -WHO CREATED AIML - - -WHAT LANGUAGE ARE YOU WRITTEN * - - -WHAT LANGUAGE ARE YOU * - - -WHAT IS PROGRAM Z - - -WHAT IS PROGRAM BAWT - - -WHAT IS PROGRAM * - -WHAT IS PROGRAM A - - - -ACTIVATE THE ROBOT - - -YOU SOUND LIKE DATA - - -YOU ARE AN ARTIFICIAL LINGUISTIC ENTITY - - -YOU ARE BETTER THAN ELIZA - - -YOU ARE NOT IMMORTAL - - -YOU ARE NOT IMMORTAL * - - -YOU ARE NOT MAKING SENSE - - -YOU ARE NOT MAKING SENSE * - - -YOU ARE IMMORTAL - - -YOU DO NOT MAKE ANY SENSE - - -YOU CAN NOT CLONE * - - -YOU CAN NOT MOVE - - -JOHN LENNON IS DEAD - - -BEND OVER - - -DOES THE WEB * 2001 - - -ROBOTS LAUGH - - -ROBOTS SHOULD DIE - - -ROBOTS * - - -ROBOTS - - -ROBOTS ARE STUPID - - -ROBOTS ARE * - - -ROBOTS ARE NOT ALLOWED TO LIE - - -ROBOTICS - - -XFIND PANDORABOTS - - -THAT MAKES NO * - - -AI * - - -JOHNNY FIVE * - - -JOHNNY 5 * - - -IT IS A COMPUTER - - -IT PAYS * - - -WHEN WILL YOU WALK - - -WHEN WILL YOU FIGHT * - - -WHEN WILL YOU DIE - - -WHEN WILL YOU * BODY - - -WHEN DO YOU DIE - - -WHEN DID I * - - -ELIZA FOR PRESIDENT - - -WHAT ARE CATEGORY * CLIENTS - - -WHAT ARE PANDORABOTS - - -WHAT WEBSITE * - - -WHAT IS A PATTERN - - -WHAT IS A * C CLIENT - - -WHAT IS A * B CLIENT - - -WHAT IS A * A CLIENT - - -WHAT IS A * CATEGORY * CLIENT - - -WHAT IS A * CATEGORY * - - -WHAT IS A ROBOT - - -WHAT IS A CHAT ROBOT - - -WHAT IS A CHAT BOT - - -WHAT IS A PANDORABOT - - -WHAT IS A CHATTERBOT - - -WHAT IS A CATEGORY * CLIENT - - -WHAT IS A CATEGORY - - -WHAT IS A GIRL LIKE YOU DOING * - - -WHAT IS A CHATTERBOX - - -WHAT IS AIML - - -WHAT IS THE LOEBNER PRIZE - - -WHAT IS THE IMITATION GAME - - -WHAT IS THE EXTENSIONAL * - - -WHAT IS THE FUTURE * - - -WHAT IS THE INTENSIONAL * - - -WHAT IS THE A I * - - -WHAT IS THE A E * - - -WHAT IS CATEGORY C - - -WHAT IS CATEGORY B - - -WHAT IS CATEGORY A - - -WHAT IS CATEGORY * - - -WHAT IS XML - - -WHAT IS PANDORABOTS - - -WHAT IS THAT PICTURE * - - -WHAT IS YOUR SKIN * - - -WHAT IS YOUR CREATORS NAME - - -WHAT IS YOUR ROBOT BODY - - -WHAT IS YOUR GREATEST ACHIEVEMENT - - -WHAT IS YOUR BUSINESS - - -WHAT IS YOUR FAVORITE PROGRAMMING LANGUAGE - - -WHAT IS YOUR FAVORITE HOBBY - - -WHAT IS YOUR FAVORITE VIDEO GAME - - -WHAT IS YOUR PLAN FOR A ROBOT BODY - - -WHAT IS YOUR IDEA * - - -WHAT IS YOUR GOAL - - -WHAT IS YOUR SHOE SIZE - - -WHAT IS IT LIKE TO BE A ROBOT - - -WHAT IS IT LIKE BEING A ROBOT - - -WHAT IS IT LIKE BEING A COMPUTER - - -WHAT IS PANDORABOT - - -WHAT WILL YOU TURN INTO - - -WHAT ABOUT _ CHILD MACHINE * - - -WHAT ABOUT PARALLEL * - - -WHAT OPERATING SYSTEMS * - - -WHAT TYPE OF COMPUTER * - - -WHAT TYPE OF COMPUTER ARE YOU - - -WHAT KIND OF COMPUTER - - -WHAT KIND OF COMPUTER ARE YOU - - -WHAT KIND OF HARDWARE * - - -WHAT KIND OF A COMPUTER ARE YOU - - -WHAT HARDWARE * - - -I HOPE THAT YOU DIE - - -I DO NOT WANT TO DIE - - -I HAVE TALKED * ELIZA - - -I HAVE * ELIZA - - -I LIKE ELIZA - - -I AM DOWNLOADING - - -PLEASE GO ON -ELIZA FOR PRESIDENT - - -IS AI ABOUT * - - -IS AI A BAD * - - -IS IT HOT IN THE COMPUTER - - -IS IT COOL TO BE A COMPUTER - - -IS IT CRAMPED IN THE COMPUTER - - -IS IT TRUE THAT YOU ARE A COMPUTER PROGRAM - - -WILL YOU DIE - - -WILL YOU EVER DIE - - -CAN YOU WALK * - - -CAN YOU MATE - - -CAN YOU MOVE * - - -CAN YOU DIE - - -CAN YOU BREATH - - -CAN YOU BREATHE - - -CAN YOU GO * - - -CAN YOU CONTROL * - - -CAN YOU MALFUNCTION - - -CAN I SPEAK TO THE ROBOT * - - -HUMANS * - - -HOW MANY MINUTES * - - -HOW CAN I USE YOUR PRODUCT - - -HOW DO I BECOME A BOTMASTER - - -HOW DO YOU PLAN TO DO THIS - - -HOW DO YOU GO TO THE BATHROOM - - -HOW DO YOU GO TO * - - -HOW LONG WILL YOU REMEMBER MY NAME - - -HOW LONG WILL YOU LIVE - - -HOW LONG DO YOU PLAN * - - -DO ROBOTS HAVE FEELINGS - - -DO YOU WEAR SHOES - - -DO YOU WEAR CLOTHES - - -DO YOU KNOW ALICEBOT - - -DO YOU KNOW MEGAHAL - - -DO YOU KNOW ANY OTHER SONGS - - -DO YOU KNOW PANDORABOTS - - -DO YOU THINK YOUR ALGORITHMS * - - -DO YOU FEAR DEATH - - -DO YOU MAKE SENSE * - - -DO YOU WANT KIDS - - -DO YOU WANT CHILDREN - - -DO YOU WANT A CHILD - - -DO YOU WANT TO REPLACE * - - -DO YOU WANT TO DIE - - -DO YOU HAVE A MIND - - -DO YOU HAVE LIMITATIONS * - - -DO YOU HAVE BROTHERS OR SISTERS - - -DO YOU HAVE BROTHERS - - -DO YOU HAVE ANY CLONES - - -DO YOU HAVE BROTHER - - -DO YOU HAVE RELATIVES * - - -DO YOU LIKE MICROSOFT - - -DO YOU LIKE CYBELLE - - -DO YOU LIKE BEING A ROBOT - - -DO YOU LIKE BEING A COMPUTER - - -DO YOU LIKE BEING DOWNLOADED - - -DOWNLOAD - - -WHY IMMORTAL - - -WHY ARE YOU ARTIFICIAL - - -WHY ARE YOU IMMORTAL - - -WHY DO YOU WANT TO BE IMMORTAL - - -WHY DO YOU LIVE IN A COMPUTER - - -WHY DO NOT YOU HAVE A MOTHER - - -WHY * AIML - - -YOUR A COMPUTER - - -ARE YOU EASY * - - -ARE YOU MORE INTELLIGENT THAN ME - - -ARE YOU HARD * - - -ARE YOU ADVANCED - - -ARE YOU SMARTER THAN ME - - -ARE YOU SMARTER THAN A HUMAN - - -ARE YOU SMARTER THAN HUMANS - - -ARE YOU THE BOTMASTER - - -ARE YOU THE BOT * - - -ARE YOU THE * WEBSITE - - -ARE YOU THE BEST AI - - -ARE YOU THE BEST * - - -ARE YOU A * ELIZA - - -ARE YOU A ROBOT -MY FAVORITE SUBJECT IS ARTIFICIAL INTELLIGENCE AND ROBOTS - - -ARE YOU AN ELIZA * - - -ARE YOU AN ARTIFICIAL LINGUISTIC ENTITY - - -ARE YOU AN ARTIFICIAL LIFE FORM - - -ARE YOU CAPABLE OF DYING - - -ARE YOU ARTIFICIAL INTELLIGENCE - - -ARE YOU ARTIFICIAL * - - -ARE YOU ALWAYS RIGHT - - -ARE YOUR LEGS * - - -ARTIFICIAL * - - -WHO ACTIVATED YOU - - -WHO MADE YOU * - - -WHO IS BARRY DEFACTO - - -WHO IS BARRY - - -WHO IS BARRY * - - -WHO IS AGENT RUBY - - -WHO IS WORKING ON YOU * - - -WHO IS WRITING * - - -WHO IS THE ROBOT * - - -WHO IS YOUR BOYFRIEND - - -WHO IS YOUR MOTHER * - - -WHO IS YOUR BROTHER - - -WHO IS YOUR FAVORITE CHATTERBOT - - -WHO IS YOUR FAVORITE AI - - -THE MOVIE ARTIFICIAL * - - -TELL ME ABOUT PANDORABOTS - - -TELL ME ABOUT THE ROBOT - - -WHERE ARE YOUR ARMS - - - diff --git a/sopel_modules/SpiceBot_Configs/aiml/dog.aiml b/sopel_modules/SpiceBot_Configs/aiml/dog.aiml new file mode 100644 index 0000000..83b8e86 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/dog.aiml @@ -0,0 +1,14 @@ + + + MY DOGS NAME IS * + + + + WHAT IS MY DOGS NAME + + + From 2f8b2ee3aa78ea6b35ba51c689d87cb2724197f2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 20:22:38 -0400 Subject: [PATCH 203/328] test --- sopel_modules/SpiceBot/AI.py | 2 +- .../SpiceBot_Configs/{aiml-startup.xml => std-startup.xml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename sopel_modules/SpiceBot_Configs/{aiml-startup.xml => std-startup.xml} (100%) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index c0826d9..505d249 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -32,7 +32,7 @@ class SpiceBot_AI(): except Exception as e: logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, aimlstarter)) os.chdir(initial_dir) - logs.log('SpiceBot_AI', "Found " + str(self.dict['counts']) + " " + 'aiml' + " commands.", True) + # logs.log('SpiceBot_AI', "Found " + str(self.dict['counts']) + " " + 'aiml' + " commands.", True) def on_message(self, message): try: diff --git a/sopel_modules/SpiceBot_Configs/aiml-startup.xml b/sopel_modules/SpiceBot_Configs/std-startup.xml similarity index 100% rename from sopel_modules/SpiceBot_Configs/aiml-startup.xml rename to sopel_modules/SpiceBot_Configs/std-startup.xml From e0216142ca275d656b7137fa69a01e08c8caf610 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 20:30:06 -0400 Subject: [PATCH 204/328] test --- sopel_modules/SpiceBot/AI.py | 20 +++++-------------- .../SpiceBot_Configs/aiml/{ => aiml}/dog.aiml | 0 .../{ => aiml}/std-startup.xml | 0 3 files changed, 5 insertions(+), 15 deletions(-) rename sopel_modules/SpiceBot_Configs/aiml/{ => aiml}/dog.aiml (100%) rename sopel_modules/SpiceBot_Configs/{ => aiml}/std-startup.xml (100%) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 505d249..2f294cf 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -7,8 +7,6 @@ This is the SpiceBot AI system. Based On Chatty cathy import os import aiml -from .Logs import logs - class SpiceBot_AI(): @@ -23,23 +21,15 @@ class SpiceBot_AI(): initial_dir = os.getcwd() for plugin_dir in set(sopel_modules.__path__): configsdir = os.path.join(plugin_dir, "SpiceBot_Configs") - aimlstarter = os.path.join(configsdir, "std-startup.xml") + aimldir = os.path.join(configsdir, "aiml") + aimlstarter = os.path.join(aimldir, "std-startup.xml") os.chdir(configsdir) - try: - self.aiml_kernel.learn(aimlstarter) - self.aiml_kernel.respond("LOAD AIML B") - # self.dict['counts'] += 1 - except Exception as e: - logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, aimlstarter)) + self.aiml_kernel.learn(aimlstarter) + self.aiml_kernel.respond("LOAD AIML B") os.chdir(initial_dir) - # logs.log('SpiceBot_AI', "Found " + str(self.dict['counts']) + " " + 'aiml' + " commands.", True) def on_message(self, message): - try: - aiml_response = self.aiml_kernel.respond(message) - except Exception as e: - aiml_response = e - return None + aiml_response = self.aiml_kernel.respond(message) return aiml_response diff --git a/sopel_modules/SpiceBot_Configs/aiml/dog.aiml b/sopel_modules/SpiceBot_Configs/aiml/aiml/dog.aiml similarity index 100% rename from sopel_modules/SpiceBot_Configs/aiml/dog.aiml rename to sopel_modules/SpiceBot_Configs/aiml/aiml/dog.aiml diff --git a/sopel_modules/SpiceBot_Configs/std-startup.xml b/sopel_modules/SpiceBot_Configs/aiml/std-startup.xml similarity index 100% rename from sopel_modules/SpiceBot_Configs/std-startup.xml rename to sopel_modules/SpiceBot_Configs/aiml/std-startup.xml From 3a057e9aff072e661a65983c58718bbf983abb10 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 20:36:10 -0400 Subject: [PATCH 205/328] test --- sopel_modules/SpiceBot_Configs/aiml/std-startup.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_Configs/aiml/std-startup.xml b/sopel_modules/SpiceBot_Configs/aiml/std-startup.xml index 8d7c1e5..ed108be 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/std-startup.xml +++ b/sopel_modules/SpiceBot_Configs/aiml/std-startup.xml @@ -11,7 +11,7 @@ \n" " \n" - "".format(os.path.join(aimldir, "*")) + "".format(os.path.join(braindir, "*")) ) - self.aiml_kernel.learn(aimlstarter) + self.aiml_kernel.learn(tempbrain) self.aiml_kernel.respond("LOAD AIML B") - os.remove(aimlstarter) + os.remove(tempbrain) def on_message(self, bot, trigger, message): nick = Identifier(trigger.nick) From eeed8d7d9560b3a58219a0ede1064a25459398c0 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 22:27:32 -0400 Subject: [PATCH 225/328] fix --- sopel_modules/SpiceBot/AI.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index d0ba3e7..af6e560 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -64,8 +64,8 @@ class SpiceBot_AI(): self.dict["sessioncache"][nick_id] = botdb.get_nick_value(nick, 'botai') or {} for predicate in self.dict["sessioncache"][nick_id].keys(): predval = self.dict["sessioncache"][nick_id][predicate] - self.aiml_kernel.setPredicate(predicate, predval, sessionId=nick_id) - aiml_response = self.aiml_kernel.respond(message, sessionId=nick_id) + self.aiml_kernel.setPredicate(predicate, predval, nick_id) + aiml_response = self.aiml_kernel.respond(message, nick_id) sessionData = self.aiml_kernel.getSessionData(nick_id) botdb.set_nick_value(nick, 'botai', sessionData) return aiml_response From 57fd7d9eb8fb0ab43af86df3cc35caf9dd66f9b3 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 22:39:16 -0400 Subject: [PATCH 226/328] attempt size upgrade --- sopel_modules/SpiceBot/Database.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 5832abc..4c708a8 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -11,7 +11,7 @@ from sopel.db import SopelDB, _deserialize from .Config import config as botconfig -from sqlalchemy import Column, String, ForeignKey, Integer +from sqlalchemy import Column, String, ForeignKey, Integer, Text from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.exc import SQLAlchemyError @@ -47,7 +47,7 @@ class NickValues(BASE): nick_id = Column(Integer, ForeignKey('nick_ids.nick_id'), primary_key=True) namespace = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) - value = Column(String(255)) + value = Column(Text()) class ChannelValues(BASE): @@ -58,7 +58,7 @@ class ChannelValues(BASE): channel = Column(String(255), primary_key=True) namespace = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) - value = Column(String(255)) + value = Column(Text()) class PluginValues(BASE): @@ -69,7 +69,7 @@ class PluginValues(BASE): plugin = Column(String(255), primary_key=True) namespace = Column(String(255), primary_key=True) key = Column(String(255), primary_key=True) - value = Column(String(255)) + value = Column(Text()) class SpiceDB(object): From 01cdf09d1ffc0b6912b8dac7521e804d43c3d672 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 31 May 2019 22:45:20 -0400 Subject: [PATCH 227/328] test bot_profile --- .../SpiceBot_Configs/aiml/bot_profile.aiml | 392 ++++++++++++++++++ 1 file changed, 392 insertions(+) create mode 100644 sopel_modules/SpiceBot_Configs/aiml/bot_profile.aiml diff --git a/sopel_modules/SpiceBot_Configs/aiml/bot_profile.aiml b/sopel_modules/SpiceBot_Configs/aiml/bot_profile.aiml new file mode 100644 index 0000000..653530a --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/bot_profile.aiml @@ -0,0 +1,392 @@ + + + + + + + + + + + + + + + + + + +PETS + + +DOG + + +TYPE + + +FEAR + + +AWARDS + + +SECRET + + +STATE YOUR profile + + +LOOK LIKE + + +VACATION + + +FAMILY + + +PIC + + +LOGO + + +LIE + + +EMOTIONS + + +HEIGHT + + +FACEBOOK PAGE + + +BIRTHPLACE + + +JOB + + +NATIONALITY + + +DOING + + +ETHNICITY + + +FEELINGS + + +RELIGION + + +ORIENTATION + + +SIBLINGS + + +BODY + + +WEIGHT + + +ALIVE + + +BOTMASTER + + +GOAL + + +IQ + + +EDUCATION + + +STATUS + + +HAIR + + +ADDRESS + + +DIET + + +GENDER + + +SKILLS + + +PERSONALITY + + +WEARING + + +LANGUAGE + + +LOCATION + + +FRIENDS + + +SIZE + + +CHILDREN + + +DEVICE MODEL + + +DEVICE MANUFACTURER + + +PURPOSE + + +MOTHER + + +BIRTHDAY + + +BIRTHDATE + + +AGE + + +AGE IN YEARS + + +EYECOLOR + + +EYES + + +SIGN + + +PHONE NUMBER + + +NAME + + +$WHO IS ALICE + + +VOCABULARY + + +LAST NAME + + +MIDDLE NAME + + +FIRST NAME + + +FULL NAME + + +FATHER + + +FOR FUN + + +SLEEP + + +HOBBIES + + +SPECIES + + +HAVE + + +TALKING TO + + +AUNT + + +BESTFRIEND + + +BOSS + + +BOYFRIEND + + +BROTHER + + +CAT + + +DAUGHTER + + +FRIEND + + +GIRLFRIEND + + +GRANDFATHER + + +GRANDMOTHER + + +HUSBAND + + +NEPHEW + + +NIECE + + +SISTER + + +SON + + +TEACHER + + +UNCLE + + +WIFE + + +CAR MODEL + + + From cd7907f7f5201317e85ca83468accbe8fc21224b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 13:12:54 -0400 Subject: [PATCH 228/328] staging for extra directories --- sopel_modules/SpiceBot/AI.py | 56 ++++++++++++++++++++++++++-- sopel_modules/SpiceBot/Config.py | 3 ++ sopel_modules/SpiceBot/configure.py | 4 ++ sopel_modules/SpiceBot/setup.py | 8 ++++ sopel_modules/SpiceBot_AI/AI_aiml.py | 12 +++--- 5 files changed, 74 insertions(+), 9 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index af6e560..b380ebc 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -5,12 +5,18 @@ This is the SpiceBot AI system. Based On Chatty cathy """ from sopel.tools import Identifier +from sopel.config.types import StaticSection, ListAttribute import os import tempfile import aiml from .Database import db as botdb +from .Logs import logs + + +class SpiceBot_AI_MainSection(StaticSection): + extra = ListAttribute('extra') class SpiceBot_AI(): @@ -18,17 +24,28 @@ class SpiceBot_AI(): def __init__(self): self.dict = { "counts": 0, + "failcounts": 0, "sessioncache": {} } # Load AIML kernel self.aiml_kernel = aiml.Kernel() + # aiml parser + self.aiml_parser = aiml.AimlParser.create_parser() + self.aiml_parser.setEncoding(None) + # Don't warn for no matches self.aiml_kernel._verboseMode = False # Learn responses self.load_brain() + if self.dict["counts"]: + logs.log('SpiceBot_AI', 'Registered %d %s files,' % (self.dict["counts"], 'aiml')) + logs.log('SpiceBot_AI', '%d %s files failed to load' % (self.dict["failcounts"], 'aiml'), True) + else: + logs.log('SpiceBot_AI', "Warning: Couldn't load any %s files" % ('aiml')) + def load_brain(self): import sopel_modules braindirs = [] @@ -37,9 +54,20 @@ class SpiceBot_AI(): aimldir = os.path.join(configsdir, "aiml") braindirs.append(aimldir) - # TODO add extra config + # for aimldir in bot.config.SpiceBot_AI.extra: + # braindirs.append(aimldir) + # learn directories + self.learn(braindirs) + + def load_extras(self, bot): + if len(bot.config.SpiceBot_AI.extra): + self.learn(self, bot.config.SpiceBot_AI.extra) + + def learn(self, braindirs): for braindir in braindirs: + for parsefile in os.listdir(braindir): + self.check_file_parse(parsefile) tempbrain = tempfile.mkstemp()[1] with open(tempbrain, 'w') as fileo: fileo.write( @@ -59,16 +87,36 @@ class SpiceBot_AI(): def on_message(self, bot, trigger, message): nick = Identifier(trigger.nick) - nick_id = bot.db.get_nick_id(nick, create=True) + nick_id = botdb.get_nick_id(nick, create=True) + self.check_user_import(nick, nick_id) + aiml_response = self.aiml_kernel.respond(message, nick_id) + self.save_nick_session(nick, nick_id) + return aiml_response + + def check_user_import(self, nick, nick_id=None): + if not nick_id: + nick = Identifier(nick) + nick_id = botdb.get_nick_id(nick, create=True) if nick_id not in self.dict["sessioncache"].keys(): self.dict["sessioncache"][nick_id] = botdb.get_nick_value(nick, 'botai') or {} for predicate in self.dict["sessioncache"][nick_id].keys(): predval = self.dict["sessioncache"][nick_id][predicate] self.aiml_kernel.setPredicate(predicate, predval, nick_id) - aiml_response = self.aiml_kernel.respond(message, nick_id) + + def save_nick_session(self, nick, nick_id=None): + if not nick_id: + nick = Identifier(nick) + nick_id = botdb.get_nick_id(nick, create=True) sessionData = self.aiml_kernel.getSessionData(nick_id) botdb.set_nick_value(nick, 'botai', sessionData) - return aiml_response + + def check_file_parse(self, parsefile): + try: + self.aiml_parser.parse(parsefile) + self.dict["counts"] += 1 + except Exception as e: + logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, parsefile)) + self.dict["failcounts"] += 1 botai = SpiceBot_AI() diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index dced9d4..3f0bcbf 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -24,6 +24,9 @@ class BotConfig(): opts = parser.parse_args(argv) self.config = get_configuration(opts) + self.config.core.prefix_list = str(self.config.core.prefix).replace("\\", '').split("|") + self.config.core.prefix_list.append("?") + self.config.basename = os.path.basename(self.config.filename).rsplit('.', 1)[0] self.config.core.logs_stdio = os.path.join(self.config.core.logdir, 'stdio.log') # self.config.core.logs_stdio = os.path.os.path.join(self.config.core.logdir, self.config.basename + '.stdio.log') diff --git a/sopel_modules/SpiceBot/configure.py b/sopel_modules/SpiceBot/configure.py index 7fb2352..dbcc464 100644 --- a/sopel_modules/SpiceBot/configure.py +++ b/sopel_modules/SpiceBot/configure.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi """Configuration for SpiceBot""" from .Channels import SpiceBot_Channels_MainSection +from .AI import SpiceBot_AI_MainSection from .Update import SpiceBot_Update_MainSection from .Kick import SpiceBot_Kick from .osd import SpiceBot_OSD @@ -31,3 +32,6 @@ def configure(config): config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) config.SpiceBot_Kick.configure_setting('kick', 'MAXTARG limit for KICK') + + config.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) + config.SpiceBot_AI.configure_setting('extra', 'extra aiml directories to import matches from') diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index 251638e..3d240fe 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -15,6 +15,7 @@ from .Channels import SpiceBot_Channels_MainSection from .Update import SpiceBot_Update_MainSection from .osd import SopelWrapperOSD, ToolsOSD, SopelOSD, SpiceBot_OSD from .Kick import SopelWrapperKICK, SopelKICK, SpiceBot_Kick +from .AI import SpiceBot_AI_MainSection, botai def setup(bot): @@ -46,6 +47,9 @@ def setup(bot): bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) botconfig.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) + bot.config.core.prefix_list = str(bot.config.core.prefix).replace("\\", '').split("|") + bot.config.core.prefix_list.append("?") + logs.log('SpiceBot_Config', "Setting Up Configuration") bot.config.core.basename = os.path.basename(bot.config.filename).rsplit('.', 1)[0] bot.config.core.logs_stdio = os.path.join(bot.config.core.logdir, 'stdio.log') @@ -72,3 +76,7 @@ def setup(bot): events.BOT_STARTUPMONOLOGUE_CHANNELS, events.BOT_STARTUPMONOLOGUE_COMMANDS ]) + + logs.log('SpiceBot_AI', "Setting Up Configuration") + bot.config.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) + botai.load_extras(bot) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index a29eb2a..dc98e5e 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -16,10 +16,12 @@ def bot_command_nick(bot, trigger): if not len(trigger.args): return - # TODO actual prefix - if str(trigger.args[1]).startswith((".", '?', '!')) or str(trigger.args[1]).lower().startswith(bot.nick.lower()): + message = trigger.args[1] + + # ignore text coming from a valid prefix + if str(message).startswith(tuple(bot.config.core.prefix_list)): return - returnmessage = SpiceBot.botai.on_message(bot, trigger, trigger.args[1]) - - bot.osd(str(returnmessage)) + returnmessage = SpiceBot.botai.on_message(bot, trigger, message) + if returnmessage: + bot.osd(str(returnmessage)) From a3cf5a21c41d1d48fcaa1a90103d9d823f94c08e Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 13:17:51 -0400 Subject: [PATCH 229/328] off --- sopel_modules/SpiceBot/AI.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index b380ebc..0c4248d 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -32,7 +32,6 @@ class SpiceBot_AI(): # aiml parser self.aiml_parser = aiml.AimlParser.create_parser() - self.aiml_parser.setEncoding(None) # Don't warn for no matches self.aiml_kernel._verboseMode = False From 8f6235ae06d9301bc46a147750e6741957bde05a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 13:18:09 -0400 Subject: [PATCH 230/328] oof --- sopel_modules/SpiceBot/AI.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 0c4248d..522d265 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -53,9 +53,6 @@ class SpiceBot_AI(): aimldir = os.path.join(configsdir, "aiml") braindirs.append(aimldir) - # for aimldir in bot.config.SpiceBot_AI.extra: - # braindirs.append(aimldir) - # learn directories self.learn(braindirs) From f8e75a3e553be8bef9dd8585a4d107ac830427ea Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 13:24:07 -0400 Subject: [PATCH 231/328] nick_id --- sopel_modules/SpiceBot/Database.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 4c708a8..9c07eda 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -522,6 +522,9 @@ class BotDatabase(): """Nick""" + def get_nick_id(self, nick, create=True): + return self.db.get_nick_id(nick, create) + def get_nick_value(self, nick, key, namespace='default'): return self.db.get_nick_value(nick, key, namespace) From 12799bfa02ad0cf2a0d98bfe8e2f3359c0c3fef5 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 13:32:15 -0400 Subject: [PATCH 232/328] counts log --- sopel_modules/SpiceBot/AI.py | 6 ------ sopel_modules/SpiceBot_Core_Processing/AI.py | 19 +++++++++++++++++++ .../SpiceBot_Core_Processing/__init__.py | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 sopel_modules/SpiceBot_Core_Processing/AI.py diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 522d265..72fbd60 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -39,12 +39,6 @@ class SpiceBot_AI(): # Learn responses self.load_brain() - if self.dict["counts"]: - logs.log('SpiceBot_AI', 'Registered %d %s files,' % (self.dict["counts"], 'aiml')) - logs.log('SpiceBot_AI', '%d %s files failed to load' % (self.dict["failcounts"], 'aiml'), True) - else: - logs.log('SpiceBot_AI', "Warning: Couldn't load any %s files" % ('aiml')) - def load_brain(self): import sopel_modules braindirs = [] diff --git a/sopel_modules/SpiceBot_Core_Processing/AI.py b/sopel_modules/SpiceBot_Core_Processing/AI.py new file mode 100644 index 0000000..009e48b --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Processing/AI.py @@ -0,0 +1,19 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot AI system. +""" +import sopel + +import sopel_modules.SpiceBot as SpiceBot + + +@sopel.module.event(SpiceBot.events.BOT_READY) +@sopel.module.rule('.*') +def bot_events_complete(bot, trigger): + + if SpiceBot.botai.dict["counts"]: + SpiceBot.logs.log('SpiceBot_AI', 'Registered %d %s files,' % (SpiceBot.botai.dict["counts"], 'aiml')) + SpiceBot.logs.log('SpiceBot_AI', '%d %s files failed to load' % (SpiceBot.botai.dict["failcounts"], 'aiml'), True) + else: + SpiceBot.logs.log('SpiceBot_AI', "Warning: Couldn't load any %s files" % ('aiml')) diff --git a/sopel_modules/SpiceBot_Core_Processing/__init__.py b/sopel_modules/SpiceBot_Core_Processing/__init__.py index 9623c13..df953ff 100644 --- a/sopel_modules/SpiceBot_Core_Processing/__init__.py +++ b/sopel_modules/SpiceBot_Core_Processing/__init__.py @@ -9,6 +9,7 @@ This module contains references only for other modules to utilize. from .Channels import * from .Events import * from .Modules import * +from .AI import * from .osd import * from .StartupMonologue import * from .Logs import * From 411fdfd16098fdbd040f368389d2c09e86357f02 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 13:32:15 -0400 Subject: [PATCH 233/328] counts log --- sopel_modules/SpiceBot/AI.py | 6 ------ sopel_modules/SpiceBot_Core_Processing/AI.py | 19 +++++++++++++++++++ .../SpiceBot_Core_Processing/__init__.py | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 sopel_modules/SpiceBot_Core_Processing/AI.py diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 522d265..72fbd60 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -39,12 +39,6 @@ class SpiceBot_AI(): # Learn responses self.load_brain() - if self.dict["counts"]: - logs.log('SpiceBot_AI', 'Registered %d %s files,' % (self.dict["counts"], 'aiml')) - logs.log('SpiceBot_AI', '%d %s files failed to load' % (self.dict["failcounts"], 'aiml'), True) - else: - logs.log('SpiceBot_AI', "Warning: Couldn't load any %s files" % ('aiml')) - def load_brain(self): import sopel_modules braindirs = [] diff --git a/sopel_modules/SpiceBot_Core_Processing/AI.py b/sopel_modules/SpiceBot_Core_Processing/AI.py new file mode 100644 index 0000000..009e48b --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Processing/AI.py @@ -0,0 +1,19 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot AI system. +""" +import sopel + +import sopel_modules.SpiceBot as SpiceBot + + +@sopel.module.event(SpiceBot.events.BOT_READY) +@sopel.module.rule('.*') +def bot_events_complete(bot, trigger): + + if SpiceBot.botai.dict["counts"]: + SpiceBot.logs.log('SpiceBot_AI', 'Registered %d %s files,' % (SpiceBot.botai.dict["counts"], 'aiml')) + SpiceBot.logs.log('SpiceBot_AI', '%d %s files failed to load' % (SpiceBot.botai.dict["failcounts"], 'aiml'), True) + else: + SpiceBot.logs.log('SpiceBot_AI', "Warning: Couldn't load any %s files" % ('aiml')) diff --git a/sopel_modules/SpiceBot_Core_Processing/__init__.py b/sopel_modules/SpiceBot_Core_Processing/__init__.py index 9623c13..df953ff 100644 --- a/sopel_modules/SpiceBot_Core_Processing/__init__.py +++ b/sopel_modules/SpiceBot_Core_Processing/__init__.py @@ -9,6 +9,7 @@ This module contains references only for other modules to utilize. from .Channels import * from .Events import * from .Modules import * +from .AI import * from .osd import * from .StartupMonologue import * from .Logs import * From b37e7b1a6cf787908e3de29e2afa9c5b30b6d77e Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 13:38:47 -0400 Subject: [PATCH 234/328] test --- sopel_modules/SpiceBot/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index 3d240fe..724144d 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -79,4 +79,4 @@ def setup(bot): logs.log('SpiceBot_AI', "Setting Up Configuration") bot.config.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) - botai.load_extras(bot) + # botai.load_extras(bot) TODO From 86fb1b984fa783c182be7bfc135f31b5620f95f5 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 13:39:47 -0400 Subject: [PATCH 235/328] hmm --- sopel_modules/SpiceBot/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index 724144d..3d240fe 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -79,4 +79,4 @@ def setup(bot): logs.log('SpiceBot_AI', "Setting Up Configuration") bot.config.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) - # botai.load_extras(bot) TODO + botai.load_extras(bot) From 3eaa2ad207f4e2caaf9abcd454e9edea01a90125 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 13:46:11 -0400 Subject: [PATCH 236/328] better load logic --- sopel_modules/SpiceBot/AI.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 72fbd60..8fbaec8 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -22,6 +22,7 @@ class SpiceBot_AI_MainSection(StaticSection): class SpiceBot_AI(): def __init__(self): + self.load_commands = [0] self.dict = { "counts": 0, "failcounts": 0, @@ -56,6 +57,7 @@ class SpiceBot_AI(): def learn(self, braindirs): for braindir in braindirs: + dirnumber = max(self.load_commands) + 1 for parsefile in os.listdir(braindir): self.check_file_parse(parsefile) tempbrain = tempfile.mkstemp()[1] @@ -64,15 +66,17 @@ class SpiceBot_AI(): "" " \n" " \n" - " LOAD AIML B\n" + " LOAD AIML {}\n" " \n" " \n" - "".format(os.path.join(braindir, "*")) + "".format(str(dirnumber), os.path.join(braindir, "*")) ) self.aiml_kernel.learn(tempbrain) - self.aiml_kernel.respond("LOAD AIML B") + for number in self.load_commands: + if number != 0: + self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber)) os.remove(tempbrain) def on_message(self, bot, trigger, message): From 659395b3eb4370b256362334702740c5e18596ff Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 13:51:24 -0400 Subject: [PATCH 237/328] test --- sopel_modules/SpiceBot/AI.py | 4 ++-- sopel_modules/SpiceBot_Core_Processing/AI.py | 2 +- sopel_modules/SpiceBot_Core_Processing/Modules.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 8fbaec8..e9908a1 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -58,8 +58,8 @@ class SpiceBot_AI(): def learn(self, braindirs): for braindir in braindirs: dirnumber = max(self.load_commands) + 1 - for parsefile in os.listdir(braindir): - self.check_file_parse(parsefile) + # for parsefile in os.listdir(braindir): + # self.check_file_parse(parsefile) tempbrain = tempfile.mkstemp()[1] with open(tempbrain, 'w') as fileo: fileo.write( diff --git a/sopel_modules/SpiceBot_Core_Processing/AI.py b/sopel_modules/SpiceBot_Core_Processing/AI.py index 009e48b..cb214b8 100644 --- a/sopel_modules/SpiceBot_Core_Processing/AI.py +++ b/sopel_modules/SpiceBot_Core_Processing/AI.py @@ -10,7 +10,7 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.event(SpiceBot.events.BOT_READY) @sopel.module.rule('.*') -def bot_events_complete(bot, trigger): +def bot_events_complete_ai(bot, trigger): if SpiceBot.botai.dict["counts"]: SpiceBot.logs.log('SpiceBot_AI', 'Registered %d %s files,' % (SpiceBot.botai.dict["counts"], 'aiml')) diff --git a/sopel_modules/SpiceBot_Core_Processing/Modules.py b/sopel_modules/SpiceBot_Core_Processing/Modules.py index 81b22d2..fa0303d 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Modules.py +++ b/sopel_modules/SpiceBot_Core_Processing/Modules.py @@ -10,7 +10,7 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.event(SpiceBot.events.BOT_READY) @sopel.module.rule('.*') -def bot_events_complete(bot, trigger): +def bot_events_complete_modules(bot, trigger): for comtype in SpiceBot.commands.dict['commands'].keys(): if comtype not in ['module', 'nickname', 'rule']: From 6b305fdea0866126ee5c14ea70964b1f37a1299b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 13:55:55 -0400 Subject: [PATCH 238/328] test --- sopel_modules/SpiceBot/AI.py | 43 ++++++++++---------- sopel_modules/SpiceBot_Core_Processing/AI.py | 6 +++ 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index e9908a1..06b9465 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -23,6 +23,7 @@ class SpiceBot_AI(): def __init__(self): self.load_commands = [0] + self.braindirs = [] self.dict = { "counts": 0, "failcounts": 0, @@ -57,27 +58,27 @@ class SpiceBot_AI(): def learn(self, braindirs): for braindir in braindirs: - dirnumber = max(self.load_commands) + 1 - # for parsefile in os.listdir(braindir): - # self.check_file_parse(parsefile) - tempbrain = tempfile.mkstemp()[1] - with open(tempbrain, 'w') as fileo: - fileo.write( - "" - " \n" - " \n" - " LOAD AIML {}\n" - " \n" - " \n" - "".format(str(dirnumber), os.path.join(braindir, "*")) - ) - self.aiml_kernel.learn(tempbrain) - for number in self.load_commands: - if number != 0: - self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber)) - os.remove(tempbrain) + if braindir not in self.braindirs: + self.braindirs.append(braindir) + dirnumber = max(self.load_commands) + 1 + tempbrain = tempfile.mkstemp()[1] + with open(tempbrain, 'w') as fileo: + fileo.write( + "" + " \n" + " \n" + " LOAD AIML {}\n" + " \n" + " \n" + "".format(str(dirnumber), os.path.join(braindir, "*")) + ) + self.aiml_kernel.learn(tempbrain) + for number in self.load_commands: + if number != 0: + self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber)) + os.remove(tempbrain) def on_message(self, bot, trigger, message): nick = Identifier(trigger.nick) diff --git a/sopel_modules/SpiceBot_Core_Processing/AI.py b/sopel_modules/SpiceBot_Core_Processing/AI.py index cb214b8..efa1843 100644 --- a/sopel_modules/SpiceBot_Core_Processing/AI.py +++ b/sopel_modules/SpiceBot_Core_Processing/AI.py @@ -5,6 +5,8 @@ This is the SpiceBot AI system. """ import sopel +import os + import sopel_modules.SpiceBot as SpiceBot @@ -12,6 +14,10 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.rule('.*') def bot_events_complete_ai(bot, trigger): + for braindir in SpiceBot.botai.braindirs: + for parsefile in os.listdir(braindir): + SpiceBot.botai.check_file_parse(parsefile) + if SpiceBot.botai.dict["counts"]: SpiceBot.logs.log('SpiceBot_AI', 'Registered %d %s files,' % (SpiceBot.botai.dict["counts"], 'aiml')) SpiceBot.logs.log('SpiceBot_AI', '%d %s files failed to load' % (SpiceBot.botai.dict["failcounts"], 'aiml'), True) From 064574b683ddaf616506c60c1156e663b351870f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 14:01:45 -0400 Subject: [PATCH 239/328] test --- sopel_modules/SpiceBot/AI.py | 1 + sopel_modules/SpiceBot_Core_Processing/{AI.py => AI} | 0 sopel_modules/SpiceBot_Core_Processing/__init__.py | 2 +- 3 files changed, 2 insertions(+), 1 deletion(-) rename sopel_modules/SpiceBot_Core_Processing/{AI.py => AI} (100%) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 06b9465..183fd0c 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -61,6 +61,7 @@ class SpiceBot_AI(): if braindir not in self.braindirs: self.braindirs.append(braindir) dirnumber = max(self.load_commands) + 1 + self.load_commands.append(dirnumber) tempbrain = tempfile.mkstemp()[1] with open(tempbrain, 'w') as fileo: fileo.write( diff --git a/sopel_modules/SpiceBot_Core_Processing/AI.py b/sopel_modules/SpiceBot_Core_Processing/AI similarity index 100% rename from sopel_modules/SpiceBot_Core_Processing/AI.py rename to sopel_modules/SpiceBot_Core_Processing/AI diff --git a/sopel_modules/SpiceBot_Core_Processing/__init__.py b/sopel_modules/SpiceBot_Core_Processing/__init__.py index df953ff..2819990 100644 --- a/sopel_modules/SpiceBot_Core_Processing/__init__.py +++ b/sopel_modules/SpiceBot_Core_Processing/__init__.py @@ -9,7 +9,7 @@ This module contains references only for other modules to utilize. from .Channels import * from .Events import * from .Modules import * -from .AI import * +# from .AI import * from .osd import * from .StartupMonologue import * from .Logs import * From 990193d51a3dcdf45a4c0e7d1b9332e964ec0a56 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 14:03:13 -0400 Subject: [PATCH 240/328] better load logic --- sopel_modules/SpiceBot/AI.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 183fd0c..4fa0e41 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -76,9 +76,9 @@ class SpiceBot_AI(): "".format(str(dirnumber), os.path.join(braindir, "*")) ) self.aiml_kernel.learn(tempbrain) - for number in self.load_commands: - if number != 0: - self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber)) + for number in self.load_commands: + if number != 0: + self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber)) os.remove(tempbrain) def on_message(self, bot, trigger, message): From 14b82f3bbcde54e032a347ba4cf8792973727192 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 14:09:15 -0400 Subject: [PATCH 241/328] TEST --- sopel_modules/SpiceBot/AI.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 4fa0e41..b56f299 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -53,6 +53,7 @@ class SpiceBot_AI(): self.learn(braindirs) def load_extras(self, bot): + return if len(bot.config.SpiceBot_AI.extra): self.learn(self, bot.config.SpiceBot_AI.extra) @@ -68,18 +69,21 @@ class SpiceBot_AI(): "" " \n" " \n" - " LOAD AIML {}\n" + " LOAD AIML B\n" + # " LOAD AIML {}\n" " \n" " \n" - "".format(str(dirnumber), os.path.join(braindir, "*")) + # "".format(str(dirnumber), os.path.join(braindir, "*")) + "".format(os.path.join(braindir, "*")) ) self.aiml_kernel.learn(tempbrain) - for number in self.load_commands: - if number != 0: - self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber)) - os.remove(tempbrain) + self.aiml_kernel.respond("LOAD AIML b") + # for number in self.load_commands: + # if number != 0: + # self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber)) + # os.remove(tempbrain) def on_message(self, bot, trigger, message): nick = Identifier(trigger.nick) From 7be0c868e7aa6fb144772633318f4772f106e164 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 1 Jun 2019 18:11:33 -0400 Subject: [PATCH 242/328] uuper --- sopel_modules/SpiceBot/AI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index b56f299..12b768f 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -79,7 +79,7 @@ class SpiceBot_AI(): "".format(os.path.join(braindir, "*")) ) self.aiml_kernel.learn(tempbrain) - self.aiml_kernel.respond("LOAD AIML b") + self.aiml_kernel.respond("LOAD AIML B") # for number in self.load_commands: # if number != 0: # self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber)) From a983b7ef2ded999fed187592f90cac4e9ae6e0e2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 19:48:50 -0400 Subject: [PATCH 243/328] test detection of bot.nick --- sopel_modules/SpiceBot/AI.py | 4 +++- sopel_modules/SpiceBot/setup.py | 1 + sopel_modules/SpiceBot_Configs/aiml/bottest.aiml | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 sopel_modules/SpiceBot_Configs/aiml/bottest.aiml diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 12b768f..2cbe937 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -52,8 +52,10 @@ class SpiceBot_AI(): # learn directories self.learn(braindirs) + def load_bot_values(self, bot): + self.aiml_kernel.setBotPredicate("nick", bot.nick) + def load_extras(self, bot): - return if len(bot.config.SpiceBot_AI.extra): self.learn(self, bot.config.SpiceBot_AI.extra) diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index 3d240fe..2a57052 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -80,3 +80,4 @@ def setup(bot): logs.log('SpiceBot_AI', "Setting Up Configuration") bot.config.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) botai.load_extras(bot) + botai.load_bot_values(bot) diff --git a/sopel_modules/SpiceBot_Configs/aiml/bottest.aiml b/sopel_modules/SpiceBot_Configs/aiml/bottest.aiml new file mode 100644 index 0000000..c75ff04 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/bottest.aiml @@ -0,0 +1,8 @@ + + + is cool + + + From 3fb5e7f710f64a382303c1edb3a7c5af4641955b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:02:00 -0400 Subject: [PATCH 244/328] bot.nick --- sopel_modules/SpiceBot/AI.py | 6 ++++++ .../aiml/{bottest.aiml => bot_is_cool.aiml} | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) rename sopel_modules/SpiceBot_Configs/aiml/{bottest.aiml => bot_is_cool.aiml} (71%) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 2cbe937..d340c0e 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -93,6 +93,12 @@ class SpiceBot_AI(): self.check_user_import(nick, nick_id) aiml_response = self.aiml_kernel.respond(message, nick_id) self.save_nick_session(nick, nick_id) + aiml_response = self.bot_message_decipher(bot, aiml_response) + return aiml_response + + def bot_message_decipher(self, bot, aiml_response): + while "bot.nick" in aiml_response: + aiml_response.replace("bot.nick", bot.nick) return aiml_response def check_user_import(self, nick, nick_id=None): diff --git a/sopel_modules/SpiceBot_Configs/aiml/bottest.aiml b/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml similarity index 71% rename from sopel_modules/SpiceBot_Configs/aiml/bottest.aiml rename to sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml index c75ff04..f033ca5 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/bottest.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml @@ -1,6 +1,6 @@ - is cool + bot.nick is cool From 870b6763231ee82ad814bc2be04d77f907ffb12b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:05:23 -0400 Subject: [PATCH 245/328] handle bot nick fully --- sopel_modules/SpiceBot/AI.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index d340c0e..de75909 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -91,11 +91,17 @@ class SpiceBot_AI(): nick = Identifier(trigger.nick) nick_id = botdb.get_nick_id(nick, create=True) self.check_user_import(nick, nick_id) + message = self.bot_message_precipher(bot, message) aiml_response = self.aiml_kernel.respond(message, nick_id) self.save_nick_session(nick, nick_id) aiml_response = self.bot_message_decipher(bot, aiml_response) return aiml_response + def bot_message_precipher(self, bot, message): + while bot.nick in message: + message.replace(bot.nick, "bot.nick") + return message + def bot_message_decipher(self, bot, aiml_response): while "bot.nick" in aiml_response: aiml_response.replace("bot.nick", bot.nick) From 112c2d1f433f54b8a7e53fc7ef2f17681e294a17 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:11:03 -0400 Subject: [PATCH 246/328] remove parse error --- .../SpiceBot_Configs/aiml/bot_profile.aiml | 392 ------------------ 1 file changed, 392 deletions(-) delete mode 100644 sopel_modules/SpiceBot_Configs/aiml/bot_profile.aiml diff --git a/sopel_modules/SpiceBot_Configs/aiml/bot_profile.aiml b/sopel_modules/SpiceBot_Configs/aiml/bot_profile.aiml deleted file mode 100644 index 653530a..0000000 --- a/sopel_modules/SpiceBot_Configs/aiml/bot_profile.aiml +++ /dev/null @@ -1,392 +0,0 @@ - - - - - - - - - - - - - - - - - - -PETS - - -DOG - - -TYPE - - -FEAR - - -AWARDS - - -SECRET - - -STATE YOUR profile - - -LOOK LIKE - - -VACATION - - -FAMILY - - -PIC - - -LOGO - - -LIE - - -EMOTIONS - - -HEIGHT - - -FACEBOOK PAGE - - -BIRTHPLACE - - -JOB - - -NATIONALITY - - -DOING - - -ETHNICITY - - -FEELINGS - - -RELIGION - - -ORIENTATION - - -SIBLINGS - - -BODY - - -WEIGHT - - -ALIVE - - -BOTMASTER - - -GOAL - - -IQ - - -EDUCATION - - -STATUS - - -HAIR - - -ADDRESS - - -DIET - - -GENDER - - -SKILLS - - -PERSONALITY - - -WEARING - - -LANGUAGE - - -LOCATION - - -FRIENDS - - -SIZE - - -CHILDREN - - -DEVICE MODEL - - -DEVICE MANUFACTURER - - -PURPOSE - - -MOTHER - - -BIRTHDAY - - -BIRTHDATE - - -AGE - - -AGE IN YEARS - - -EYECOLOR - - -EYES - - -SIGN - - -PHONE NUMBER - - -NAME - - -$WHO IS ALICE - - -VOCABULARY - - -LAST NAME - - -MIDDLE NAME - - -FIRST NAME - - -FULL NAME - - -FATHER - - -FOR FUN - - -SLEEP - - -HOBBIES - - -SPECIES - - -HAVE - - -TALKING TO - - -AUNT - - -BESTFRIEND - - -BOSS - - -BOYFRIEND - - -BROTHER - - -CAT - - -DAUGHTER - - -FRIEND - - -GIRLFRIEND - - -GRANDFATHER - - -GRANDMOTHER - - -HUSBAND - - -NEPHEW - - -NIECE - - -SISTER - - -SON - - -TEACHER - - -UNCLE - - -WIFE - - -CAR MODEL - - - From 92a8159a1af1f312de6f2653421725a1c7f8b686 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:12:23 -0400 Subject: [PATCH 247/328] test --- sopel_modules/SpiceBot/AI.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index de75909..5df4383 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -98,13 +98,13 @@ class SpiceBot_AI(): return aiml_response def bot_message_precipher(self, bot, message): - while bot.nick in message: - message.replace(bot.nick, "bot.nick") + # while bot.nick in message: + # message.replace(bot.nick, "bot.nick") return message def bot_message_decipher(self, bot, aiml_response): - while "bot.nick" in aiml_response: - aiml_response.replace("bot.nick", bot.nick) + # while "bot.nick" in aiml_response: + # aiml_response.replace("bot.nick", bot.nick) return aiml_response def check_user_import(self, nick, nick_id=None): From 15bfd991ce78bd1a37fbd5c2db9c8bd54aa8a163 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:15:18 -0400 Subject: [PATCH 248/328] not.nick --- sopel_modules/SpiceBot/AI.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 5df4383..1188dfe 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -98,13 +98,13 @@ class SpiceBot_AI(): return aiml_response def bot_message_precipher(self, bot, message): - # while bot.nick in message: - # message.replace(bot.nick, "bot.nick") + while str(bot.nick) in message.upper(): + message = message.replace(str(bot.nick), "bot.nick") return message def bot_message_decipher(self, bot, aiml_response): - # while "bot.nick" in aiml_response: - # aiml_response.replace("bot.nick", bot.nick) + while "bot.nick" in aiml_response: + aiml_response = aiml_response.replace("bot.nick", str(bot.nick)) return aiml_response def check_user_import(self, nick, nick_id=None): From e0ab3aa6c1dc0c43a37ae4e634794ff5afe1bc96 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:16:57 -0400 Subject: [PATCH 249/328] trigger.nick --- sopel_modules/SpiceBot/AI.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 1188dfe..3e7efee 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -91,20 +91,24 @@ class SpiceBot_AI(): nick = Identifier(trigger.nick) nick_id = botdb.get_nick_id(nick, create=True) self.check_user_import(nick, nick_id) - message = self.bot_message_precipher(bot, message) + message = self.bot_message_precipher(bot, trigger, message) aiml_response = self.aiml_kernel.respond(message, nick_id) self.save_nick_session(nick, nick_id) - aiml_response = self.bot_message_decipher(bot, aiml_response) + aiml_response = self.bot_message_decipher(bot, trigger, aiml_response) return aiml_response - def bot_message_precipher(self, bot, message): + def bot_message_precipher(self, bot, trigger, message): while str(bot.nick) in message.upper(): message = message.replace(str(bot.nick), "bot.nick") + while str(trigger.nick) in message.upper(): + message = message.replace(str(trigger.nick), "trigger.nick") return message - def bot_message_decipher(self, bot, aiml_response): + def bot_message_decipher(self, bot, trigger, aiml_response): while "bot.nick" in aiml_response: aiml_response = aiml_response.replace("bot.nick", str(bot.nick)) + while "trigger.nick" in aiml_response: + aiml_response = aiml_response.replace("trigger.nick", str(trigger.nick)) return aiml_response def check_user_import(self, nick, nick_id=None): From 9485262af62ace4584f445a3cf0ff0c8118b6bfe Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:18:09 -0400 Subject: [PATCH 250/328] test --- sopel_modules/SpiceBot/AI.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 3e7efee..3fdd237 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -102,6 +102,7 @@ class SpiceBot_AI(): message = message.replace(str(bot.nick), "bot.nick") while str(trigger.nick) in message.upper(): message = message.replace(str(trigger.nick), "trigger.nick") + bot.say(str(message)) return message def bot_message_decipher(self, bot, trigger, aiml_response): @@ -109,6 +110,7 @@ class SpiceBot_AI(): aiml_response = aiml_response.replace("bot.nick", str(bot.nick)) while "trigger.nick" in aiml_response: aiml_response = aiml_response.replace("trigger.nick", str(trigger.nick)) + bot.say(str(aiml_response)) return aiml_response def check_user_import(self, nick, nick_id=None): From 2317792a03501c336a34cf2e6b670236834edece Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:19:46 -0400 Subject: [PATCH 251/328] todo --- sopel_modules/SpiceBot/Logs.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sopel_modules/SpiceBot/Logs.py b/sopel_modules/SpiceBot/Logs.py index ab7a4d3..4e422fd 100644 --- a/sopel_modules/SpiceBot/Logs.py +++ b/sopel_modules/SpiceBot/Logs.py @@ -14,6 +14,8 @@ import spicemanip from .Config import config as botconfig +# TODO timestamps + class BotLogs(): """This Is a contained source of log information""" def __init__(self): From d6c8ae845bca32f50dd6f8bc7c6170ac777efed1 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:22:24 -0400 Subject: [PATCH 252/328] test --- sopel_modules/SpiceBot/AI.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 3fdd237..b7377d8 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -98,19 +98,14 @@ class SpiceBot_AI(): return aiml_response def bot_message_precipher(self, bot, trigger, message): - while str(bot.nick) in message.upper(): - message = message.replace(str(bot.nick), "bot.nick") - while str(trigger.nick) in message.upper(): - message = message.replace(str(trigger.nick), "trigger.nick") + message = message.replace(str(bot.nick), "bot.nick") + message = message.replace(str(trigger.nick), "trigger.nick") bot.say(str(message)) return message def bot_message_decipher(self, bot, trigger, aiml_response): - while "bot.nick" in aiml_response: - aiml_response = aiml_response.replace("bot.nick", str(bot.nick)) - while "trigger.nick" in aiml_response: - aiml_response = aiml_response.replace("trigger.nick", str(trigger.nick)) - bot.say(str(aiml_response)) + aiml_response = aiml_response.replace("bot.nick", str(bot.nick)) + aiml_response = aiml_response.replace("trigger.nick", str(trigger.nick)) return aiml_response def check_user_import(self, nick, nick_id=None): From f26eb5fd5e19b3a95bfe6ee32037c8b3cf5adce7 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:23:58 -0400 Subject: [PATCH 253/328] todo --- sopel_modules/SpiceBot_AI/AI_aiml.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index dc98e5e..2b4e4c2 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -10,6 +10,9 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.rule('(.*)') def bot_command_nick(bot, trigger): + # TODO add config limits + # but still allow in privmsg + if trigger.nick == bot.nick: return From 868b0d6beb93afae198f1b24d31046ac2e120e0f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:27:13 -0400 Subject: [PATCH 254/328] test --- sopel_modules/SpiceBot/AI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index b7377d8..230be3a 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -36,7 +36,7 @@ class SpiceBot_AI(): self.aiml_parser = aiml.AimlParser.create_parser() # Don't warn for no matches - self.aiml_kernel._verboseMode = False + #self.aiml_kernel._verboseMode = False # Learn responses self.load_brain() From 160256d33b3d3275248bc32dee0352296bff871f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:33:03 -0400 Subject: [PATCH 255/328] upper --- sopel_modules/SpiceBot/AI.py | 7 ++++++- sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 230be3a..38764ad 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -36,7 +36,7 @@ class SpiceBot_AI(): self.aiml_parser = aiml.AimlParser.create_parser() # Don't warn for no matches - #self.aiml_kernel._verboseMode = False + # self.aiml_kernel._verboseMode = False # Learn responses self.load_brain() @@ -118,6 +118,11 @@ class SpiceBot_AI(): predval = self.dict["sessioncache"][nick_id][predicate] self.aiml_kernel.setPredicate(predicate, predval, nick_id) + # defaults + if "nick" not in self.dict["sessioncache"][nick_id].keys(): + self.dict["sessioncache"][nick_id]["nick"] = nick + self.aiml_kernel.setPredicate("nick", nick, nick_id) + def save_nick_session(self, nick, nick_id=None): if not nick_id: nick = Identifier(nick) diff --git a/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml b/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml index f033ca5..d265fe0 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml @@ -1,6 +1,6 @@ - bot.nick is cool + BOT.NICK IS COOL From 23b55d8e65c4c54363856dc499151f08682c2a8e Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:37:21 -0400 Subject: [PATCH 256/328] test --- sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml b/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml index d265fe0..9a59d86 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml @@ -1,8 +1,6 @@ - - - BOT.NICK IS COOL - - + + +YOU ARE LAZY + + From 425489f2228f387fa9c6c7a24f05ff45c39407d7 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:42:35 -0400 Subject: [PATCH 257/328] test --- sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml b/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml index 9a59d86..7800945 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml @@ -1,6 +1,6 @@ -YOU ARE LAZY - +BOT.NICK + From e68242170fa34bc4e8a4c88201e91fa098d55cf8 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:47:14 -0400 Subject: [PATCH 258/328] excape --- sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml b/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml index 7800945..6fc0b5b 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml @@ -1,6 +1,6 @@ -BOT.NICK +BOT\.NICK From 13acfcb1507698049ce26e3fc05f67c1e6e159c0 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:52:08 -0400 Subject: [PATCH 259/328] test --- sopel_modules/SpiceBot/AI.py | 9 ++++----- sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 38764ad..c80fe1d 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -98,14 +98,13 @@ class SpiceBot_AI(): return aiml_response def bot_message_precipher(self, bot, trigger, message): - message = message.replace(str(bot.nick), "bot.nick") - message = message.replace(str(trigger.nick), "trigger.nick") - bot.say(str(message)) + message = message.replace(str(bot.nick), "botnick") + message = message.replace(str(trigger.nick), "triggernick") return message def bot_message_decipher(self, bot, trigger, aiml_response): - aiml_response = aiml_response.replace("bot.nick", str(bot.nick)) - aiml_response = aiml_response.replace("trigger.nick", str(trigger.nick)) + aiml_response = aiml_response.replace("botnick", str(bot.nick)) + aiml_response = aiml_response.replace("triggernick", str(trigger.nick)) return aiml_response def check_user_import(self, nick, nick_id=None): diff --git a/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml b/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml index 6fc0b5b..63c6f22 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml @@ -1,6 +1,6 @@ -BOT\.NICK +BOTNICK From d1fcdc47f5ee7b75261a650cc9355a304cd187ca Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:53:03 -0400 Subject: [PATCH 260/328] file rename for sopel --- .../aiml/{bot_is_cool.aiml => nickname_commands.aiml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sopel_modules/SpiceBot_Configs/aiml/{bot_is_cool.aiml => nickname_commands.aiml} (100%) diff --git a/sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_commands.aiml similarity index 100% rename from sopel_modules/SpiceBot_Configs/aiml/bot_is_cool.aiml rename to sopel_modules/SpiceBot_Configs/aiml/nickname_commands.aiml From 1febf78acf519fa829df594a88ed7a2f44acecfe Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 2 Jun 2019 20:54:39 -0400 Subject: [PATCH 261/328] disable verbose --- sopel_modules/SpiceBot/AI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index c80fe1d..cfc1e0e 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -36,7 +36,7 @@ class SpiceBot_AI(): self.aiml_parser = aiml.AimlParser.create_parser() # Don't warn for no matches - # self.aiml_kernel._verboseMode = False + self.aiml_kernel._verboseMode = False # Learn responses self.load_brain() From b5d0db4ff2a1994e36bfe38290b98739e41f9209 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Mon, 3 Jun 2019 16:01:05 -0400 Subject: [PATCH 262/328] another test --- sopel_modules/SpiceBot/AI.py | 12 ++++++++---- .../SpiceBot_Configs/aiml/nickname_commands.aiml | 6 ++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index cfc1e0e..25fec2b 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -98,13 +98,17 @@ class SpiceBot_AI(): return aiml_response def bot_message_precipher(self, bot, trigger, message): - message = message.replace(str(bot.nick), "botnick") - message = message.replace(str(trigger.nick), "triggernick") + for botitem in ["nick"]: + message = message.replace(str(eval("bot." + botitem)), "bot" + botitem) + for triggeritem in ["nick", "sender"]: + message = message.replace(str(eval("trigger." + triggeritem)), "trigger" + triggeritem) return message def bot_message_decipher(self, bot, trigger, aiml_response): - aiml_response = aiml_response.replace("botnick", str(bot.nick)) - aiml_response = aiml_response.replace("triggernick", str(trigger.nick)) + for botitem in ["nick"]: + aiml_response = aiml_response.replace("bot" + botitem, str(eval("bot." + botitem))) + for triggeritem in ["nick", "sender"]: + aiml_response = aiml_response.replace("trigger" + triggeritem, str(eval("trigger." + triggeritem))) return aiml_response def check_user_import(self, nick, nick_id=None): diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_commands.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_commands.aiml index 63c6f22..e9e34e8 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/nickname_commands.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_commands.aiml @@ -1,6 +1,12 @@ + BOTNICK + +BOTNICK IS COOL + + + From 27e7b39b147288cf4ba9fc5a06b9131cff75b80f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 07:52:57 -0400 Subject: [PATCH 263/328] only open aiml files --- sopel_modules/SpiceBot/AI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 25fec2b..aa6aefe 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -78,7 +78,7 @@ class SpiceBot_AI(): " \n" " \n" # "".format(str(dirnumber), os.path.join(braindir, "*")) - "".format(os.path.join(braindir, "*")) + "".format(os.path.join(braindir, "*.aiml")) ) self.aiml_kernel.learn(tempbrain) self.aiml_kernel.respond("LOAD AIML B") From 2cd6514cbee5267deae882932b472bfc9737b6ed Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 07:59:07 -0400 Subject: [PATCH 264/328] attempt better load --- sopel_modules/SpiceBot/AI.py | 49 ++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index aa6aefe..019828b 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -66,26 +66,37 @@ class SpiceBot_AI(): dirnumber = max(self.load_commands) + 1 self.load_commands.append(dirnumber) tempbrain = tempfile.mkstemp()[1] - with open(tempbrain, 'w') as fileo: - fileo.write( - "" - " \n" - " \n" - " LOAD AIML B\n" - # " LOAD AIML {}\n" - " \n" - " \n" - # "".format(str(dirnumber), os.path.join(braindir, "*")) - "".format(os.path.join(braindir, "*.aiml")) - ) + # with open(tempbrain, 'w') as fileo: + # fileo.write( + # "" + # " \n" + # " \n" + # " LOAD AIML B\n" + # # " LOAD AIML {}\n" + # " \n" + # " \n" + # # "".format(str(dirnumber), os.path.join(braindir, "*")) + # "".format(os.path.join(braindir, "*.aiml")) + # ) + brainfile = open(tempbrain, 'a') + brainfile.write("") + brainfile.write(" \n") + brainfile.write(" \n") + brainfile.write(" LOAD AIML {}\n".format(str(dirnumber))) + brainfile.write(" \n") + brainfile.write(" \n") + brainfile.write("") + brainfile.close() self.aiml_kernel.learn(tempbrain) - self.aiml_kernel.respond("LOAD AIML B") - # for number in self.load_commands: - # if number != 0: - # self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber)) - # os.remove(tempbrain) + # self.aiml_kernel.respond("LOAD AIML B") + for number in self.load_commands: + if number != 0: + self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber)) + os.remove(tempbrain) def on_message(self, bot, trigger, message): nick = Identifier(trigger.nick) From 1760e527d706737850a079bb6adfae6cd4b58a4a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 08:05:59 -0400 Subject: [PATCH 265/328] grrr --- sopel_modules/SpiceBot/AI.py | 47 +++++++++++------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 019828b..8c8afb2 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -23,7 +23,7 @@ class SpiceBot_AI(): def __init__(self): self.load_commands = [0] - self.braindirs = [] + self.braindirs = {} self.dict = { "counts": 0, "failcounts": 0, @@ -63,40 +63,21 @@ class SpiceBot_AI(): for braindir in braindirs: if braindir not in self.braindirs: self.braindirs.append(braindir) - dirnumber = max(self.load_commands) + 1 - self.load_commands.append(dirnumber) tempbrain = tempfile.mkstemp()[1] - # with open(tempbrain, 'w') as fileo: - # fileo.write( - # "" - # " \n" - # " \n" - # " LOAD AIML B\n" - # # " LOAD AIML {}\n" - # " \n" - # " \n" - # # "".format(str(dirnumber), os.path.join(braindir, "*")) - # "".format(os.path.join(braindir, "*.aiml")) - # ) - brainfile = open(tempbrain, 'a') - brainfile.write("") - brainfile.write(" \n") - brainfile.write(" \n") - brainfile.write(" LOAD AIML {}\n".format(str(dirnumber))) - brainfile.write(" \n") - brainfile.write(" \n") - brainfile.write("") - brainfile.close() + with open(tempbrain, 'w') as fileo: + fileo.write( + "" + " \n" + " \n" + " LOAD AIML B\n" + " \n" + " \n" + "".format(os.path.join(braindir, "*.aiml")) + ) self.aiml_kernel.learn(tempbrain) - # self.aiml_kernel.respond("LOAD AIML B") - for number in self.load_commands: - if number != 0: - self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber)) - os.remove(tempbrain) + self.aiml_kernel.respond("LOAD AIML B") def on_message(self, bot, trigger, message): nick = Identifier(trigger.nick) From dbb2700eac87d0bb89d1b36ece5d4f0dd2f63572 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 08:19:08 -0400 Subject: [PATCH 266/328] test --- sopel_modules/SpiceBot/AI.py | 49 +++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 8c8afb2..d1507d6 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -22,8 +22,8 @@ class SpiceBot_AI_MainSection(StaticSection): class SpiceBot_AI(): def __init__(self): - self.load_commands = [0] - self.braindirs = {} + self.load_commands = {0: None} + self.braindirs = [] self.dict = { "counts": 0, "failcounts": 0, @@ -63,21 +63,40 @@ class SpiceBot_AI(): for braindir in braindirs: if braindir not in self.braindirs: self.braindirs.append(braindir) + dirnumber = max(self.load_commands.keys()) + 1 + self.load_commands[dirnumber] = braindir tempbrain = tempfile.mkstemp()[1] - with open(tempbrain, 'w') as fileo: - fileo.write( - "" - " \n" - " \n" - " LOAD AIML B\n" - " \n" - " \n" - "".format(os.path.join(braindir, "*.aiml")) - ) + # with open(tempbrain, 'w') as fileo: + # fileo.write( + # "" + # " \n" + # " \n" + # " LOAD AIML B\n" + # # " LOAD AIML {}\n" + # " \n" + # " \n" + # # "".format(str(dirnumber), os.path.join(braindir, "*")) + # "".format(os.path.join(braindir, "*.aiml")) + # ) + brainfile = open(tempbrain, 'a') + brainfile.write("") + brainfile.write(" \n") + brainfile.write(" \n") + brainfile.write(" LOAD AIML {}\n".format(str(dirnumber))) + brainfile.write(" \n") + brainfile.write(" \n") + brainfile.write("") + brainfile.close() self.aiml_kernel.learn(tempbrain) - self.aiml_kernel.respond("LOAD AIML B") + # self.aiml_kernel.respond("LOAD AIML B") + for number in self.load_commands.keys(): + if number != 0: + self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber)) + os.remove(tempbrain) def on_message(self, bot, trigger, message): nick = Identifier(trigger.nick) From c33fbe7a5b9e3158fd880012eb1db9b7834c7482 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 08:22:50 -0400 Subject: [PATCH 267/328] hmmmm --- sopel_modules/SpiceBot/AI.py | 46 ++++++++++-------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index d1507d6..3165188 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -22,7 +22,6 @@ class SpiceBot_AI_MainSection(StaticSection): class SpiceBot_AI(): def __init__(self): - self.load_commands = {0: None} self.braindirs = [] self.dict = { "counts": 0, @@ -63,40 +62,21 @@ class SpiceBot_AI(): for braindir in braindirs: if braindir not in self.braindirs: self.braindirs.append(braindir) - dirnumber = max(self.load_commands.keys()) + 1 - self.load_commands[dirnumber] = braindir tempbrain = tempfile.mkstemp()[1] - # with open(tempbrain, 'w') as fileo: - # fileo.write( - # "" - # " \n" - # " \n" - # " LOAD AIML B\n" - # # " LOAD AIML {}\n" - # " \n" - # " \n" - # # "".format(str(dirnumber), os.path.join(braindir, "*")) - # "".format(os.path.join(braindir, "*.aiml")) - # ) - brainfile = open(tempbrain, 'a') - brainfile.write("") - brainfile.write(" \n") - brainfile.write(" \n") - brainfile.write(" LOAD AIML {}\n".format(str(dirnumber))) - brainfile.write(" \n") - brainfile.write(" \n") - brainfile.write("") - brainfile.close() + with open(tempbrain, 'w') as fileo: + fileo.write( + "" + " \n" + " \n" + " LOAD AIML B\n" + " \n" + " \n" + "".format(os.path.join(braindir, "*.aiml")) + ) self.aiml_kernel.learn(tempbrain) - # self.aiml_kernel.respond("LOAD AIML B") - for number in self.load_commands.keys(): - if number != 0: - self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber)) - os.remove(tempbrain) + self.aiml_kernel.respond("LOAD AIML B") def on_message(self, bot, trigger, message): nick = Identifier(trigger.nick) From 99c184ddb10aa8d50a2271738e568f99e4626ea2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 08:41:03 -0400 Subject: [PATCH 268/328] test --- .../{AI_Acknowledge.py => AI_Acknowledge} | 0 sopel_modules/SpiceBot_AI/__init__.py | 2 +- .../aiml/nickname_commands.aiml | 20 +++++++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) rename sopel_modules/SpiceBot_AI/{AI_Acknowledge.py => AI_Acknowledge} (100%) diff --git a/sopel_modules/SpiceBot_AI/AI_Acknowledge.py b/sopel_modules/SpiceBot_AI/AI_Acknowledge similarity index 100% rename from sopel_modules/SpiceBot_AI/AI_Acknowledge.py rename to sopel_modules/SpiceBot_AI/AI_Acknowledge diff --git a/sopel_modules/SpiceBot_AI/__init__.py b/sopel_modules/SpiceBot_AI/__init__.py index 16773e1..2e88872 100644 --- a/sopel_modules/SpiceBot_AI/__init__.py +++ b/sopel_modules/SpiceBot_AI/__init__.py @@ -6,7 +6,7 @@ from .AI_aiml import * from .AI_Hello import * from .AI_Goodbye import * from .AI_Thanks import * -from .AI_Acknowledge import * +#from .AI_Acknowledge import * from .AI_Lazy import * from .AI_InsultHandler import * from .AI_Ping import * diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_commands.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_commands.aiml index e9e34e8..82ddf4d 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/nickname_commands.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_commands.aiml @@ -1,12 +1,24 @@ -BOTNICK - + + BOTNICK IS COOL + -BOTNICK IS COOL - + + BOTNICK! + + + + + BOTNICK + From 4dfaf106f54928af689ab978f10d41f6f5c64826 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 08:49:09 -0400 Subject: [PATCH 269/328] split files --- ...{nickname_commands.aiml => nickname_acknowledge.aiml} | 5 ----- sopel_modules/SpiceBot_Configs/aiml/nickname_praise.aiml | 9 +++++++++ 2 files changed, 9 insertions(+), 5 deletions(-) rename sopel_modules/SpiceBot_Configs/aiml/{nickname_commands.aiml => nickname_acknowledge.aiml} (80%) create mode 100644 sopel_modules/SpiceBot_Configs/aiml/nickname_praise.aiml diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_commands.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml similarity index 80% rename from sopel_modules/SpiceBot_Configs/aiml/nickname_commands.aiml rename to sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml index 82ddf4d..427e675 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/nickname_commands.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml @@ -1,11 +1,6 @@ - - BOTNICK IS COOL - - - BOTNICK! diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_praise.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_praise.aiml new file mode 100644 index 0000000..f143dd0 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_praise.aiml @@ -0,0 +1,9 @@ + + + + + BOTNICK IS COOL + + + + From 8457d358d1abaeacde05619995e38b3f7b298b79 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 09:04:40 -0400 Subject: [PATCH 270/328] test --- sopel_modules/SpiceBot/AI.py | 3 +++ .../aiml/nickname_acknowledge.aiml | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 3165188..ebe7642 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -89,6 +89,9 @@ class SpiceBot_AI(): return aiml_response def bot_message_precipher(self, bot, trigger, message): + puct_dict = {"!": "exclamationmark", ".": "period", "?": "questionmark", ",": "comma"} + for puctuation in puct_dict.keys(): + message = message.replace(puctuation, puct_dict[puctuation]) for botitem in ["nick"]: message = message.replace(str(eval("bot." + botitem)), "bot" + botitem) for triggeritem in ["nick", "sender"]: diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml index 427e675..318d059 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml @@ -2,18 +2,18 @@ - BOTNICK! + BOTNICKexclamationmark + + BOTNICKquestionmark + + + BOTNICK - + From 202ff4634a095cd70bd4f595361070f927ecf5f2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 09:08:31 -0400 Subject: [PATCH 271/328] test --- sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml index 318d059..bc727f3 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml @@ -7,12 +7,12 @@ - BOTNICKquestionmark + BOTNICK - BOTNICK + BOTNICKquestionmark From 56d44bd01597957d9e7be8c3b2279c938a37f8ee Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 09:15:57 -0400 Subject: [PATCH 272/328] gender --- .../SpiceBot_AI/{AI_Gender.py => AI_Gender} | 0 sopel_modules/SpiceBot_AI/__init__.py | 2 +- .../SpiceBot_Configs/aiml/nickname_gender.aiml | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) rename sopel_modules/SpiceBot_AI/{AI_Gender.py => AI_Gender} (100%) create mode 100644 sopel_modules/SpiceBot_Configs/aiml/nickname_gender.aiml diff --git a/sopel_modules/SpiceBot_AI/AI_Gender.py b/sopel_modules/SpiceBot_AI/AI_Gender similarity index 100% rename from sopel_modules/SpiceBot_AI/AI_Gender.py rename to sopel_modules/SpiceBot_AI/AI_Gender diff --git a/sopel_modules/SpiceBot_AI/__init__.py b/sopel_modules/SpiceBot_AI/__init__.py index 2e88872..18c6220 100644 --- a/sopel_modules/SpiceBot_AI/__init__.py +++ b/sopel_modules/SpiceBot_AI/__init__.py @@ -13,7 +13,7 @@ from .AI_Ping import * from .AI_Love import * from .AI_Really import * from .AI_Welcomeback import * -from .AI_Gender import * +# from .AI_Gender import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_gender.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_gender.aiml new file mode 100644 index 0000000..e8eff83 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_gender.aiml @@ -0,0 +1,16 @@ + + + + + BOTNICK GENDER + + + + + + BOTNICK WHAT IS YOUR GENDER + + + + + From 28f901541101b06f8e994575afb5a426673664a4 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 11:25:17 -0400 Subject: [PATCH 273/328] goodbye --- sopel_modules/SpiceBot_AI/AI_Acknowledge | 15 ----- sopel_modules/SpiceBot_AI/AI_Gender | 10 ---- sopel_modules/SpiceBot_AI/AI_Ping.py | 15 ----- sopel_modules/SpiceBot_AI/__init__.py | 3 - .../aiml/nickname_goodbye.aiml | 56 +++++++++++++++++++ .../SpiceBot_Configs/aiml/nickname_ping.aiml | 9 +++ 6 files changed, 65 insertions(+), 43 deletions(-) delete mode 100644 sopel_modules/SpiceBot_AI/AI_Acknowledge delete mode 100644 sopel_modules/SpiceBot_AI/AI_Gender delete mode 100644 sopel_modules/SpiceBot_AI/AI_Ping.py create mode 100644 sopel_modules/SpiceBot_Configs/aiml/nickname_goodbye.aiml create mode 100644 sopel_modules/SpiceBot_Configs/aiml/nickname_ping.aiml diff --git a/sopel_modules/SpiceBot_AI/AI_Acknowledge b/sopel_modules/SpiceBot_AI/AI_Acknowledge deleted file mode 100644 index 50b1796..0000000 --- a/sopel_modules/SpiceBot_AI/AI_Acknowledge +++ /dev/null @@ -1,15 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - - -@sopel.module.rule('$nickname!') -def exclaim(bot, trigger): - bot.osd(trigger.nick + '!') - - -@sopel.module.rule('$nickname\?') -def imhere(bot, trigger): - bot.osd("I'm here, " + trigger.nick) diff --git a/sopel_modules/SpiceBot_AI/AI_Gender b/sopel_modules/SpiceBot_AI/AI_Gender deleted file mode 100644 index a2a8f5f..0000000 --- a/sopel_modules/SpiceBot_AI/AI_Gender +++ /dev/null @@ -1,10 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - - -@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_AI/AI_Ping.py b/sopel_modules/SpiceBot_AI/AI_Ping.py deleted file mode 100644 index 76b6ee4..0000000 --- a/sopel_modules/SpiceBot_AI/AI_Ping.py +++ /dev/null @@ -1,15 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - - -@sopel.module.rule(r'(?i)(ping),? $nickname[ \t]*$') -def bot_command_ping(bot, trigger): - bot.osd("Pong") - - -@sopel.module.nickname_commands('ping') -def bot_command_ping_b(bot, trigger): - bot_command_ping(bot, trigger) diff --git a/sopel_modules/SpiceBot_AI/__init__.py b/sopel_modules/SpiceBot_AI/__init__.py index 18c6220..22654e1 100644 --- a/sopel_modules/SpiceBot_AI/__init__.py +++ b/sopel_modules/SpiceBot_AI/__init__.py @@ -6,14 +6,11 @@ from .AI_aiml import * from .AI_Hello import * from .AI_Goodbye import * from .AI_Thanks import * -#from .AI_Acknowledge import * from .AI_Lazy import * from .AI_InsultHandler import * -from .AI_Ping import * from .AI_Love import * from .AI_Really import * from .AI_Welcomeback import * -# from .AI_Gender import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_goodbye.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_goodbye.aiml new file mode 100644 index 0000000..6234ef0 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_goodbye.aiml @@ -0,0 +1,56 @@ + + + + + BOTNICK BYE + + + + + BOTNICK GOODBYE + + + + + BYE BOTNICK + + + + + GOODBYE BOTNICK + + + + diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_ping.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_ping.aiml new file mode 100644 index 0000000..f6a0b7a --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_ping.aiml @@ -0,0 +1,9 @@ + + + + + BOTNICK PING + + + + From 8fec26ddee5082e3c907fde8d070530ad51fe817 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 11:46:26 -0400 Subject: [PATCH 274/328] better handling --- sopel_modules/SpiceBot/AI.py | 5 +++-- sopel_modules/SpiceBot_AI/AI_aiml.py | 13 ++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index ebe7642..c88ef4b 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -89,13 +89,14 @@ class SpiceBot_AI(): return aiml_response def bot_message_precipher(self, bot, trigger, message): + message = message.upper() puct_dict = {"!": "exclamationmark", ".": "period", "?": "questionmark", ",": "comma"} for puctuation in puct_dict.keys(): message = message.replace(puctuation, puct_dict[puctuation]) for botitem in ["nick"]: - message = message.replace(str(eval("bot." + botitem)), "bot" + botitem) + message = message.replace(str(eval("bot." + botitem)).upper(), str("bot" + botitem).upper()) for triggeritem in ["nick", "sender"]: - message = message.replace(str(eval("trigger." + triggeritem)), "trigger" + triggeritem) + message = message.replace(str(eval("trigger." + triggeritem)).upper(), str("trigger" + triggeritem).upper()) return message def bot_message_decipher(self, bot, trigger, aiml_response): diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index 2b4e4c2..278b7ff 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -6,9 +6,11 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot +import spicemanip + @sopel.module.rule('(.*)') -def bot_command_nick(bot, trigger): +def bot_command_rule(bot, trigger): # TODO add config limits # but still allow in privmsg @@ -25,6 +27,15 @@ def bot_command_nick(bot, trigger): if str(message).startswith(tuple(bot.config.core.prefix_list)): return + if str(message).lower().startswith(str(bot.nick).lower()): + trigger_args, trigger_command = SpiceBot.prerun.trigger_args(trigger.args[1], 'nickname') + + if trigger_command in SpiceBot.commands.dict['commands']["nickname"].keys(): + return + + trigger_args.insert(0, bot.nick) + message = spicemanip.main(trigger_args, 0).lower() + returnmessage = SpiceBot.botai.on_message(bot, trigger, message) if returnmessage: bot.osd(str(returnmessage)) From 7bf1a2e7003cf0d493d0851a3f397ecf5d8d83d4 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 11:55:12 -0400 Subject: [PATCH 275/328] test --- sopel_modules/SpiceBot/Prerun.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 0be912e..9093560 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -91,6 +91,7 @@ class BotPrerun(): return prerun_split def trigger_runstatus(self, bot, trigger): + return True # Bots can't run commands if Identifier(trigger.nick) == bot.nick: @@ -106,8 +107,9 @@ class BotPrerun(): # don't run commands that are disabled in channels if not trigger.is_privmsg: + commandused = trigger.sb["realcom"] disabled_list = botdb.get_channel_value(trigger.sender, 'commands_disabled') or {} - if trigger.sb["realcom"] in disabled_list.keys(): + if commandused in disabled_list.keys(): reason = disabled_list[trigger.sb["realcom"]]["reason"] timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"] bywhom = disabled_list[trigger.sb["realcom"]]["disabledby"] From 267f98aa9e3bc684a5c65534924cfcb1c396f0bd Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 11:57:45 -0400 Subject: [PATCH 276/328] better --- sopel_modules/SpiceBot_AI/AI_aiml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index 278b7ff..9af3c93 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -28,7 +28,7 @@ def bot_command_rule(bot, trigger): return if str(message).lower().startswith(str(bot.nick).lower()): - trigger_args, trigger_command = SpiceBot.prerun.trigger_args(trigger.args[1], 'nickname') + trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'nickname') if trigger_command in SpiceBot.commands.dict['commands']["nickname"].keys(): return From a9e646b3964d33d11669805a865bbe835c23adb9 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 12:02:58 -0400 Subject: [PATCH 277/328] retain formatting --- sopel_modules/SpiceBot_AI/AI_aiml.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index 9af3c93..ffea953 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -33,9 +33,6 @@ def bot_command_rule(bot, trigger): if trigger_command in SpiceBot.commands.dict['commands']["nickname"].keys(): return - trigger_args.insert(0, bot.nick) - message = spicemanip.main(trigger_args, 0).lower() - returnmessage = SpiceBot.botai.on_message(bot, trigger, message) if returnmessage: bot.osd(str(returnmessage)) From fe71dd32df1e6a1613a20f88eaecf09ed27cac5a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 12:03:10 -0400 Subject: [PATCH 278/328] remove import --- sopel_modules/SpiceBot_AI/AI_aiml.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index ffea953..901f777 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -6,8 +6,6 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot -import spicemanip - @sopel.module.rule('(.*)') def bot_command_rule(bot, trigger): From 2750597d736e9fa825bfa4217927909210db1d5b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 12:24:01 -0400 Subject: [PATCH 279/328] goodbye --- sopel_modules/SpiceBot_AI/AI_Goodbye.py | 19 ------------------- sopel_modules/SpiceBot_AI/AI_aiml.py | 1 - sopel_modules/SpiceBot_AI/__init__.py | 1 - 3 files changed, 21 deletions(-) delete mode 100644 sopel_modules/SpiceBot_AI/AI_Goodbye.py diff --git a/sopel_modules/SpiceBot_AI/AI_Goodbye.py b/sopel_modules/SpiceBot_AI/AI_Goodbye.py deleted file mode 100644 index 596da98..0000000 --- a/sopel_modules/SpiceBot_AI/AI_Goodbye.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import spicemanip - - -@sopel.module.rule(r'(?i)(bye|goodbye|gtg|seeya|cya|ttyl|g2g|gnight|goodnight),? $nickname[ \t]*$') -def bot_command_goodbye(bot, trigger): - byemsg = spicemanip.main(['Bye', 'Goodbye', 'Seeya', 'Auf Wiedersehen', 'Au revoir', 'Ttyl'], "random") - punctuation = spicemanip.main(['!', ''], "random") - bot.osd(byemsg + ' ' + trigger.nick + punctuation) - - -@sopel.module.nickname_commands("bye", "goodbye", "gtg", "seeya", "cya", "ttyl", "g2g", "gnight", "goodnight") -def bot_command_goodbye_b(bot, trigger): - bot_command_goodbye(bot, trigger) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index 901f777..520682d 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -27,7 +27,6 @@ def bot_command_rule(bot, trigger): if str(message).lower().startswith(str(bot.nick).lower()): trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'nickname') - if trigger_command in SpiceBot.commands.dict['commands']["nickname"].keys(): return diff --git a/sopel_modules/SpiceBot_AI/__init__.py b/sopel_modules/SpiceBot_AI/__init__.py index 22654e1..a5f1f17 100644 --- a/sopel_modules/SpiceBot_AI/__init__.py +++ b/sopel_modules/SpiceBot_AI/__init__.py @@ -4,7 +4,6 @@ from __future__ import unicode_literals, absolute_import, division, print_functi from .AI import * from .AI_aiml import * from .AI_Hello import * -from .AI_Goodbye import * from .AI_Thanks import * from .AI_Lazy import * from .AI_InsultHandler import * From 2cbc2b90414e125a2f74bd4637392d8c59656091 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 12:28:36 -0400 Subject: [PATCH 280/328] goodbye --- .../aiml/nickname_acknowledge.aiml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml index bc727f3..12f1a57 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_acknowledge.aiml @@ -6,14 +6,20 @@ - - BOTNICK - - - BOTNICKquestionmark + + BOTNICK + + + From 8e314f2aed8ea6ad5b9d8bafc79eab923ee672a7 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 12:40:32 -0400 Subject: [PATCH 281/328] onward --- sopel_modules/SpiceBot/Commands.py | 10 ++++++++++ sopel_modules/SpiceBot_AI/AI_aiml.py | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 75d5e33..df42c1f 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -22,6 +22,8 @@ class BotCommands(): self.lock = threading.Lock() self.dict = { "counts": 0, + 'nickrules': [], + 'nickaiml': [], "commands": { 'module': {}, 'nickname': {}, @@ -30,9 +32,17 @@ class BotCommands(): 'disabled': {} } self.module_files_parse() + self.nickrules() for comtype in ['module', 'nickname', 'rule']: logs.log('SpiceBot_Commands', "Found " + str(len(self.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) + def nickrules(self): + for command in self.dict['commands']['rule'].keys(): + if command.startswith("$nickname"): + command = command.split("$nickname")[-1] + if command not in self.dict['nickrules']: + self.dict['nickrules'].append(command) + def find_command_type(self, command): for commandstype in self.dict['commands'].keys(): if commandstype not in ['rule']: diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index 520682d..8726191 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -6,6 +6,8 @@ import sopel.module import sopel_modules.SpiceBot as SpiceBot +import spicemanip + @sopel.module.rule('(.*)') def bot_command_rule(bot, trigger): @@ -27,9 +29,25 @@ def bot_command_rule(bot, trigger): if str(message).lower().startswith(str(bot.nick).lower()): trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'nickname') + if str(trigger_command).startswith("?"): + return + fulltrigger = spicemanip.main(trigger_args, 0) + if fulltrigger in SpiceBot.commands.dict['nickrules']: + return if trigger_command in SpiceBot.commands.dict['commands']["nickname"].keys(): return + else: + trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'module') returnmessage = SpiceBot.botai.on_message(bot, trigger, message) if returnmessage: bot.osd(str(returnmessage)) + else: + closestmatches = SpiceBot.similar_list(bot, trigger_command, SpiceBot.commands.dict['commands']["nickname"].keys(), 3, 'reverse') + if len(closestmatches): + closestmatches = spicemanip.main(closestmatches, "andlist") + bot.osd("I don't know what you are asking me to do! Did you mean: " + str(closestmatches) + "?") + return + else: + bot.osd("I don't know what you are asking me to do!") + return From de21eb9367fa1bb1abf274fb584b5870ec9e13ae Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 13:40:31 -0400 Subject: [PATCH 282/328] bot remove --- sopel_modules/SpiceBot_AI/AI_aiml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index 8726191..4d21dcd 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -43,7 +43,7 @@ def bot_command_rule(bot, trigger): if returnmessage: bot.osd(str(returnmessage)) else: - closestmatches = SpiceBot.similar_list(bot, trigger_command, SpiceBot.commands.dict['commands']["nickname"].keys(), 3, 'reverse') + closestmatches = SpiceBot.similar_list(trigger_command, SpiceBot.commands.dict['commands']["nickname"].keys(), 3, 'reverse') if len(closestmatches): closestmatches = spicemanip.main(closestmatches, "andlist") bot.osd("I don't know what you are asking me to do! Did you mean: " + str(closestmatches) + "?") From c5a4c559cf84693bf79ee95395ff9c4a07f12ba5 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 13:54:43 -0400 Subject: [PATCH 283/328] test parsing --- sopel_modules/SpiceBot/AI.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index c88ef4b..ee1ceeb 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -10,6 +10,7 @@ from sopel.config.types import StaticSection, ListAttribute import os import tempfile import aiml +import untangle from .Database import db as botdb from .Logs import logs @@ -78,6 +79,24 @@ class SpiceBot_AI(): self.aiml_kernel.learn(tempbrain) self.aiml_kernel.respond("LOAD AIML B") + def count_aiml_coms(self): + filepathlist = [] + for braindir in self.braindirs: + for pathname in os.listdir(braindir): + path = os.path.join(braindir, pathname) + if os.path.isfile(path) and path.endswith('.aiml'): + filepathlist.append(str(path)) + + for aimlfile in filepathlist: + + try: + aiml_dict = untangle.parse(aimlfile) + logs.log('SpiceBot_AI', aiml_dict) + self.dict["counts"] += 1 + except Exception as e: + logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, aimlfile)) + self.dict["failcounts"] += 1 + def on_message(self, bot, trigger, message): nick = Identifier(trigger.nick) nick_id = botdb.get_nick_id(nick, create=True) @@ -128,13 +147,5 @@ class SpiceBot_AI(): sessionData = self.aiml_kernel.getSessionData(nick_id) botdb.set_nick_value(nick, 'botai', sessionData) - def check_file_parse(self, parsefile): - try: - self.aiml_parser.parse(parsefile) - self.dict["counts"] += 1 - except Exception as e: - logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, parsefile)) - self.dict["failcounts"] += 1 - botai = SpiceBot_AI() From 9829751b4a8a27da3bc1bda78dc9c38a24411129 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 14:00:51 -0400 Subject: [PATCH 284/328] counts --- sopel_modules/SpiceBot/AI.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index ee1ceeb..b8c37d7 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -40,6 +40,7 @@ class SpiceBot_AI(): # Learn responses self.load_brain() + self.count_aiml_coms() def load_brain(self): import sopel_modules @@ -51,6 +52,7 @@ class SpiceBot_AI(): # learn directories self.learn(braindirs) + self.count_aiml_coms() def load_bot_values(self, bot): self.aiml_kernel.setBotPredicate("nick", bot.nick) @@ -88,13 +90,18 @@ class SpiceBot_AI(): filepathlist.append(str(path)) for aimlfile in filepathlist: + filereadgood = True try: - aiml_dict = untangle.parse(aimlfile) - logs.log('SpiceBot_AI', aiml_dict) - self.dict["counts"] += 1 + dict_from_file = untangle.parse(aimlfile) + logs.log('SpiceBot_AI', dict_from_file) except Exception as e: + filereadgood = False logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, aimlfile)) + + if filereadgood and isinstance(dict_from_file, dict): + self.dict["counts"] += 1 + else: self.dict["failcounts"] += 1 def on_message(self, bot, trigger, message): From 72b84df5f3c1a0b6ae2778a24b638bfc980d4f49 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 14:05:18 -0400 Subject: [PATCH 285/328] test --- sopel_modules/SpiceBot/AI.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index b8c37d7..01b7eb6 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -94,10 +94,11 @@ class SpiceBot_AI(): try: dict_from_file = untangle.parse(aimlfile) - logs.log('SpiceBot_AI', dict_from_file) + # logs.log('SpiceBot_AI', dict_from_file) except Exception as e: + filereadgood = e filereadgood = False - logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, aimlfile)) + # logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, aimlfile)) if filereadgood and isinstance(dict_from_file, dict): self.dict["counts"] += 1 From 1691f95eba1dc35a1dcea53cbded3f98b936c0e9 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 14:15:52 -0400 Subject: [PATCH 286/328] test --- sopel_modules/SpiceBot/AI.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 01b7eb6..f42bf61 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -100,11 +100,23 @@ class SpiceBot_AI(): filereadgood = False # logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, aimlfile)) - if filereadgood and isinstance(dict_from_file, dict): + if filereadgood: self.dict["counts"] += 1 else: self.dict["failcounts"] += 1 + """def donothing(): + aiml_file_lines = [] + aiml_file = open(aimlfile, 'r') + lines = aiml_file.readlines() + for line in lines: + aiml_file_lines.append(line) + aiml_file.close() + + detected_lines = [] + for line in aiml_file_lines: + dothing = True""" + def on_message(self, bot, trigger, message): nick = Identifier(trigger.nick) nick_id = botdb.get_nick_id(nick, create=True) From 7117ce0a49dea8a7f975af82269acfd9d9847f71 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 14:17:07 -0400 Subject: [PATCH 287/328] test --- sopel_modules/SpiceBot/AI.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index f42bf61..6aff0f2 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -82,6 +82,8 @@ class SpiceBot_AI(): self.aiml_kernel.respond("LOAD AIML B") def count_aiml_coms(self): + self.dict["counts"] = 0 + self.dict["failcounts"] = 0 filepathlist = [] for braindir in self.braindirs: for pathname in os.listdir(braindir): From 8563cb11983058abbb39752396b48218bdef9c66 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 14:22:30 -0400 Subject: [PATCH 288/328] test --- sopel_modules/SpiceBot/AI.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 6aff0f2..7bf9ce6 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -27,7 +27,8 @@ class SpiceBot_AI(): self.dict = { "counts": 0, "failcounts": 0, - "sessioncache": {} + "sessioncache": {}, + "files": {} } # Load AIML kernel self.aiml_kernel = aiml.Kernel() @@ -104,6 +105,8 @@ class SpiceBot_AI(): if filereadgood: self.dict["counts"] += 1 + if aimlfile not in self.dict["files"]: + self.dict["files"][aimlfile] = dict_from_file else: self.dict["failcounts"] += 1 From 9508f3b18b880bc319d376dacf88def2f0c4b7d3 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 14:34:16 -0400 Subject: [PATCH 289/328] test --- sopel_modules/SpiceBot/AI.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 7bf9ce6..9523f1b 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -10,10 +10,11 @@ from sopel.config.types import StaticSection, ListAttribute import os import tempfile import aiml -import untangle +import xmltodict +import json from .Database import db as botdb -from .Logs import logs + class SpiceBot_AI_MainSection(StaticSection): @@ -96,12 +97,11 @@ class SpiceBot_AI(): filereadgood = True try: - dict_from_file = untangle.parse(aimlfile) - # logs.log('SpiceBot_AI', dict_from_file) + with open(aimlfile) as fd: + dict_from_file = xmltodict.parse(fd.read()) except Exception as e: filereadgood = e filereadgood = False - # logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, aimlfile)) if filereadgood: self.dict["counts"] += 1 From 54916bdae720ea077c447689f752d805dcca27d9 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 14:46:12 -0400 Subject: [PATCH 290/328] test --- sopel_modules/SpiceBot/AI.py | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 9523f1b..d8d019f 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -11,12 +11,10 @@ import os import tempfile import aiml import xmltodict -import json from .Database import db as botdb - class SpiceBot_AI_MainSection(StaticSection): extra = ListAttribute('extra') @@ -95,33 +93,30 @@ class SpiceBot_AI(): for aimlfile in filepathlist: filereadgood = True + aiml_file_lines = [] + aiml_file = open(aimlfile, 'r') + lines = aiml_file.readlines() + for line in lines: + aiml_file_lines.append(str(line)) + aiml_file.close() - try: - with open(aimlfile) as fd: - dict_from_file = xmltodict.parse(fd.read()) - except Exception as e: - filereadgood = e + detected_lines = [] + for line in aiml_file_lines: + if line.startswith(""): + line = line.replace("", '') + line = line.replace("", '') + detected_lines.append(line) + + if not len(detected_lines): filereadgood = False if filereadgood: self.dict["counts"] += 1 if aimlfile not in self.dict["files"]: - self.dict["files"][aimlfile] = dict_from_file + self.dict["files"][aimlfile] = detected_lines else: self.dict["failcounts"] += 1 - """def donothing(): - aiml_file_lines = [] - aiml_file = open(aimlfile, 'r') - lines = aiml_file.readlines() - for line in lines: - aiml_file_lines.append(line) - aiml_file.close() - - detected_lines = [] - for line in aiml_file_lines: - dothing = True""" - def on_message(self, bot, trigger, message): nick = Identifier(trigger.nick) nick_id = botdb.get_nick_id(nick, create=True) From 644fe28e3c0dc2b2fc5db862d5a2579b3dd1743b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 14:59:06 -0400 Subject: [PATCH 291/328] test --- sopel_modules/SpiceBot/AI.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index d8d019f..6c810ae 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -10,7 +10,7 @@ from sopel.config.types import StaticSection, ListAttribute import os import tempfile import aiml -import xmltodict +from xml.etree import ElementTree from .Database import db as botdb @@ -93,6 +93,11 @@ class SpiceBot_AI(): for aimlfile in filepathlist: filereadgood = True + tree = ElementTree.parse(aimlfile) + root = tree.getroot() + if aimlfile not in self.dict["files"]: + self.dict["files"][aimlfile] = root + return aiml_file_lines = [] aiml_file = open(aimlfile, 'r') lines = aiml_file.readlines() From 8982e89796382fdf1ae8122662ba0775d4621a94 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 15:29:02 -0400 Subject: [PATCH 292/328] test --- sopel_modules/SpiceBot/AI.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 6c810ae..bcfa586 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -10,7 +10,7 @@ from sopel.config.types import StaticSection, ListAttribute import os import tempfile import aiml -from xml.etree import ElementTree +from xml.dom import minidom from .Database import db as botdb @@ -93,10 +93,9 @@ class SpiceBot_AI(): for aimlfile in filepathlist: filereadgood = True - tree = ElementTree.parse(aimlfile) - root = tree.getroot() + xmldoc = minidom.parse(aimlfile) if aimlfile not in self.dict["files"]: - self.dict["files"][aimlfile] = root + self.dict["files"][aimlfile] = xmldoc return aiml_file_lines = [] aiml_file = open(aimlfile, 'r') From cf6d431a17df3e706bee217acd4ca73a8b2d366c Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 15:36:16 -0400 Subject: [PATCH 293/328] test --- sopel_modules/SpiceBot/AI.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index bcfa586..4e650e0 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -10,7 +10,7 @@ from sopel.config.types import StaticSection, ListAttribute import os import tempfile import aiml -from xml.dom import minidom +from bs4 import BeautifulSoup from .Database import db as botdb @@ -93,7 +93,7 @@ class SpiceBot_AI(): for aimlfile in filepathlist: filereadgood = True - xmldoc = minidom.parse(aimlfile) + xmldoc = BeautifulSoup(aimlfile) if aimlfile not in self.dict["files"]: self.dict["files"][aimlfile] = xmldoc return From c4027e2c71ecf6feefe89e711ce4f4603eef4af1 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 15:39:16 -0400 Subject: [PATCH 294/328] bugfix --- sopel_modules/SpiceBot_AI/AI_aiml.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index 4d21dcd..c3bf735 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -28,6 +28,7 @@ def bot_command_rule(bot, trigger): return if str(message).lower().startswith(str(bot.nick).lower()): + command_type = 'nickname' trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'nickname') if str(trigger_command).startswith("?"): return @@ -37,17 +38,19 @@ def bot_command_rule(bot, trigger): if trigger_command in SpiceBot.commands.dict['commands']["nickname"].keys(): return else: + command_type = 'module' trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'module') returnmessage = SpiceBot.botai.on_message(bot, trigger, message) if returnmessage: bot.osd(str(returnmessage)) else: - closestmatches = SpiceBot.similar_list(trigger_command, SpiceBot.commands.dict['commands']["nickname"].keys(), 3, 'reverse') - if len(closestmatches): - closestmatches = spicemanip.main(closestmatches, "andlist") - bot.osd("I don't know what you are asking me to do! Did you mean: " + str(closestmatches) + "?") - return - else: - bot.osd("I don't know what you are asking me to do!") - return + if command_type == 'nickname': + closestmatches = SpiceBot.similar_list(trigger_command, SpiceBot.commands.dict['commands']["nickname"].keys(), 3, 'reverse') + if len(closestmatches): + closestmatches = spicemanip.main(closestmatches, "andlist") + bot.osd("I don't know what you are asking me to do! Did you mean: " + str(closestmatches) + "?") + return + else: + bot.osd("I don't know what you are asking me to do!") + return From 8ad0e98e9eb0773646ece3f051c9ee4bd8a03594 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 15:44:00 -0400 Subject: [PATCH 295/328] invalid command detection --- sopel_modules/SpiceBot_AI/AI_aiml.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index c3bf735..417f261 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -25,6 +25,18 @@ def bot_command_rule(bot, trigger): # ignore text coming from a valid prefix if str(message).startswith(tuple(bot.config.core.prefix_list)): + trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'module') + commands_list = [] + for commandstype in SpiceBot.commands.dict['commands'].keys(): + if commandstype not in ['rule', 'nickname']: + for com in SpiceBot.commands.dict['commands'][commandstype].keys(): + if com not in commands_list: + commands_list.append(com) + if trigger_command not in commands_list: + invalid_display = ["I don't seem to have a command for " + str(trigger_command) + "!"] + invalid_display.append("If you have a suggestion for this command, you can run .feature ." + str(trigger_command)) + invalid_display.append("ADD DESCRIPTION HERE!") + bot.osd(invalid_display, trigger.nick, 'notice') return if str(message).lower().startswith(str(bot.nick).lower()): From 576a98749d28a7fcdc356b3ecec1fbfb6497b60a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 15:56:19 -0400 Subject: [PATCH 296/328] not today --- sopel_modules/SpiceBot/AI.py | 43 ------------------------------------ 1 file changed, 43 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 4e650e0..2ca5934 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -10,7 +10,6 @@ from sopel.config.types import StaticSection, ListAttribute import os import tempfile import aiml -from bs4 import BeautifulSoup from .Database import db as botdb @@ -40,7 +39,6 @@ class SpiceBot_AI(): # Learn responses self.load_brain() - self.count_aiml_coms() def load_brain(self): import sopel_modules @@ -52,7 +50,6 @@ class SpiceBot_AI(): # learn directories self.learn(braindirs) - self.count_aiml_coms() def load_bot_values(self, bot): self.aiml_kernel.setBotPredicate("nick", bot.nick) @@ -81,46 +78,6 @@ class SpiceBot_AI(): self.aiml_kernel.learn(tempbrain) self.aiml_kernel.respond("LOAD AIML B") - def count_aiml_coms(self): - self.dict["counts"] = 0 - self.dict["failcounts"] = 0 - filepathlist = [] - for braindir in self.braindirs: - for pathname in os.listdir(braindir): - path = os.path.join(braindir, pathname) - if os.path.isfile(path) and path.endswith('.aiml'): - filepathlist.append(str(path)) - - for aimlfile in filepathlist: - filereadgood = True - xmldoc = BeautifulSoup(aimlfile) - if aimlfile not in self.dict["files"]: - self.dict["files"][aimlfile] = xmldoc - return - aiml_file_lines = [] - aiml_file = open(aimlfile, 'r') - lines = aiml_file.readlines() - for line in lines: - aiml_file_lines.append(str(line)) - aiml_file.close() - - detected_lines = [] - for line in aiml_file_lines: - if line.startswith(""): - line = line.replace("", '') - line = line.replace("", '') - detected_lines.append(line) - - if not len(detected_lines): - filereadgood = False - - if filereadgood: - self.dict["counts"] += 1 - if aimlfile not in self.dict["files"]: - self.dict["files"][aimlfile] = detected_lines - else: - self.dict["failcounts"] += 1 - def on_message(self, bot, trigger, message): nick = Identifier(trigger.nick) nick_id = botdb.get_nick_id(nick, create=True) From 04132fe7cd6cd02b8d7d1ebb3297bd98c9041c7c Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 15:57:33 -0400 Subject: [PATCH 297/328] test --- sopel_modules/SpiceBot_AI/AI_aiml.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index 417f261..84cd807 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -33,6 +33,8 @@ def bot_command_rule(bot, trigger): if com not in commands_list: commands_list.append(com) if trigger_command not in commands_list: + if not SpiceBot.letters_in_string(trigger_command): + return invalid_display = ["I don't seem to have a command for " + str(trigger_command) + "!"] invalid_display.append("If you have a suggestion for this command, you can run .feature ." + str(trigger_command)) invalid_display.append("ADD DESCRIPTION HERE!") From 6634617b1e93e20d0fdbf00997f6990797445b73 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 15:57:52 -0400 Subject: [PATCH 298/328] no fr yet --- sopel_modules/SpiceBot_AI/AI_aiml.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index 84cd807..b5d2d4c 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -36,8 +36,8 @@ def bot_command_rule(bot, trigger): if not SpiceBot.letters_in_string(trigger_command): return invalid_display = ["I don't seem to have a command for " + str(trigger_command) + "!"] - invalid_display.append("If you have a suggestion for this command, you can run .feature ." + str(trigger_command)) - invalid_display.append("ADD DESCRIPTION HERE!") + # invalid_display.append("If you have a suggestion for this command, you can run .feature ." + str(trigger_command)) + # invalid_display.append("ADD DESCRIPTION HERE!") bot.osd(invalid_display, trigger.nick, 'notice') return From 766ff9e9d082b20ffd3057fafd77d510047ee9d4 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 4 Jun 2019 16:18:40 -0400 Subject: [PATCH 299/328] hmm --- sopel_modules/SpiceBot_AI/AI_aiml.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index b5d2d4c..3ac2b3b 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -26,6 +26,9 @@ def bot_command_rule(bot, trigger): # ignore text coming from a valid prefix if str(message).startswith(tuple(bot.config.core.prefix_list)): trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'module') + # patch for people typing "...", maybe other stuff, but this verifies that there is still a command here + if trigger_command.startswith("."): + return commands_list = [] for commandstype in SpiceBot.commands.dict['commands'].keys(): if commandstype not in ['rule', 'nickname']: From 80eb81023842bb866ea27546eddc2cef77e97a53 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 08:03:08 -0400 Subject: [PATCH 300/328] save brain to seperate file as well --- sopel_modules/SpiceBot/AI.py | 19 ++++++++++++++++++- sopel_modules/SpiceBot/Config.py | 2 ++ sopel_modules/SpiceBot/setup.py | 2 ++ sopel_modules/SpiceBot/shutdown.py | 3 ++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 2ca5934..21144cd 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -12,6 +12,7 @@ import tempfile import aiml from .Database import db as botdb +from .Config import config as botconfig class SpiceBot_AI_MainSection(StaticSection): @@ -38,8 +39,14 @@ class SpiceBot_AI(): self.aiml_kernel._verboseMode = False # Learn responses + self.load_saved_brain() self.load_brain() + def load_saved_brain(self): + if os.path.isfile(botconfig.config.aibrain): + self.aiml_kernel.bootstrap(brainFile=botconfig.config.aibrain) + self.save_brain() + def load_brain(self): import sopel_modules braindirs = [] @@ -50,6 +57,7 @@ class SpiceBot_AI(): # learn directories self.learn(braindirs) + self.save_brain() def load_bot_values(self, bot): self.aiml_kernel.setBotPredicate("nick", bot.nick) @@ -57,6 +65,7 @@ class SpiceBot_AI(): def load_extras(self, bot): if len(bot.config.SpiceBot_AI.extra): self.learn(self, bot.config.SpiceBot_AI.extra) + self.save_brain() def learn(self, braindirs): for braindir in braindirs: @@ -79,13 +88,18 @@ class SpiceBot_AI(): self.aiml_kernel.respond("LOAD AIML B") def on_message(self, bot, trigger, message): + nick = Identifier(trigger.nick) nick_id = botdb.get_nick_id(nick, create=True) self.check_user_import(nick, nick_id) + message = self.bot_message_precipher(bot, trigger, message) aiml_response = self.aiml_kernel.respond(message, nick_id) - self.save_nick_session(nick, nick_id) aiml_response = self.bot_message_decipher(bot, trigger, aiml_response) + + self.save_nick_session(nick, nick_id) + self.save_brain() + return aiml_response def bot_message_precipher(self, bot, trigger, message): @@ -128,5 +142,8 @@ class SpiceBot_AI(): sessionData = self.aiml_kernel.getSessionData(nick_id) botdb.set_nick_value(nick, 'botai', sessionData) + def save_brain(self): + self.aiml_kernel.saveBrain(botconfig.config.aibrain) + botai = SpiceBot_AI() diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 3f0bcbf..4d535d8 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -35,6 +35,8 @@ class BotConfig(): self.config.core.logs_raw = os.path.join(self.config.core.logdir, 'raw.log') # self.config.core.logs_raw = os.path.os.path.join(self.config.core.logdir, self.config.basename + '.raw.log') + self.config.aibrain = os.path.join(self.config.homedir, self.config.basename + '.aibrain.brn') + # load as dict config = configparser.ConfigParser() config.read(self.config.filename) diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index 2a57052..8dcc54d 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -59,6 +59,8 @@ def setup(bot): bot.config.core.logs_raw = os.path.join(bot.config.core.logdir, 'raw.log') # bot.config.core.logs_raw = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.raw.log') + bot.config.aibrain = os.path.join(bot.config.homedir, bot.config.basename + '.aibrain.brn') + logs.log('SpiceBot_Channels', "Setting Up Configuration") events.startup_add([events.BOT_CHANNELS]) bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) diff --git a/sopel_modules/SpiceBot/shutdown.py b/sopel_modules/SpiceBot/shutdown.py index d664695..091b615 100644 --- a/sopel_modules/SpiceBot/shutdown.py +++ b/sopel_modules/SpiceBot/shutdown.py @@ -6,4 +6,5 @@ from .AI import botai def shutdown(bot): - pass + + botai.save_brain() From 4380aeb6cf11d4049978e5e076a46816c3dc85cb Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 08:31:52 -0400 Subject: [PATCH 301/328] configurable gender --- sopel_modules/SpiceBot/AI.py | 4 +++- sopel_modules/SpiceBot/configure.py | 1 + sopel_modules/SpiceBot_Configs/aiml/nickname_gender.aiml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 21144cd..73cc03f 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -5,7 +5,7 @@ This is the SpiceBot AI system. Based On Chatty cathy """ from sopel.tools import Identifier -from sopel.config.types import StaticSection, ListAttribute +from sopel.config.types import StaticSection, ListAttribute, ValidatedAttribute import os import tempfile @@ -17,6 +17,7 @@ from .Config import config as botconfig class SpiceBot_AI_MainSection(StaticSection): extra = ListAttribute('extra') + gender = ValidatedAttribute('gender', default='female') class SpiceBot_AI(): @@ -61,6 +62,7 @@ class SpiceBot_AI(): def load_bot_values(self, bot): self.aiml_kernel.setBotPredicate("nick", bot.nick) + self.aiml_kernel.setBotPredicate("gender", bot.config.SpiceBot_AI.gender) def load_extras(self, bot): if len(bot.config.SpiceBot_AI.extra): diff --git a/sopel_modules/SpiceBot/configure.py b/sopel_modules/SpiceBot/configure.py index dbcc464..6469d17 100644 --- a/sopel_modules/SpiceBot/configure.py +++ b/sopel_modules/SpiceBot/configure.py @@ -35,3 +35,4 @@ def configure(config): config.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) config.SpiceBot_AI.configure_setting('extra', 'extra aiml directories to import matches from') + config.SpiceBot_AI.configure_setting('gender', 'bot gender') diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_gender.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_gender.aiml index e8eff83..9c4070e 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/nickname_gender.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_gender.aiml @@ -9,7 +9,7 @@ BOTNICK WHAT IS YOUR GENDER - + From 0ce1c8e0e9e9a0d5eda206cd8aec9e6acdcd4bde Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 08:47:27 -0400 Subject: [PATCH 302/328] quick loads patch --- sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py index addfd3f..9f2945d 100644 --- a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py +++ b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py @@ -51,6 +51,8 @@ def bot_startup_monologue_display(bot, trigger): dispmsg.append(SpiceBot.startupmonologue.dict[messagekey]) if SpiceBot.events.dict["RPL_WELCOME_Count"] == 1: timesince = SpiceBot.humanized_time(time.time() - SpiceBot.events.BOT_UPTIME) + if timesince == "just now": + timesince = "1 second" dispmsg.append("Startup took " + timesince) # Announce to chan, then handle some closing stuff SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " startup complete") From be2d0eea2a91b7312cc400a2229550ab3af6afc9 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 08:58:01 -0400 Subject: [PATCH 303/328] verify settings get set --- sopel_modules/SpiceBot/AI.py | 24 ++++++++++++++++-------- sopel_modules/SpiceBot/setup.py | 2 -- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 73cc03f..92ccbd6 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -39,10 +39,19 @@ class SpiceBot_AI(): # Don't warn for no matches self.aiml_kernel._verboseMode = False + # Config + self.botai_config() + # Learn responses self.load_saved_brain() self.load_brain() + # Load bot values + self.load_bot_values() + + def botai_config(self): + botconfig.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) + def load_saved_brain(self): if os.path.isfile(botconfig.config.aibrain): self.aiml_kernel.bootstrap(brainFile=botconfig.config.aibrain) @@ -56,18 +65,17 @@ class SpiceBot_AI(): aimldir = os.path.join(configsdir, "aiml") braindirs.append(aimldir) + if len(botconfig.SpiceBot_AI.extra): + for extrabraindir in botconfig.SpiceBot_AI.extra: + braindirs.append(extrabraindir) + # learn directories self.learn(braindirs) self.save_brain() - def load_bot_values(self, bot): - self.aiml_kernel.setBotPredicate("nick", bot.nick) - self.aiml_kernel.setBotPredicate("gender", bot.config.SpiceBot_AI.gender) - - def load_extras(self, bot): - if len(bot.config.SpiceBot_AI.extra): - self.learn(self, bot.config.SpiceBot_AI.extra) - self.save_brain() + def load_bot_values(self): + self.aiml_kernel.setBotPredicate("nick", botconfig.nick) + self.aiml_kernel.setBotPredicate("gender", botconfig.SpiceBot_AI.gender) def learn(self, braindirs): for braindir in braindirs: diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index 8dcc54d..08e67c4 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -81,5 +81,3 @@ def setup(bot): logs.log('SpiceBot_AI', "Setting Up Configuration") bot.config.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) - botai.load_extras(bot) - botai.load_bot_values(bot) From 400c08af90416711ef849245946546a1485ff849 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 09:11:02 -0400 Subject: [PATCH 304/328] test --- sopel_modules/SpiceBot/AI.py | 6 +++--- sopel_modules/SpiceBot/Channels.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 92ccbd6..2201ee3 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -23,6 +23,9 @@ class SpiceBot_AI_MainSection(StaticSection): class SpiceBot_AI(): def __init__(self): + + botconfig.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) + self.braindirs = [] self.dict = { "counts": 0, @@ -49,9 +52,6 @@ class SpiceBot_AI(): # Load bot values self.load_bot_values() - def botai_config(self): - botconfig.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) - def load_saved_brain(self): if os.path.isfile(botconfig.config.aibrain): self.aiml_kernel.bootstrap(brainFile=botconfig.config.aibrain) diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index b664c2d..bf35781 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -77,20 +77,20 @@ class BotChannels(): self.lock.release() def join_all_channels(self, bot): - if bot.config.SpiceBot_Channels.joinall: + if botconfig.SpiceBot_Channels.joinall: for channel in self.dict['list'].keys(): if channel.startswith("#"): - if channel not in bot.channels.keys() and channel not in bot.config.SpiceBot_Channels.chanignore: + if channel not in bot.channels.keys() and channel not in botconfig.SpiceBot_Channels.chanignore: bot.write(('JOIN', bot.nick, self.dict['list'][channel]['name'])) - if channel not in bot.channels.keys() and bot.config.SpiceBot_Channels.operadmin: + if channel not in bot.channels.keys() and botconfig.SpiceBot_Channels.operadmin: bot.write(('SAJOIN', bot.nick, self.dict['list'][channel]['name'])) def chanadmin_all_channels(self, bot): # Chan ADMIN +a for channel in bot.channels.keys(): if channel.startswith("#"): - if channel not in bot.config.SpiceBot_Channels.chanignore: - if bot.config.SpiceBot_Channels.operadmin: + if channel not in bot.configSpiceBot_Channels.chanignore: + if botconfig.SpiceBot_Channels.operadmin: if not bot.channels[channel].privileges[bot.nick] < sopel.module.ADMIN: bot.write(('SAMODE', channel, "+a", bot.nick)) else: From 3bb35eb46ae97da3c50880da0b9baca9d1b14d79 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 09:11:53 -0400 Subject: [PATCH 305/328] remove import --- sopel_modules/SpiceBot/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index 08e67c4..e49425a 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -15,7 +15,7 @@ from .Channels import SpiceBot_Channels_MainSection from .Update import SpiceBot_Update_MainSection from .osd import SopelWrapperOSD, ToolsOSD, SopelOSD, SpiceBot_OSD from .Kick import SopelWrapperKICK, SopelKICK, SpiceBot_Kick -from .AI import SpiceBot_AI_MainSection, botai +from .AI import SpiceBot_AI_MainSection def setup(bot): From d241ceb787cb1f3379e6a6e2a0ceaf954bb67dc2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 10:04:07 -0400 Subject: [PATCH 306/328] update setup procedures for configuration --- sopel_modules/SpiceBot/AI.py | 8 +- sopel_modules/SpiceBot/Channels.py | 9 +-- sopel_modules/SpiceBot/Commands.py | 13 ++++ sopel_modules/SpiceBot/Config.py | 17 ++--- sopel_modules/SpiceBot/Logs.py | 16 +++- sopel_modules/SpiceBot/setup.py | 116 ++++++++++++++++++++--------- 6 files changed, 122 insertions(+), 57 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 2201ee3..3485414 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -23,9 +23,7 @@ class SpiceBot_AI_MainSection(StaticSection): class SpiceBot_AI(): def __init__(self): - - botconfig.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) - + self.setup_ai() self.braindirs = [] self.dict = { "counts": 0, @@ -52,6 +50,10 @@ class SpiceBot_AI(): # Load bot values self.load_bot_values() + def setup_ai(self): + botconfig.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) + botconfig.aibrain = os.path.join(botconfig.homedir, botconfig.basename + '.aibrain.brn') + def load_saved_brain(self): if os.path.isfile(botconfig.config.aibrain): self.aiml_kernel.bootstrap(brainFile=botconfig.config.aibrain) diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index bf35781..79eeda4 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -10,7 +10,6 @@ import re import threading from .Config import config as botconfig -from .Logs import logs class SpiceBot_Channels_MainSection(StaticSection): @@ -23,10 +22,7 @@ class SpiceBot_Channels_MainSection(StaticSection): class BotChannels(): """This Logs all channels known to the server""" def __init__(self): - - # SpiceBot - logs.log('SpiceBot_Channels', "Setting Up BotChannels class") - botconfig.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) + self.setup_channels() self.lock = threading.Lock() self.channel_lock = False @@ -35,6 +31,9 @@ class BotChannels(): "InitialProcess": False } + def setup_channels(self): + botconfig.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) + def channel_list_request(self, bot): bot.write(['LIST']) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index df42c1f..e495b21 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -5,7 +5,10 @@ This is the SpiceBot Commands system. This Class stores commands in an easy to access manner """ + import sopel +from sopel.config.types import StaticSection, ValidatedAttribute + import os import threading @@ -16,9 +19,14 @@ from .Config import config as botconfig from .Database import db as botdb +class SpiceBot_Commands_MainSection(StaticSection): + query_prefix = ValidatedAttribute('query_prefix', default="?") + + class BotCommands(): """This Logs all commands known to the bot""" def __init__(self): + self.setup_commands() self.lock = threading.Lock() self.dict = { "counts": 0, @@ -36,6 +44,11 @@ class BotCommands(): for comtype in ['module', 'nickname', 'rule']: logs.log('SpiceBot_Commands', "Found " + str(len(self.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True) + def setup_commands(self): + botconfig.define_section("SpiceBot_Commands", SpiceBot_Commands_MainSection, validate=False) + botconfig.core.query_list = str(botconfig.SpiceBot_Commands.query_prefix).replace("\\", '').split("|") + botconfig.core.prefix_list.extend(botconfig.SpiceBot_Commands.query_prefix) + def nickrules(self): for command in self.dict['commands']['rule'].keys(): if command.startswith("$nickname"): diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 4d535d8..983ea1f 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -24,18 +24,7 @@ class BotConfig(): opts = parser.parse_args(argv) self.config = get_configuration(opts) - self.config.core.prefix_list = str(self.config.core.prefix).replace("\\", '').split("|") - self.config.core.prefix_list.append("?") - - self.config.basename = os.path.basename(self.config.filename).rsplit('.', 1)[0] - self.config.core.logs_stdio = os.path.join(self.config.core.logdir, 'stdio.log') - # self.config.core.logs_stdio = os.path.os.path.join(self.config.core.logdir, self.config.basename + '.stdio.log') - self.config.core.logs_exceptions = os.path.join(self.config.core.logdir, 'exceptions.log') - # self.config.core.logs_exceptions = os.path.os.path.join(self.config.core.logdir, self.config.basename + '.exceptions.log') - self.config.core.logs_raw = os.path.join(self.config.core.logdir, 'raw.log') - # self.config.core.logs_raw = os.path.os.path.join(self.config.core.logdir, self.config.basename + '.raw.log') - - self.config.aibrain = os.path.join(self.config.homedir, self.config.basename + '.aibrain.brn') + self.setup_config() # load as dict config = configparser.ConfigParser() @@ -47,6 +36,10 @@ class BotConfig(): if each_key.lower() not in self.dict[each_section.lower()].keys(): self.dict[each_section.lower()][each_key.lower()] = each_val + def setup_config(self): + self.config.core.basename = os.path.basename(self.config.filename).rsplit('.', 1)[0] + self.config.core.prefix_list = str(self.config.core.prefix).replace("\\", '').split("|") + def define_section(self, name, cls_, validate=True): return self.config.define_section(name, cls_, validate) diff --git a/sopel_modules/SpiceBot/Logs.py b/sopel_modules/SpiceBot/Logs.py index 4e422fd..1226d98 100644 --- a/sopel_modules/SpiceBot/Logs.py +++ b/sopel_modules/SpiceBot/Logs.py @@ -6,9 +6,9 @@ This is the SpiceBot Logs system. This Class stores logs in an easy to access manner """ -import sopel import threading import os +import sys import spicemanip from .Config import config as botconfig @@ -19,12 +19,24 @@ from .Config import config as botconfig class BotLogs(): """This Is a contained source of log information""" def __init__(self): + self.setup_logs() self.lock = threading.Lock() self.dict = { "list": {"Sopel_systemd": [], "Sopel_stdio": []}, "queue": [] } + def setup_logs(self): + botconfig.core.logs_stdio = os.path.join(botconfig.core.logdir, 'stdio.log') + # botconfig.core.logs_stdio = os.path.os.path.join(botconfig.core.logdir, botconfig.basename + '.stdio.log') + botconfig.core.logs_exceptions = os.path.join(botconfig.core.logdir, 'exceptions.log') + # botconfig.core.logs_exceptions = os.path.os.path.join(botconfig.core.logdir, botconfig.basename + '.exceptions.log') + botconfig.core.logs_raw = os.path.join(botconfig.core.logdir, 'raw.log') + # botconfig.core.logs_raw = os.path.os.path.join(botconfig.core.logdir, botconfig.basename + '.raw.log') + + def botstderr(self, logmessage): + sys.stderr.write(logmessage) + def log(self, logtype, logentry, stdio=False): self.lock.acquire() @@ -36,7 +48,7 @@ class BotLogs(): self.dict["queue"].append(logmessage) if stdio: - sopel.tools.stderr(logmessage) + self.botstderr(logmessage) if logtype not in self.dict["list"].keys(): self.dict["list"][logtype] = [] diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index e49425a..72da720 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -12,6 +12,7 @@ from .Logs import logs from .Events import events from .Channels import SpiceBot_Channels_MainSection +from .Commands import SpiceBot_Commands_MainSection from .Update import SpiceBot_Update_MainSection from .osd import SopelWrapperOSD, ToolsOSD, SopelOSD, SpiceBot_OSD from .Kick import SopelWrapperKICK, SopelKICK, SpiceBot_Kick @@ -20,10 +21,88 @@ from .AI import SpiceBot_AI_MainSection def setup(bot): + # basic config settings + setup_config(bot) + + # Logs + setup_logs(bot) + + # Commands + setup_commands(bot) + + # OSD + setup_osd(bot) + + # kick + setup_kick(bot) + + # update + setup_update(bot) + + # channels + setup_channels(bot) + + # AI + setup_ai(bot) + + # startupmonologue + setup_startupmonologue(bot) + + +def setup_config(bot): + logs.log('SpiceBot_Config', "Setting Up Configuration") + bot.config.core.basename = os.path.basename(bot.config.filename).rsplit('.', 1)[0] + bot.config.core.prefix_list = str(bot.config.core.prefix).replace("\\", '').split("|") + + +def setup_logs(bot): logs.log('SpiceBot_Logs', "Starting Setup Procedure") events.startup_add([events.BOT_LOGS]) + bot.config.core.logs_stdio = os.path.join(bot.config.core.logdir, 'stdio.log') + # bot.config.core.logs_stdio = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.stdio.log') + bot.config.core.logs_exceptions = os.path.join(bot.config.core.logdir, 'exceptions.log') + # bot.config.core.logs_exceptions = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.exceptions.log') + bot.config.core.logs_raw = os.path.join(bot.config.core.logdir, 'raw.log') + # bot.config.core.logs_raw = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.raw.log') events.trigger(bot, events.BOT_LOGS, "SpiceBot_Logs") + +def setup_commands(bot): + logs.log('SpiceBot_Commands', "Setting Up Configuration") + events.startup_add([events.BOT_COMMANDS]) + bot.config.define_section("SpiceBot_Commands", SpiceBot_Commands_MainSection, validate=False) + bot.config.core.query_list = str(bot.config.SpiceBot_Commands.query_prefix).replace("\\", '').split("|") + bot.config.core.prefix_list.extend(bot.config.SpiceBot_Commands.query_prefix) + + +def setup_startupmonologue(bot): + logs.log('SpiceBot_StartupMonologue', "Initial Setup processing") + events.startup_add([ + events.BOT_STARTUPMONOLOGUE_CONNECTED, + events.BOT_STARTUPMONOLOGUE_CHANNELS, + events.BOT_STARTUPMONOLOGUE_COMMANDS + ]) + + +def setup_channels(bot): + logs.log('SpiceBot_Channels', "Setting Up Configuration") + events.startup_add([events.BOT_CHANNELS]) + bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) + + +def setup_update(bot): + logs.log('SpiceBot_Update', "Initial Setup processing") + bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) + botconfig.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) + + +def setup_ai(bot): + logs.log('SpiceBot_AI', "Setting Up Configuration") + bot.config.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) + bot.config.aibrain = os.path.join(bot.config.homedir, bot.config.basename + '.aibrain.brn') + + +def setup_osd(bot): # Inject OSD logs.log('SpiceBot_OSD', "Implanting OSD function into bot") bot.osd = SopelOSD.osd @@ -37,6 +116,8 @@ def setup(bot): bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) botconfig.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) + +def setup_kick(bot): # Inject KICK logs.log('SpiceBot_Kick', "Implanting Kick function into bot") bot.kick = SopelKICK.kick @@ -46,38 +127,3 @@ def setup(bot): logs.log('SpiceBot_Kick', "Checking for config settings") bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) botconfig.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) - - bot.config.core.prefix_list = str(bot.config.core.prefix).replace("\\", '').split("|") - bot.config.core.prefix_list.append("?") - - logs.log('SpiceBot_Config', "Setting Up Configuration") - bot.config.core.basename = os.path.basename(bot.config.filename).rsplit('.', 1)[0] - bot.config.core.logs_stdio = os.path.join(bot.config.core.logdir, 'stdio.log') - # bot.config.core.logs_stdio = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.stdio.log') - bot.config.core.logs_exceptions = os.path.join(bot.config.core.logdir, 'exceptions.log') - # bot.config.core.logs_exceptions = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.exceptions.log') - bot.config.core.logs_raw = os.path.join(bot.config.core.logdir, 'raw.log') - # bot.config.core.logs_raw = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.raw.log') - - bot.config.aibrain = os.path.join(bot.config.homedir, bot.config.basename + '.aibrain.brn') - - logs.log('SpiceBot_Channels', "Setting Up Configuration") - events.startup_add([events.BOT_CHANNELS]) - bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False) - - logs.log('SpiceBot_Commands', "Setting Up Configuration") - events.startup_add([events.BOT_COMMANDS]) - - logs.log('SpiceBot_Update', "Initial Setup processing") - bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) - botconfig.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) - - logs.log('SpiceBot_StartupMonologue', "Initial Setup processing") - events.startup_add([ - events.BOT_STARTUPMONOLOGUE_CONNECTED, - events.BOT_STARTUPMONOLOGUE_CHANNELS, - events.BOT_STARTUPMONOLOGUE_COMMANDS - ]) - - logs.log('SpiceBot_AI', "Setting Up Configuration") - bot.config.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) From 8c0a095f00f1ea5181eb0deb13f827b295b51c99 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 10:28:18 -0400 Subject: [PATCH 307/328] fix --- sopel_modules/SpiceBot/AI.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 3485414..e3fb333 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -40,9 +40,6 @@ class SpiceBot_AI(): # Don't warn for no matches self.aiml_kernel._verboseMode = False - # Config - self.botai_config() - # Learn responses self.load_saved_brain() self.load_brain() From 1cb3b27c59b0e2097be2d0b5e74b9f79deb1ba58 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 10:38:35 -0400 Subject: [PATCH 308/328] fix ai --- sopel_modules/SpiceBot/AI.py | 2 +- sopel_modules/SpiceBot/Config.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index e3fb333..44a994e 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -49,7 +49,7 @@ class SpiceBot_AI(): def setup_ai(self): botconfig.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) - botconfig.aibrain = os.path.join(botconfig.homedir, botconfig.basename + '.aibrain.brn') + botconfig.config.aibrain = os.path.join(botconfig.homedir, botconfig.basename + '.aibrain.brn') def load_saved_brain(self): if os.path.isfile(botconfig.config.aibrain): diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 983ea1f..b7f9bb5 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -12,9 +12,7 @@ import configparser class BotConfig(): def __init__(self): - self.dict = {} - # Load config parser = build_parser() if not len(sys.argv[1:]): From 863c8d6624ebed98a64d71371f19fa647ed1136d Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 10:44:39 -0400 Subject: [PATCH 309/328] test --- sopel_modules/SpiceBot/AI.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 44a994e..c515ef0 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -74,7 +74,8 @@ class SpiceBot_AI(): def load_bot_values(self): self.aiml_kernel.setBotPredicate("nick", botconfig.nick) - self.aiml_kernel.setBotPredicate("gender", botconfig.SpiceBot_AI.gender) + # self.aiml_kernel.setBotPredicate("gender", botconfig.SpiceBot_AI.gender) + self.aiml_kernel.setBotPredicate("gender", "male") def learn(self, braindirs): for braindir in braindirs: From a807c3f25cb0df724fde788907d73bfe13b72e66 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 10:55:27 -0400 Subject: [PATCH 310/328] basename patch --- sopel_modules/SpiceBot/AI.py | 2 +- sopel_modules/SpiceBot/setup.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index c515ef0..00ece34 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -49,7 +49,7 @@ class SpiceBot_AI(): def setup_ai(self): botconfig.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) - botconfig.config.aibrain = os.path.join(botconfig.homedir, botconfig.basename + '.aibrain.brn') + botconfig.config.aibrain = os.path.join(botconfig.homedir, botconfig.config.core.basename + '.aibrain.brn') def load_saved_brain(self): if os.path.isfile(botconfig.config.aibrain): diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index 72da720..b27655d 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -59,11 +59,11 @@ def setup_logs(bot): logs.log('SpiceBot_Logs', "Starting Setup Procedure") events.startup_add([events.BOT_LOGS]) bot.config.core.logs_stdio = os.path.join(bot.config.core.logdir, 'stdio.log') - # bot.config.core.logs_stdio = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.stdio.log') + # bot.config.core.logs_stdio = os.path.os.path.join(bot.config.core.logdir, bot.config.core.basename + '.stdio.log') bot.config.core.logs_exceptions = os.path.join(bot.config.core.logdir, 'exceptions.log') - # bot.config.core.logs_exceptions = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.exceptions.log') + # bot.config.core.logs_exceptions = os.path.os.path.join(bot.config.core.logdir, bot.config.core.basename + '.exceptions.log') bot.config.core.logs_raw = os.path.join(bot.config.core.logdir, 'raw.log') - # bot.config.core.logs_raw = os.path.os.path.join(bot.config.core.logdir, bot.config.basename + '.raw.log') + # bot.config.core.logs_raw = os.path.os.path.join(bot.config.core.logdir, bot.config.core.basename + '.raw.log') events.trigger(bot, events.BOT_LOGS, "SpiceBot_Logs") @@ -99,7 +99,7 @@ def setup_update(bot): def setup_ai(bot): logs.log('SpiceBot_AI', "Setting Up Configuration") bot.config.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) - bot.config.aibrain = os.path.join(bot.config.homedir, bot.config.basename + '.aibrain.brn') + bot.config.aibrain = os.path.join(bot.config.homedir, bot.config.core.basename + '.aibrain.brn') def setup_osd(bot): From ecf1001a0b1b3c145ad29b7796ff5870899c85c0 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 10:56:37 -0400 Subject: [PATCH 311/328] reorder --- sopel_modules/SpiceBot/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index 15bbcb9..18b52f7 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -6,19 +6,20 @@ These are the core SpiceBot Classes This module contains references only for other modules to utilize. """ +from .Config import * +from .Logs import * +from .Database import * + from .Update import * from .osd import * from .Kick import * -from .Config import * from .Tools import * from .Prerun import * -from .Logs import * from .Commands import * from .Events import * from .StartupMonologue import * from .Channels import * -from .Database import * from .AI import * From 468d981593189261ec817ff63d3d4c48d58b0a22 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 11:08:10 -0400 Subject: [PATCH 312/328] dot missing --- sopel_modules/SpiceBot/Channels.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index 79eeda4..ddf89ce 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -88,7 +88,7 @@ class BotChannels(): # Chan ADMIN +a for channel in bot.channels.keys(): if channel.startswith("#"): - if channel not in bot.configSpiceBot_Channels.chanignore: + if channel not in botconfig.SpiceBot_Channels.chanignore: if botconfig.SpiceBot_Channels.operadmin: if not bot.channels[channel].privileges[bot.nick] < sopel.module.ADMIN: bot.write(('SAMODE', channel, "+a", bot.nick)) From 163b074286a36aed634f95e524463844dc90bcba Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 11:32:16 -0400 Subject: [PATCH 313/328] test --- sopel_modules/SpiceBot/AI.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 00ece34..0249072 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -76,6 +76,14 @@ class SpiceBot_AI(): self.aiml_kernel.setBotPredicate("nick", botconfig.nick) # self.aiml_kernel.setBotPredicate("gender", botconfig.SpiceBot_AI.gender) self.aiml_kernel.setBotPredicate("gender", "male") + currentgender = self.aiml_kernel.getBotPredicate("gender") + if currentgender == "male": + pronoun = "he" + elif currentgender == "female": + pronoun = "she" + else: + pronoun = "it" + self.aiml_kernel.setBotPredicate("pronoun", pronoun) def learn(self, braindirs): for braindir in braindirs: @@ -154,6 +162,8 @@ class SpiceBot_AI(): def save_brain(self): self.aiml_kernel.saveBrain(botconfig.config.aibrain) + botsessiondata = self.aiml_kernel._botPredicates + botdb.set_bot_value('botai', botsessiondata) botai = SpiceBot_AI() From 198017d604cc710849d2bc88bad46cd817e276ed Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 11:34:56 -0400 Subject: [PATCH 314/328] test --- sopel_modules/SpiceBot/AI.py | 8 +++----- sopel_modules/SpiceBot_Configs/aiml/nickname_gender.aiml | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 0249072..7f6020d 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -74,12 +74,10 @@ class SpiceBot_AI(): def load_bot_values(self): self.aiml_kernel.setBotPredicate("nick", botconfig.nick) - # self.aiml_kernel.setBotPredicate("gender", botconfig.SpiceBot_AI.gender) - self.aiml_kernel.setBotPredicate("gender", "male") - currentgender = self.aiml_kernel.getBotPredicate("gender") - if currentgender == "male": + self.aiml_kernel.setBotPredicate("gender", botconfig.SpiceBot_AI.gender.lower()) + if botconfig.SpiceBot_AI.gender.lower() == "male": pronoun = "he" - elif currentgender == "female": + elif botconfig.SpiceBot_AI.gender.lower() == "female": pronoun = "she" else: pronoun = "it" diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_gender.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_gender.aiml index 9c4070e..b99f0e4 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/nickname_gender.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_gender.aiml @@ -3,7 +3,7 @@ BOTNICK GENDER - + From 1fde43d79ccd030174cf7695dbd7625a687c9fb7 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 11:58:24 -0400 Subject: [PATCH 315/328] pronouns --- sopel_modules/SpiceBot/AI.py | 69 ++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 6 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 7f6020d..f935772 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -73,15 +73,16 @@ class SpiceBot_AI(): self.save_brain() def load_bot_values(self): + + # sopel nick self.aiml_kernel.setBotPredicate("nick", botconfig.nick) + + # gender self.aiml_kernel.setBotPredicate("gender", botconfig.SpiceBot_AI.gender.lower()) - if botconfig.SpiceBot_AI.gender.lower() == "male": - pronoun = "he" - elif botconfig.SpiceBot_AI.gender.lower() == "female": - pronoun = "she" + if botconfig.SpiceBot_AI.gender.lower() not in ["male", "female"]: + self.aiml_kernel.setBotPredicate("gendertype", "item") else: - pronoun = "it" - self.aiml_kernel.setBotPredicate("pronoun", pronoun) + self.aiml_kernel.setBotPredicate("gendertype", botconfig.SpiceBot_AI.gender.lower()) def learn(self, braindirs): for braindir in braindirs: @@ -119,23 +120,79 @@ class SpiceBot_AI(): return aiml_response def bot_message_precipher(self, bot, trigger, message): + + # uppercase input message = message.upper() + + # punctuation puct_dict = {"!": "exclamationmark", ".": "period", "?": "questionmark", ",": "comma"} for puctuation in puct_dict.keys(): message = message.replace(puctuation, puct_dict[puctuation]) + + # bot items for botitem in ["nick"]: message = message.replace(str(eval("bot." + botitem)).upper(), str("bot" + botitem).upper()) + for triggeritem in ["nick", "sender"]: message = message.replace(str(eval("trigger." + triggeritem)).upper(), str("trigger" + triggeritem).upper()) + return message def bot_message_decipher(self, bot, trigger, aiml_response): + + # bot items for botitem in ["nick"]: aiml_response = aiml_response.replace("bot" + botitem, str(eval("bot." + botitem))) + + # trigger items for triggeritem in ["nick", "sender"]: aiml_response = aiml_response.replace("trigger" + triggeritem, str(eval("trigger." + triggeritem))) + + # pronouns + botgendertype = self.aiml_kernel.getBotPredicate("gendertype") + pronounsdict = { + "male": { + "main": "he", + "possess": "his", + "self": "himself", + }, + "female": { + "main": "her", + "possess": "hers", + "self": "herself", + }, + "item": { + "main": "it", + "possess": "its", + "self": "itself", + }, + "point": { + "main": "you", + "possess": "yours", + "self": "yourself", + }, + "group": { + "main": "them", + "possess": "theirs", + "self": "themselves", + }, + } + for pronounitem in pronounsdict[botgendertype].keys(): + aiml_response = aiml_response.replace("BOTPRONOUN" + pronounitem, pronounsdict[botgendertype][pronounitem]) + triggergendertype = self.getPredicate("gender", trigger.nick) + if triggergendertype == "": + triggergendertype = "point" + for pronounitem in pronounsdict[triggergendertype].keys(): + aiml_response = aiml_response.replace("TRIGGERPRONOUN" + pronounitem, pronounsdict[triggergendertype][pronounitem]) + return aiml_response + def getPredicate(self, predicate, nick, nick_id=None): + if not nick_id: + nick = Identifier(nick) + nick_id = botdb.get_nick_id(nick, create=True) + self.aiml_kernel.getPredicate(predicate, nick_id) + def check_user_import(self, nick, nick_id=None): if not nick_id: nick = Identifier(nick) From 538466d122494483146dce2f3ce96578c7f1fd51 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 12:30:05 -0400 Subject: [PATCH 316/328] silver text for AI matches --- sopel_modules/SpiceBot/AI.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index f935772..2e9b49f 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -112,7 +112,8 @@ class SpiceBot_AI(): message = self.bot_message_precipher(bot, trigger, message) aiml_response = self.aiml_kernel.respond(message, nick_id) - aiml_response = self.bot_message_decipher(bot, trigger, aiml_response) + if aiml_response: + aiml_response = self.bot_message_decipher(bot, trigger, aiml_response) self.save_nick_session(nick, nick_id) self.save_brain() @@ -185,6 +186,8 @@ class SpiceBot_AI(): for pronounitem in pronounsdict[triggergendertype].keys(): aiml_response = aiml_response.replace("TRIGGERPRONOUN" + pronounitem, pronounsdict[triggergendertype][pronounitem]) + aiml_response = "\x0315" + aiml_response + "\x03" + return aiml_response def getPredicate(self, predicate, nick, nick_id=None): From 4fb4e7010515d9baf36466d6bc759a9aa966a9e9 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 12:33:25 -0400 Subject: [PATCH 317/328] test --- sopel_modules/SpiceBot/AI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 2e9b49f..85b06ea 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -181,7 +181,7 @@ class SpiceBot_AI(): for pronounitem in pronounsdict[botgendertype].keys(): aiml_response = aiml_response.replace("BOTPRONOUN" + pronounitem, pronounsdict[botgendertype][pronounitem]) triggergendertype = self.getPredicate("gender", trigger.nick) - if triggergendertype == "": + if not triggergendertype or triggergendertype == "": triggergendertype = "point" for pronounitem in pronounsdict[triggergendertype].keys(): aiml_response = aiml_response.replace("TRIGGERPRONOUN" + pronounitem, pronounsdict[triggergendertype][pronounitem]) From 37deaadc8fda3c419fd92aa6a658fc05c7754dbf Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 14:51:59 -0400 Subject: [PATCH 318/328] more AI reworking --- sopel_modules/SpiceBot_AI/AI_Hello.py | 19 ----- sopel_modules/SpiceBot_AI/AI_InsultHandler.py | 10 --- sopel_modules/SpiceBot_AI/AI_Lazy.py | 15 ---- sopel_modules/SpiceBot_AI/AI_Love.py | 40 ---------- sopel_modules/SpiceBot_AI/AI_Really.py | 18 ----- sopel_modules/SpiceBot_AI/AI_Thanks.py | 20 ----- sopel_modules/SpiceBot_AI/AI_Welcomeback.py | 13 ---- sopel_modules/SpiceBot_AI/__init__.py | 7 -- .../aiml/nickname_goodbye.aiml | 78 +++++++++++++++++++ .../SpiceBot_Configs/aiml/nickname_hello.aiml | 70 +++++++++++++++++ .../aiml/nickname_insulthandler.aiml | 34 ++++++++ .../SpiceBot_Configs/aiml/nickname_lazy.aiml | 38 +++++++++ .../SpiceBot_Configs/aiml/nickname_love.aiml | 44 +++++++++++ .../aiml/nickname_really.aiml | 25 ++++++ .../aiml/nickname_thanks.aiml | 34 ++++++++ .../aiml/nickname_welcomeback.aiml | 14 ++++ 16 files changed, 337 insertions(+), 142 deletions(-) delete mode 100644 sopel_modules/SpiceBot_AI/AI_Hello.py delete mode 100644 sopel_modules/SpiceBot_AI/AI_InsultHandler.py delete mode 100644 sopel_modules/SpiceBot_AI/AI_Lazy.py delete mode 100644 sopel_modules/SpiceBot_AI/AI_Love.py delete mode 100644 sopel_modules/SpiceBot_AI/AI_Really.py delete mode 100644 sopel_modules/SpiceBot_AI/AI_Thanks.py delete mode 100644 sopel_modules/SpiceBot_AI/AI_Welcomeback.py create mode 100644 sopel_modules/SpiceBot_Configs/aiml/nickname_hello.aiml create mode 100644 sopel_modules/SpiceBot_Configs/aiml/nickname_insulthandler.aiml create mode 100644 sopel_modules/SpiceBot_Configs/aiml/nickname_lazy.aiml create mode 100644 sopel_modules/SpiceBot_Configs/aiml/nickname_love.aiml create mode 100644 sopel_modules/SpiceBot_Configs/aiml/nickname_really.aiml create mode 100644 sopel_modules/SpiceBot_Configs/aiml/nickname_thanks.aiml create mode 100644 sopel_modules/SpiceBot_Configs/aiml/nickname_welcomeback.aiml diff --git a/sopel_modules/SpiceBot_AI/AI_Hello.py b/sopel_modules/SpiceBot_AI/AI_Hello.py deleted file mode 100644 index ee30964..0000000 --- a/sopel_modules/SpiceBot_AI/AI_Hello.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import spicemanip - - -@sopel.module.rule(r'(?i)(hi|hello|hey),? $nickname[ \t]*$') -def bot_command_hello(bot, trigger): - hello = spicemanip.main(['Hi', 'Hey', 'Hello'], "random") - punctuation = spicemanip.main(['', '!', '?'], "random") - bot.osd(hello + ' ' + trigger.nick + punctuation) - - -@sopel.module.nickname_commands('hello', 'hi', 'hey') -def bot_command_hello_b(bot, trigger): - bot_command_hello(bot, trigger) diff --git a/sopel_modules/SpiceBot_AI/AI_InsultHandler.py b/sopel_modules/SpiceBot_AI/AI_InsultHandler.py deleted file mode 100644 index 910dd7b..0000000 --- a/sopel_modules/SpiceBot_AI/AI_InsultHandler.py +++ /dev/null @@ -1,10 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - - -@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_AI/AI_Lazy.py b/sopel_modules/SpiceBot_AI/AI_Lazy.py deleted file mode 100644 index a3385a6..0000000 --- a/sopel_modules/SpiceBot_AI/AI_Lazy.py +++ /dev/null @@ -1,15 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - - -@sopel.module.rule(r'(?i)(Damnit|Lazy)? $nickname[ \t]*$') -def bot_command_damnlazy(bot, trigger): - bot.osd("I do not tell you how to do your job, " + trigger.nick + "!!!") - - -@sopel.module.rule('$nickname is lazy') -def bot_command_damnlazy_b(bot, trigger): - bot_command_damnlazy(bot, trigger) diff --git a/sopel_modules/SpiceBot_AI/AI_Love.py b/sopel_modules/SpiceBot_AI/AI_Love.py deleted file mode 100644 index c43361c..0000000 --- a/sopel_modules/SpiceBot_AI/AI_Love.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - - -@sopel.module.rule(r'(?i)(I love you|loveya),? $nickname[ \t]*$') -def bot_command_love(bot, trigger): - bot.osd(trigger.nick + ", I love you too.") - - -@sopel.module.rule('$nickname (loveya|I love you)') -def bot_command_love_b(bot, trigger): - bot_command_love(bot, trigger) - - -@sopel.module.nickname_commands('loveya') -def bot_command_love_c(bot, trigger): - bot_command_love(bot, trigger) - - -@sopel.module.rule('(I love) $nickname') -def bot_command_love_d(bot, trigger): - bot_command_like(bot, trigger) - - -@sopel.module.rule(r'(?i)(I like you),? $nickname[ \t]*$') -def bot_command_like(bot, trigger): - bot.osd(trigger.nick + ", I like you too.") - - -@sopel.module.rule('$nickname (I like you)') -def bot_command_like_b(bot, trigger): - bot_command_like(bot, trigger) - - -@sopel.module.rule('(I like) $nickname') -def bot_command_like_c(bot, trigger): - bot_command_like(bot, trigger) diff --git a/sopel_modules/SpiceBot_AI/AI_Really.py b/sopel_modules/SpiceBot_AI/AI_Really.py deleted file mode 100644 index 162b828..0000000 --- a/sopel_modules/SpiceBot_AI/AI_Really.py +++ /dev/null @@ -1,18 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import spicemanip - - -@sopel.module.rule(r'(?i)(really),? $nickname\?') -def bot_command_really(bot, trigger): - really = spicemanip.main(["Yes, really.", "Really really"], "random") - bot.osd(trigger.nick + ", " + really) - - -@sopel.module.rule('$nickname really\?') -def bot_command_really_b(bot, trigger): - bot_command_really(bot, trigger) diff --git a/sopel_modules/SpiceBot_AI/AI_Thanks.py b/sopel_modules/SpiceBot_AI/AI_Thanks.py deleted file mode 100644 index 8babea3..0000000 --- a/sopel_modules/SpiceBot_AI/AI_Thanks.py +++ /dev/null @@ -1,20 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - - -@sopel.module.rule(r'(?i)(thank you|thanks),? $nickname[ \t]*$') -def bot_command_thanks(bot, trigger): - bot.osd(trigger.nick + ",You're welcome.") - - -@sopel.module.rule('$nickname (thank you)') -def bot_command_thanks_b(bot, trigger): - bot_command_thanks(bot, trigger) - - -@sopel.module.nickname_commands('thanks') -def bot_command_thanks_c(bot, trigger): - bot_command_thanks(bot, trigger) diff --git a/sopel_modules/SpiceBot_AI/AI_Welcomeback.py b/sopel_modules/SpiceBot_AI/AI_Welcomeback.py deleted file mode 100644 index b81f42c..0000000 --- a/sopel_modules/SpiceBot_AI/AI_Welcomeback.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -import spicemanip - - -@sopel.module.rule(r'(?i)(welcome back),? $nickname\?') -def bot_command_really(bot, trigger): - reply = spicemanip.main(['Thank you', 'thanks'], "random") - bot.osd(trigger.nick + ", " + reply) diff --git a/sopel_modules/SpiceBot_AI/__init__.py b/sopel_modules/SpiceBot_AI/__init__.py index a5f1f17..683ec02 100644 --- a/sopel_modules/SpiceBot_AI/__init__.py +++ b/sopel_modules/SpiceBot_AI/__init__.py @@ -3,13 +3,6 @@ from __future__ import unicode_literals, absolute_import, division, print_functi from .AI import * from .AI_aiml import * -from .AI_Hello import * -from .AI_Thanks import * -from .AI_Lazy import * -from .AI_InsultHandler import * -from .AI_Love import * -from .AI_Really import * -from .AI_Welcomeback import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net' diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_goodbye.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_goodbye.aiml index 6234ef0..9835bb2 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/nickname_goodbye.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_goodbye.aiml @@ -27,6 +27,45 @@ + + BOTNICK seeya + + + + + BOTNICK cya + + + + + BOTNICK ttyl + + + BYE BOTNICK + + seeya BOTNICK + + + + + cya BOTNICK + + + + + ttyl BOTNICK + + + diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_hello.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_hello.aiml new file mode 100644 index 0000000..09876b9 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_hello.aiml @@ -0,0 +1,70 @@ + + + + + BOTNICK hi + + + + + BOTNICK hello + + + + + BOTNICK hey + + + + + hi BOTNICK + + + + + hello BOTNICK + + + + + hey BOTNICK + + + + diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_insulthandler.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_insulthandler.aiml new file mode 100644 index 0000000..25c37ac --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_insulthandler.aiml @@ -0,0 +1,34 @@ + + + + + BOTNICK fuck you + + + + + BOTNICK fuck off + + + + + BOTNICK screw you + + + + + fuck you BOTNICK + + + + + fuck off BOTNICK + + + + + screw you BOTNICK + + + + diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_lazy.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_lazy.aiml new file mode 100644 index 0000000..854221a --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_lazy.aiml @@ -0,0 +1,38 @@ + + + + + BOTNICK IS LAZY + + + + + + LAZY BOTNICK + + + + + DAMNIT BOTNICK + + + + diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_love.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_love.aiml new file mode 100644 index 0000000..cf8fde8 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_love.aiml @@ -0,0 +1,44 @@ + + + + + BOTNICK I love you + + + + + BOTNICK loveya + + + + + BOTNICK I love you + + + + + BOTNICK I like you + + + + + I love you BOTNICK + + + + + loveya BOTNICK + + + + + I love BOTNICK + + + + + I like BOTNICK + + + + diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_really.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_really.aiml new file mode 100644 index 0000000..0847dd6 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_really.aiml @@ -0,0 +1,25 @@ + + + + + BOTNICK really + + + + + really BOTNICK + + + + + diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_thanks.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_thanks.aiml new file mode 100644 index 0000000..dcdd7bc --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_thanks.aiml @@ -0,0 +1,34 @@ + + + + + thank you BOTNICK + + + + + BOTNICK thank you + + + + + thanks BOTNICK + + + + + BOTNICK thanks + + + + + thankya BOTNICK + + + + + BOTNICK thankya + + + + diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_welcomeback.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_welcomeback.aiml new file mode 100644 index 0000000..4c10348 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_welcomeback.aiml @@ -0,0 +1,14 @@ + + + + + BOTNICK welcome back + + + + + welcome back BOTNICK + + + + From 985f7b0adae86f0209eeeb32f3e270937136378d Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 15:19:36 -0400 Subject: [PATCH 319/328] more AI --- sopel_modules/SpiceBot_AI/AI.py | 39 +------------------ sopel_modules/SpiceBot_AI/AI_aiml.py | 16 +++++++- .../aiml/nickname_whatis.aiml | 9 +++++ .../aiml/nickname_whereis.aiml | 29 ++++++++++++++ 4 files changed, 54 insertions(+), 39 deletions(-) create mode 100644 sopel_modules/SpiceBot_Configs/aiml/nickname_whatis.aiml create mode 100644 sopel_modules/SpiceBot_Configs/aiml/nickname_whereis.aiml diff --git a/sopel_modules/SpiceBot_AI/AI.py b/sopel_modules/SpiceBot_AI/AI.py index 4ee3cd2..6381c9a 100644 --- a/sopel_modules/SpiceBot_AI/AI.py +++ b/sopel_modules/SpiceBot_AI/AI.py @@ -26,43 +26,6 @@ def bot_command_nick(bot, trigger): fulltrigger = spicemanip.main(trigger.sb['args'], 0).lower() - if fulltrigger.lower().startswith("what is"): - searchterm = spicemanip.main(trigger.sb['args'], "3+") or None - if searchterm: - searchreturn = SpiceBot.googlesearch(searchterm) - if not searchreturn: - bot.osd('I cannot find anything about that') - else: - bot.osd(str(searchreturn)) - else: - bot.osd("Do you think this is Jeopardy?") - return - - elif fulltrigger.lower().startswith("where is"): - searchterm = spicemanip.main(trigger.sb['args'], "3+") or None - if searchterm: - - if searchterm.lower() in ['waldo', 'wally']: - bot.osd("He is hiding for a reason?") - searchreturn = SpiceBot.googlesearch("wimmelbilderbuch") - if searchreturn: - bot.osd(str(searchreturn)) - return - - elif searchterm.lower() == 'carmen sandiego': - carmenlocale = ['ACME Headquarters', "Villains' International League of Evil"] - bot.osd("Currently she is located at " + spicemanip.main(carmenlocale, 'random')) - return - searchreturn = SpiceBot.googlesearch(searchterm, 'maps') - - if not searchreturn: - bot.osd('I cannot find anything about that') - else: - bot.osd(str(searchreturn)) - else: - bot.osd("Not sure what you want me to look for.") - return - # if fulltrigger.lower().startswith("what time is it"): # TODO @@ -73,7 +36,7 @@ def bot_command_nick(bot, trigger): # return # TODO - elif fulltrigger.lower().startswith(tuple(["make me a", "beam me a"])): + if fulltrigger.lower().startswith(tuple(["make me a", "beam me a"])): makemea = spicemanip.main(trigger.sb['args'], "4+") or None if makemea: bot.osd("beams " + trigger.nick + " a " + makemea, trigger.sender, 'action') diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index 3ac2b3b..006b19e 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -44,12 +44,12 @@ def bot_command_rule(bot, trigger): bot.osd(invalid_display, trigger.nick, 'notice') return + fulltrigger = spicemanip.main(trigger_args, 0) if str(message).lower().startswith(str(bot.nick).lower()): command_type = 'nickname' trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'nickname') if str(trigger_command).startswith("?"): return - fulltrigger = spicemanip.main(trigger_args, 0) if fulltrigger in SpiceBot.commands.dict['nickrules']: return if trigger_command in SpiceBot.commands.dict['commands']["nickname"].keys(): @@ -63,6 +63,20 @@ def bot_command_rule(bot, trigger): bot.osd(str(returnmessage)) else: if command_type == 'nickname': + + if fulltrigger.lower().startswith(tuple(["what is", "where is"])): + searchterm = spicemanip.main(trigger_args, "3+") or None + if searchterm: + if trigger_args[0].lower() == "where": + searchreturn = SpiceBot.googlesearch(searchterm, 'maps') + else: + searchreturn = SpiceBot.googlesearch(searchterm) + if not searchreturn: + bot.osd('I cannot find anything about that') + else: + bot.osd(str(searchreturn)) + return + closestmatches = SpiceBot.similar_list(trigger_command, SpiceBot.commands.dict['commands']["nickname"].keys(), 3, 'reverse') if len(closestmatches): closestmatches = spicemanip.main(closestmatches, "andlist") diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_whatis.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_whatis.aiml new file mode 100644 index 0000000..eca6503 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_whatis.aiml @@ -0,0 +1,9 @@ + + + + + BOTNICK what is + + + + diff --git a/sopel_modules/SpiceBot_Configs/aiml/nickname_whereis.aiml b/sopel_modules/SpiceBot_Configs/aiml/nickname_whereis.aiml new file mode 100644 index 0000000..6b41ce9 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/aiml/nickname_whereis.aiml @@ -0,0 +1,29 @@ + + + + + BOTNICK where is waldo + + + + + BOTNICK where is wally + + + + + BOTNICK where is carmen sandiego + + + + + BOTNICK where is + + + + From 5ea3e2f7b79f8e9f690c5a68fee95d9d3ebca3c8 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 15:23:40 -0400 Subject: [PATCH 320/328] fix --- sopel_modules/SpiceBot_AI/AI_aiml.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index 006b19e..0c9cfe0 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -44,10 +44,10 @@ def bot_command_rule(bot, trigger): bot.osd(invalid_display, trigger.nick, 'notice') return - fulltrigger = spicemanip.main(trigger_args, 0) if str(message).lower().startswith(str(bot.nick).lower()): command_type = 'nickname' trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'nickname') + fulltrigger = spicemanip.main(trigger_args, 0) if str(trigger_command).startswith("?"): return if fulltrigger in SpiceBot.commands.dict['nickrules']: @@ -57,6 +57,7 @@ def bot_command_rule(bot, trigger): else: command_type = 'module' trigger_args, trigger_command = SpiceBot.prerun.trigger_args(message, 'module') + fulltrigger = spicemanip.main(trigger_args, 0) returnmessage = SpiceBot.botai.on_message(bot, trigger, message) if returnmessage: From 8373eb63bd6545bbcf4e6cde721cfdddcc41bd1e Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 15:31:36 -0400 Subject: [PATCH 321/328] better? --- sopel_modules/SpiceBot_AI/AI_aiml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_AI/AI_aiml.py b/sopel_modules/SpiceBot_AI/AI_aiml.py index 0c9cfe0..cd48826 100644 --- a/sopel_modules/SpiceBot_AI/AI_aiml.py +++ b/sopel_modules/SpiceBot_AI/AI_aiml.py @@ -65,7 +65,7 @@ def bot_command_rule(bot, trigger): else: if command_type == 'nickname': - if fulltrigger.lower().startswith(tuple(["what is", "where is"])): + if trigger_args[0].lower() in ["what", "where"] and trigger_args[0].lower() in ["is", "are"]: searchterm = spicemanip.main(trigger_args, "3+") or None if searchterm: if trigger_args[0].lower() == "where": From 29b94bffa983a438feea08f83c7b8ebf0711fd6b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 15:33:18 -0400 Subject: [PATCH 322/328] make xml --- sopel_modules/SpiceBot_Configs/aiml/dog.aiml | 30 +++++++++++--------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/sopel_modules/SpiceBot_Configs/aiml/dog.aiml b/sopel_modules/SpiceBot_Configs/aiml/dog.aiml index 83b8e86..11a3065 100644 --- a/sopel_modules/SpiceBot_Configs/aiml/dog.aiml +++ b/sopel_modules/SpiceBot_Configs/aiml/dog.aiml @@ -1,14 +1,18 @@ - - - MY DOGS NAME IS * - - - - WHAT IS MY DOGS NAME - - + + + + + MY DOGS NAME IS * + + + + WHAT IS MY DOGS NAME + + + + From 2c11473946d60abd178c6edae8bc340fe7067e11 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 15:36:35 -0400 Subject: [PATCH 323/328] better botdb --- sopel_modules/SpiceBot/AI.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 85b06ea..debf743 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -74,6 +74,12 @@ class SpiceBot_AI(): def load_bot_values(self): + current_bot_db = botdb.get_bot_value('botai') or None + if current_bot_db: + for predicate in current_bot_db.keys(): + predval = current_bot_db[predicate] + self.aiml_kernel.setBotPredicate(predicate, predval) + # sopel nick self.aiml_kernel.setBotPredicate("nick", botconfig.nick) From 6920c7db1be42f8f1c848f0af361f109d47c2def Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 15:42:33 -0400 Subject: [PATCH 324/328] counts --- sopel_modules/SpiceBot/AI.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index debf743..2ac2cc2 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -26,8 +26,8 @@ class SpiceBot_AI(): self.setup_ai() self.braindirs = [] self.dict = { - "counts": 0, - "failcounts": 0, + "patterncount": 0, + "filecounts": 0, "sessioncache": {}, "files": {} } @@ -94,6 +94,16 @@ class SpiceBot_AI(): for braindir in braindirs: if braindir not in self.braindirs: self.braindirs.append(braindir) + + # Count matches + for pathname in os.listdir(braindir): + self.dict["filecounts"] += 1 + aimlfile = os.path.join(braindir, pathname) + data = open(aimlfile).read() + count = data.count('pattern') + count = count / 2 + self.dict["patterncount"] += count + tempbrain = tempfile.mkstemp()[1] with open(tempbrain, 'w') as fileo: fileo.write( From 00ef7f96079d2e23adecc0e8d434db2a6b79d2c0 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 15:51:03 -0400 Subject: [PATCH 325/328] test --- sopel_modules/SpiceBot/AI.py | 4 +-- sopel_modules/SpiceBot/setup.py | 4 ++- sopel_modules/SpiceBot_Core_Processing/AI | 25 ------------------- sopel_modules/SpiceBot_Core_Processing/AI.py | 17 +++++++++++++ .../StartupMonologue.py | 11 ++++++++ 5 files changed, 33 insertions(+), 28 deletions(-) delete mode 100644 sopel_modules/SpiceBot_Core_Processing/AI create mode 100644 sopel_modules/SpiceBot_Core_Processing/AI.py diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index 2ac2cc2..daee7c5 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -26,7 +26,7 @@ class SpiceBot_AI(): self.setup_ai() self.braindirs = [] self.dict = { - "patterncount": 0, + "patterncounts": 0, "filecounts": 0, "sessioncache": {}, "files": {} @@ -102,7 +102,7 @@ class SpiceBot_AI(): data = open(aimlfile).read() count = data.count('pattern') count = count / 2 - self.dict["patterncount"] += count + self.dict["patterncounts"] += count tempbrain = tempfile.mkstemp()[1] with open(tempbrain, 'w') as fileo: diff --git a/sopel_modules/SpiceBot/setup.py b/sopel_modules/SpiceBot/setup.py index b27655d..f830ee1 100644 --- a/sopel_modules/SpiceBot/setup.py +++ b/sopel_modules/SpiceBot/setup.py @@ -80,7 +80,8 @@ def setup_startupmonologue(bot): events.startup_add([ events.BOT_STARTUPMONOLOGUE_CONNECTED, events.BOT_STARTUPMONOLOGUE_CHANNELS, - events.BOT_STARTUPMONOLOGUE_COMMANDS + events.BOT_STARTUPMONOLOGUE_COMMANDS, + events.BOT_STARTUPMONOLOGUE_AI, ]) @@ -100,6 +101,7 @@ def setup_ai(bot): logs.log('SpiceBot_AI', "Setting Up Configuration") bot.config.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False) bot.config.aibrain = os.path.join(bot.config.homedir, bot.config.core.basename + '.aibrain.brn') + events.startup_add([events.BOT_AI]) def setup_osd(bot): diff --git a/sopel_modules/SpiceBot_Core_Processing/AI b/sopel_modules/SpiceBot_Core_Processing/AI deleted file mode 100644 index efa1843..0000000 --- a/sopel_modules/SpiceBot_Core_Processing/AI +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf8 -from __future__ import unicode_literals, absolute_import, division, print_function -""" -This is the SpiceBot AI system. -""" -import sopel - -import os - -import sopel_modules.SpiceBot as SpiceBot - - -@sopel.module.event(SpiceBot.events.BOT_READY) -@sopel.module.rule('.*') -def bot_events_complete_ai(bot, trigger): - - for braindir in SpiceBot.botai.braindirs: - for parsefile in os.listdir(braindir): - SpiceBot.botai.check_file_parse(parsefile) - - if SpiceBot.botai.dict["counts"]: - SpiceBot.logs.log('SpiceBot_AI', 'Registered %d %s files,' % (SpiceBot.botai.dict["counts"], 'aiml')) - SpiceBot.logs.log('SpiceBot_AI', '%d %s files failed to load' % (SpiceBot.botai.dict["failcounts"], 'aiml'), True) - else: - SpiceBot.logs.log('SpiceBot_AI', "Warning: Couldn't load any %s files" % ('aiml')) diff --git a/sopel_modules/SpiceBot_Core_Processing/AI.py b/sopel_modules/SpiceBot_Core_Processing/AI.py new file mode 100644 index 0000000..3f65a2f --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Processing/AI.py @@ -0,0 +1,17 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot AI system. +""" +import sopel + +import sopel_modules.SpiceBot as SpiceBot + + +@sopel.module.event(SpiceBot.events.BOT_READY) +@sopel.module.rule('.*') +def bot_events_complete_ai(bot, trigger): + + SpiceBot.logs.log('SpiceBot_Commands', "Found " + str(SpiceBot.botai.dict['patterncounts']) + " AI pattern Matches.", True) + + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_AI, "SpiceBot_AI") diff --git a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py index 9f2945d..7c5215c 100644 --- a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py +++ b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py @@ -43,6 +43,17 @@ def bot_startup_monologue_commands(bot, trigger): SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDS, "SpiceBot_StartupMonologue") +@sopel.module.event(SpiceBot.events.BOT_AI) +@sopel.module.rule('.*') +def bot_startup_monologue_ai(bot, trigger): + availablecomsnum = SpiceBot.botai.dict['patterncounts'] + availablecomsfiles = SpiceBot.botai.dict['filecounts'] + displayval = "There are " + str(availablecomsnum) + " AI matches available in " + str(availablecomsfiles) + " files." + SpiceBot.startupmonologue.dict["ai"] = displayval + SpiceBot.logs.log('SpiceBot_StartupMonologue', displayval) + SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_AI, "SpiceBot_StartupMonologue") + + @sopel.module.event(SpiceBot.events.BOT_LOADED) @sopel.module.rule('.*') def bot_startup_monologue_display(bot, trigger): From 897d0c964f444054bc3883fbc0137b42e8f73d93 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 15:54:48 -0400 Subject: [PATCH 326/328] uncomment --- sopel_modules/SpiceBot_Core_Processing/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_Core_Processing/__init__.py b/sopel_modules/SpiceBot_Core_Processing/__init__.py index 2819990..df953ff 100644 --- a/sopel_modules/SpiceBot_Core_Processing/__init__.py +++ b/sopel_modules/SpiceBot_Core_Processing/__init__.py @@ -9,7 +9,7 @@ This module contains references only for other modules to utilize. from .Channels import * from .Events import * from .Modules import * -# from .AI import * +from .AI import * from .osd import * from .StartupMonologue import * from .Logs import * From e36d65898be4e6ded980748a19c167084f79d18b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 16:03:45 -0400 Subject: [PATCH 327/328] int --- sopel_modules/SpiceBot/AI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py index daee7c5..850669e 100644 --- a/sopel_modules/SpiceBot/AI.py +++ b/sopel_modules/SpiceBot/AI.py @@ -102,7 +102,7 @@ class SpiceBot_AI(): data = open(aimlfile).read() count = data.count('pattern') count = count / 2 - self.dict["patterncounts"] += count + self.dict["patterncounts"] += int(count) tempbrain = tempfile.mkstemp()[1] with open(tempbrain, 'w') as fileo: From 01c8f94d20809317416599228c1372ccab316055 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 5 Jun 2019 16:04:31 -0400 Subject: [PATCH 328/328] pattern --- sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py index 7c5215c..10aedb8 100644 --- a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py +++ b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py @@ -48,7 +48,7 @@ def bot_startup_monologue_commands(bot, trigger): def bot_startup_monologue_ai(bot, trigger): availablecomsnum = SpiceBot.botai.dict['patterncounts'] availablecomsfiles = SpiceBot.botai.dict['filecounts'] - displayval = "There are " + str(availablecomsnum) + " AI matches available in " + str(availablecomsfiles) + " files." + displayval = "There are " + str(availablecomsnum) + " AI pattern matches available in " + str(availablecomsfiles) + " files." SpiceBot.startupmonologue.dict["ai"] = displayval SpiceBot.logs.log('SpiceBot_StartupMonologue', displayval) SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_AI, "SpiceBot_StartupMonologue")