From ee1559f0f1a27710e1d5fe178f63139f8dffbc67 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 08:33:10 -0400 Subject: [PATCH 01/45] fixes --- sopel_modules/SpiceBot/Tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index e6fa9b7..155ce29 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -302,7 +302,7 @@ def stock_modules_begone(): for pathname in os.listdir(modules_dir): path = os.path.join(modules_dir, pathname) if (os.path.isfile(path) and pathname.endswith('.py') and not pathname.startswith('_')): - if not pathname in ["__init__.py", "SpiceBot_dummycommand.py"]: + if pathname not in ["__init__.py", "SpiceBot_dummycommand.py"]: os.system("sudo mv " + path + " " + stockdir) @@ -320,7 +320,7 @@ def spicebot_update(deps=False): pipcommand = "sudo pip3 install --upgrade" if not deps: - pipcommand += " --no-deps" + pipcommand += " --no-deps" pipcommand += " --force-reinstall" # pipcommand += " git+" + str(botconfig.SpiceBot_Update.gitrepo) + "@" + str(botconfig.SpiceBot_Update.gitbranch) pipcommand += " /tmp/SpiceBot/" From 597fabc6d3ab78adf85d84d5a3345705d5e1338b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 08:38:15 -0400 Subject: [PATCH 02/45] no unidentified admins --- sopel_modules/SpiceBot/Tools.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index 155ce29..cc71c9a 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -18,6 +18,7 @@ from sopel_modules.spicemanip import spicemanip from .Logs import logs from .Config import config as botconfig +from .Users import users as botusers """Variable References""" @@ -58,6 +59,11 @@ def bot_privs(privtype): def command_permissions_check(bot, trigger, privslist): + nick_id = botusers.whois_ident(trigger.nick) + if bot.config.SpiceBot_regnick.regnick: + if int(nick_id) not in botusers.dict["identified"]: + return False + commandrunconsensus = [] for botpriv in ["admins", "owner"]: From 1164a7c478db121f7a185f8d8a13f5810b53e469 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 08:45:23 -0400 Subject: [PATCH 03/45] migrate user privs check --- sopel_modules/SpiceBot/Prerun.py | 12 +++---- sopel_modules/SpiceBot/Tools.py | 36 ------------------- sopel_modules/SpiceBot/Users.py | 36 ++++++++++++++++++- sopel_modules/SpiceBot_Core_Commands/Logs.py | 2 +- .../SpiceBot_Core_Commands/Messaging.py | 2 +- .../Runtime_Controls.py | 2 +- 6 files changed, 44 insertions(+), 46 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 8e95fce..feda81a 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -13,7 +13,7 @@ from word2number import w2n from sopel_modules.spicemanip import spicemanip -from .Tools import command_permissions_check, class_create +from .Tools import class_create from .Commands import commands as botcommands from .Database import db as botdb from .Channels import channels as botchannels @@ -282,7 +282,7 @@ def trigger_runstatus_query(bot, trigger, botcom): # Allow permissions for enabling and disabling commands via hyphenargs if botcom.dict["adminswitch"]: - if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + if botusers.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): return True else: botmessagelog.messagelog_error(botcom.dict["log_id"], "The admin switch (-a) is for use by authorized nicks ONLY.") @@ -348,7 +348,7 @@ def trigger_runstatus(bot, trigger, botcom): # Allow permissions for enabling and disabling commands via hyphenargs if botcom.dict["adminswitch"]: - if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + if botusers.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): return True else: botmessagelog.messagelog_error(botcom.dict["log_id"], "The admin switch (-a) is for use by authorized nicks ONLY.") @@ -430,7 +430,7 @@ def trigger_runstatus(bot, trigger, botcom): def trigger_cant_run(bot, trigger, botcom, message=None): if message: botmessagelog.messagelog_error(botcom.dict["log_id"], message) - if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + if botusers.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): botmessagelog.messagelog_error(botcom.dict["log_id"], "You however are authorized to bypass this warning with the (-a) admin switch.") return False @@ -532,7 +532,7 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): botmessagelog.messagelog_error(botcom.dict["log_id"], "I don't know who/what " + str(target) + " is.") return False - if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + if not botusers.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): if target != trigger.nick: if botcom.dict["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]: botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to enable this command for " + str(target) + " due to privilege issues.") @@ -583,7 +583,7 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): botmessagelog.messagelog_error(botcom.dict["log_id"], "I don't know who/what " + str(target) + " is.") return False - if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + if not botusers.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): if target != trigger.nick: if onoff in ['enable', 'unblock', "activate", "on"]: botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to enable multirun usage on " + str(botcom.dict["comtext"]) + " for " + str(target) + " due to privilege issues.") diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index cc71c9a..823356d 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -18,7 +18,6 @@ from sopel_modules.spicemanip import spicemanip from .Logs import logs from .Config import config as botconfig -from .Users import users as botusers """Variable References""" @@ -57,41 +56,6 @@ def bot_privs(privtype): return botpriveval -def command_permissions_check(bot, trigger, privslist): - - nick_id = botusers.whois_ident(trigger.nick) - if bot.config.SpiceBot_regnick.regnick: - if int(nick_id) not in botusers.dict["identified"]: - return False - - commandrunconsensus = [] - - for botpriv in ["admins", "owner"]: - if botpriv in privslist: - botpriveval = bot_privs(botpriv) - if not inlist(trigger.nick, botpriveval): - commandrunconsensus.append('False') - else: - commandrunconsensus.append('True') - - if not trigger.is_privmsg: - for chanpriv in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']: - if chanpriv in privslist: - chanpriveval = channel_privs(bot, trigger.sender, chanpriv) - if not inlist(trigger.nick, chanpriveval): - commandrunconsensus.append('False') - else: - commandrunconsensus.append('True') - - if not len(privslist): - commandrunconsensus.append('True') - - if 'True' not in commandrunconsensus: - return False - - return True - - """ Classes """ diff --git a/sopel_modules/SpiceBot/Users.py b/sopel_modules/SpiceBot/Users.py index 1763dd2..4ccf102 100644 --- a/sopel_modules/SpiceBot/Users.py +++ b/sopel_modules/SpiceBot/Users.py @@ -6,7 +6,7 @@ import sopel from sopel.tools import Identifier from .Database import db as botdb -from .Tools import is_number, inlist, similar, array_arrangesort +from .Tools import is_number, inlist, similar, array_arrangesort, bot_privs, channel_privs from sopel_modules.spicemanip import spicemanip @@ -524,5 +524,39 @@ class BotUsers(): elif outputtype == 'random': return spicemanip(validtargs, 'random') + def command_permissions_check(self, bot, trigger, privslist): + + nick_id = self.whois_ident(trigger.nick) + if bot.config.SpiceBot_regnick.regnick: + if int(nick_id) not in self.dict["identified"]: + return False + + commandrunconsensus = [] + + for botpriv in ["admins", "owner"]: + if botpriv in privslist: + botpriveval = bot_privs(botpriv) + if not inlist(trigger.nick, botpriveval): + commandrunconsensus.append('False') + else: + commandrunconsensus.append('True') + + if not trigger.is_privmsg: + for chanpriv in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']: + if chanpriv in privslist: + chanpriveval = channel_privs(bot, trigger.sender, chanpriv) + if not inlist(trigger.nick, chanpriveval): + commandrunconsensus.append('False') + else: + commandrunconsensus.append('True') + + if not len(privslist): + commandrunconsensus.append('True') + + if 'True' not in commandrunconsensus: + return False + + return True + users = BotUsers() diff --git a/sopel_modules/SpiceBot_Core_Commands/Logs.py b/sopel_modules/SpiceBot_Core_Commands/Logs.py index 2188961..f55241d 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Logs.py +++ b/sopel_modules/SpiceBot_Core_Commands/Logs.py @@ -16,7 +16,7 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.nickname_commands('logs', 'debug') def bot_command_logs(bot, trigger, botcom): - if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + if not SpiceBot.users.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "I was unable to process this Bot Nick command due to privilege issues.") return diff --git a/sopel_modules/SpiceBot_Core_Commands/Messaging.py b/sopel_modules/SpiceBot_Core_Commands/Messaging.py index 510a38d..29e59a6 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Messaging.py +++ b/sopel_modules/SpiceBot_Core_Commands/Messaging.py @@ -29,7 +29,7 @@ def bot_command_privmsg(bot, trigger, botcom): def bot_command_process(bot, trigger, botcom): - if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner']): + if not SpiceBot.users.command_permissions_check(bot, trigger, ['admins', 'owner']): SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "I was unable to process this Bot Nick command due to privilege issues.") return diff --git a/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py b/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py index ed7ac5b..3294642 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py +++ b/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py @@ -13,7 +13,7 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.nickname_commands('update') def nickname_comand_update(bot, trigger, botcom): - if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): + if not SpiceBot.users.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "I was unable to process this Bot Nick command due to privilege issues.") return From c8a162d778039a655b85fcf70e3ad4cf94ae0e4e Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 09:03:52 -0400 Subject: [PATCH 04/45] attempt view change --- sopel_modules/SpiceBot/Prerun.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index feda81a..23bf697 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -437,7 +437,7 @@ def trigger_cant_run(bot, trigger, botcom, message=None): def trigger_hyphen_args(trigger_args_part): valid_hyphen_args = [ - 'check', + 'check', 'view', 'enable', 'disable', 'block', 'unblock', "activate", "deactivate", @@ -512,6 +512,23 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is a valid command") return False + elif botcom.dict["hyphen_arg"] in ['view']: + if not len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]): + botmessagelog.messagelog(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command appears to have no entries!") + else: + bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command contains:", trigger.nick, 'notice') + listnumb, relist = 0, [] + for item in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]: + listnumb += 1 + if isinstance(item, dict): + relist.append(str("[#" + str(listnumb) + "] COMPLEX dict Entry")) + elif isinstance(item, list): + relist.append(str("[#" + str(listnumb) + "] COMPLEX list Entry")) + else: + relist.append(str("[#" + str(listnumb) + "] " + str(item))) + bot.osd(relist, trigger.nick, 'notice') + return False + elif botcom.dict["hyphen_arg"] in [ 'enable', 'disable', 'block', 'unblock', From 76d4c99ec1990232efb5cd70fe5739fb882c1ae6 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 09:14:43 -0400 Subject: [PATCH 05/45] module patch --- sopel_modules/SpiceBot/Read.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sopel_modules/SpiceBot/Read.py b/sopel_modules/SpiceBot/Read.py index 79c3ff6..2834525 100644 --- a/sopel_modules/SpiceBot/Read.py +++ b/sopel_modules/SpiceBot/Read.py @@ -223,6 +223,13 @@ class BotRead(): if "hardcoded_channel_block" not in list(dict_from_file.keys()): dict_from_file["hardcoded_channel_block"] = [] + # ensure creation of '?default' + if "?default" not in list(dict_from_file.keys()): + dict_from_file["?default"] = {} + + if "responses" not in list(dict_from_file["?default"].keys()): + dict_from_file["?default"]["responses"] = [] + return dict_from_file From 03fb709da22fd304e94813c7c407ac09efdc7a75 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 09:23:01 -0400 Subject: [PATCH 06/45] test count --- sopel_modules/SpiceBot/Prerun.py | 5 +++++ .../SpiceBot_Core_Commands/DictComs.py | 18 +----------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 23bf697..913011b 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -438,6 +438,7 @@ def trigger_cant_run(bot, trigger, botcom, message=None): def trigger_hyphen_args(trigger_args_part): valid_hyphen_args = [ 'check', 'view', + 'count', 'enable', 'disable', 'block', 'unblock', "activate", "deactivate", @@ -529,6 +530,10 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): bot.osd(relist, trigger.nick, 'notice') return False + elif botcom.dict["hyphen_arg"] in ['count']: + bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command has " + str(len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])) + " entries.") + return False + elif botcom.dict["hyphen_arg"] in [ 'enable', 'disable', 'block', 'unblock', diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index da9cd69..dff2948 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -49,7 +49,7 @@ def bot_dictcom_process(bot, trigger, botcom): botcom.dict["nonstockoptions"].append(command) # This allows users to specify which reply by number by using an ! and a digit (first or last in string) - validspecifides = ['last', 'random', 'count', 'view', 'add', 'del', 'remove', 'special'] + validspecifides = ['last', 'random', 'count', 'add', 'del', 'remove', 'special'] botcom.dict["specified"] = None argone = spicemanip(botcom.dict['args'], 1) if str(argone).startswith("--") and len(str(argone)) > 2: @@ -85,22 +85,6 @@ def bot_dictcom_process(bot, trigger, botcom): elif botcom.dict["specified"] == 'count': return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command has " + str(len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])) + " entries.") - elif botcom.dict["specified"] == 'view': - if botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] == []: - return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command appears to have no entries!") - else: - bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command contains:", trigger.nick, 'notice') - listnumb, relist = 1, [] - for item in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]: - if isinstance(item, dict): - relist.append(str("[#" + str(listnumb) + "] COMPLEX dict Entry")) - elif isinstance(item, list): - relist.append(str("[#" + str(listnumb) + "] COMPLEX list Entry")) - else: - relist.append(str("[#" + str(listnumb) + "] " + str(item))) - bot.osd(relist, trigger.nick) - return - elif botcom.dict["specified"] == 'add': if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: From dcdf2c43a1810f1735eba06b3558a1532d782e8c Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 09:29:59 -0400 Subject: [PATCH 07/45] shared prerun class --- sopel_modules/SpiceBot/Prerun.py | 52 +++++++++++-------- .../SpiceBot_Core_Commands/DictComs.py | 3 -- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 913011b..288ae78 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -23,7 +23,32 @@ from .Users import users as botusers from .Events import events as botevents -# TODO check identify for OPs and bot admins +class Botprerun_shared(): + def __init__(self): + + self.valid_hyphen_args = [ + 'check', 'view', + 'count', + 'enable', 'disable', + 'block', 'unblock', + "activate", "deactivate", + "on", "off", + 'multirun', 'multiruns', + 'example', 'usage', + 'filename', 'filepath', + 'foldername', 'folderpath', + "author", + 'contribs', 'contrib', "contributors", + 'alias', 'aliases', + 'random' + ] + + self.numdict = { + "last": -1 + } + + +prerun_shared = Botprerun_shared() def prerun(t_command_type='module', t_command_subtype=None): @@ -436,25 +461,6 @@ def trigger_cant_run(bot, trigger, botcom, message=None): def trigger_hyphen_args(trigger_args_part): - valid_hyphen_args = [ - 'check', 'view', - 'count', - 'enable', 'disable', - 'block', 'unblock', - "activate", "deactivate", - "on", "off", - 'multirun', 'multiruns', - 'example', 'usage', - 'filename', 'filepath', - 'foldername', 'folderpath', - "author", - 'contribs', 'contrib', "contributors", - 'alias', 'aliases', - 'random' - ] - numdict = { - "last": -1 - } hyphen_args = [] trigger_args_unhyphend = [] @@ -463,14 +469,14 @@ def trigger_hyphen_args(trigger_args_part): clipped_word = str(worditem[2:]).lower() # valid arg above - if clipped_word in valid_hyphen_args: + if clipped_word in prerun_shared.valid_hyphen_args: hyphen_args.append(clipped_word) # numbered args elif str(clipped_word).isdigit(): hyphen_args.append(int(clipped_word)) - elif clipped_word in list(numdict.keys()): - hyphen_args.append(int(numdict[clipped_word])) + elif clipped_word in list(prerun_shared.numdict.keys()): + hyphen_args.append(int(prerun_shared.numdict[clipped_word])) else: diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index dff2948..68f8253 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -82,9 +82,6 @@ def bot_dictcom_process(bot, trigger, botcom): nonstockoptions = spicemanip(botcom.dict["nonstockoptions"], "andlist") return bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + str(nonstockoptions) + ".") - elif botcom.dict["specified"] == 'count': - return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command has " + str(len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])) + " entries.") - elif botcom.dict["specified"] == 'add': if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: From b3b628a51db00ac3eef26efa2e8b1cf8f7139735 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 09:47:47 -0400 Subject: [PATCH 08/45] test --- sopel_modules/SpiceBot/DictComs.py | 6 ++++++ sopel_modules/SpiceBot/Prerun.py | 12 +++++++++++- sopel_modules/SpiceBot/Read.py | 6 ++++++ .../SpiceBot_Core_Commands/DictComs.py | 17 ++--------------- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/sopel_modules/SpiceBot/DictComs.py b/sopel_modules/SpiceBot/DictComs.py index 266456c..b29b70a 100644 --- a/sopel_modules/SpiceBot/DictComs.py +++ b/sopel_modules/SpiceBot/DictComs.py @@ -12,6 +12,7 @@ from .Config import config as botconfig from .Read import read as botread from .Commands import commands as botcommands from .Database import db as botdb +from .Prerun import prerun_shared import os import copy @@ -104,6 +105,11 @@ class BotDictCommands(): if otherkeys != []: dict_from_file = self.dictcom_load_usecases(maincom, dict_from_file, otherkeys) + dict_from_file["nonstockoptions"] = [] + for command in list(dict_from_file["dict"].keys()): + if command not in prerun_shared.stockoptions: + dict_from_file["nonstockoptions"].append(command) + botcommands.register(dict_from_file) def dictcom_load_usecases(self, maincom, dict_from_file, process_list): diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 288ae78..302ba3a 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -28,7 +28,7 @@ class Botprerun_shared(): self.valid_hyphen_args = [ 'check', 'view', - 'count', + 'count', 'special', 'enable', 'disable', 'block', 'unblock', "activate", "deactivate", @@ -47,6 +47,12 @@ class Botprerun_shared(): "last": -1 } + self.stockoptions = [ + "?default", "validcoms", "contributors", "author", "type", + "filepath", "filename", "hardcoded_channel_block", "description", + "exampleresponse", "example", "usage", "privs" + ] + prerun_shared = Botprerun_shared() @@ -540,6 +546,10 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command has " + str(len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])) + " entries.") return False + elif botcom.dict["hyphen_arg"] in ['special']: + bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + str(botcom.dict["nonstockoptions"]) + ".") + return False + elif botcom.dict["hyphen_arg"] in [ 'enable', 'disable', 'block', 'unblock', diff --git a/sopel_modules/SpiceBot/Read.py b/sopel_modules/SpiceBot/Read.py index 2834525..051724a 100644 --- a/sopel_modules/SpiceBot/Read.py +++ b/sopel_modules/SpiceBot/Read.py @@ -12,6 +12,7 @@ from fake_useragent import UserAgent from .Logs import logs from .Config import config as botconfig +from .Prerun import prerun_shared class BotRead(): @@ -230,6 +231,11 @@ class BotRead(): if "responses" not in list(dict_from_file["?default"].keys()): dict_from_file["?default"]["responses"] = [] + dict_from_file["nonstockoptions"] = [] + for command in list(dict_from_file["dict"].keys()): + if command not in prerun_shared.stockoptions: + dict_from_file["nonstockoptions"].append(command) + return dict_from_file diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index 68f8253..32eff3a 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -43,13 +43,8 @@ def bot_dictcom_process(bot, trigger, botcom): botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') botcom.dict["dict"][botcom.dict["responsekey"]]["type"] = botcom.dict["dict"][botcom.dict["responsekey"]]["type"] - botcom.dict["nonstockoptions"] = [] - for command in list(botcom.dict["dict"].keys()): - if command not in ["?default", "validcoms", "type", "hardcoded_channel_block"]: - botcom.dict["nonstockoptions"].append(command) - # This allows users to specify which reply by number by using an ! and a digit (first or last in string) - validspecifides = ['last', 'random', 'count', 'add', 'del', 'remove', 'special'] + validspecifides = ['last', 'random', 'count', 'add', 'del', 'remove'] botcom.dict["specified"] = None argone = spicemanip(botcom.dict['args'], 1) if str(argone).startswith("--") and len(str(argone)) > 2: @@ -78,10 +73,6 @@ def bot_dictcom_process(bot, trigger, botcom): SpiceBot.dictcoms.adjust_nick_array(str(trigger.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"], 'startup') botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = SpiceBot.db.get_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] - if botcom.dict["specified"] == 'special': - nonstockoptions = spicemanip(botcom.dict["nonstockoptions"], "andlist") - return bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + str(nonstockoptions) + ".") - elif botcom.dict["specified"] == 'add': if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: @@ -305,11 +296,7 @@ def bot_dictcom_reply_shared(bot, trigger, botcom): # display special options for this command if "$specialoptions" in rply: - nonstockoptions = [] - for command in list(botcom.dict["dict"].keys()): - if command not in ["?default", "validcoms", "contributors", "author", "type", "filepath", "filename", "hardcoded_channel_block", "description", "exampleresponse", "example", "usage", "privs"]: - nonstockoptions.append(command) - nonstockoptions = spicemanip(nonstockoptions, "andlist") + nonstockoptions = spicemanip(botcom.dict["nonstockoptions"], "andlist") rply = rply.replace("$specialoptions", nonstockoptions) # saying, or action? From ed5615e1a91e5fb99bec6ca62a6cd3a1726f66e3 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 09:52:42 -0400 Subject: [PATCH 09/45] from .Tools import prerun_shared --- sopel_modules/SpiceBot/DictComs.py | 2 +- sopel_modules/SpiceBot/Prerun.py | 35 +----------------------------- sopel_modules/SpiceBot/Read.py | 2 +- sopel_modules/SpiceBot/Tools.py | 34 +++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/sopel_modules/SpiceBot/DictComs.py b/sopel_modules/SpiceBot/DictComs.py index b29b70a..57bed01 100644 --- a/sopel_modules/SpiceBot/DictComs.py +++ b/sopel_modules/SpiceBot/DictComs.py @@ -12,7 +12,7 @@ from .Config import config as botconfig from .Read import read as botread from .Commands import commands as botcommands from .Database import db as botdb -from .Prerun import prerun_shared +from .Tools import prerun_shared import os import copy diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 302ba3a..1768e05 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -21,40 +21,7 @@ from .MessageLog import messagelog as botmessagelog from .Config import config as botconfig from .Users import users as botusers from .Events import events as botevents - - -class Botprerun_shared(): - def __init__(self): - - self.valid_hyphen_args = [ - 'check', 'view', - 'count', 'special', - 'enable', 'disable', - 'block', 'unblock', - "activate", "deactivate", - "on", "off", - 'multirun', 'multiruns', - 'example', 'usage', - 'filename', 'filepath', - 'foldername', 'folderpath', - "author", - 'contribs', 'contrib', "contributors", - 'alias', 'aliases', - 'random' - ] - - self.numdict = { - "last": -1 - } - - self.stockoptions = [ - "?default", "validcoms", "contributors", "author", "type", - "filepath", "filename", "hardcoded_channel_block", "description", - "exampleresponse", "example", "usage", "privs" - ] - - -prerun_shared = Botprerun_shared() +from .Tools import prerun_shared def prerun(t_command_type='module', t_command_subtype=None): diff --git a/sopel_modules/SpiceBot/Read.py b/sopel_modules/SpiceBot/Read.py index 051724a..9d37159 100644 --- a/sopel_modules/SpiceBot/Read.py +++ b/sopel_modules/SpiceBot/Read.py @@ -12,7 +12,7 @@ from fake_useragent import UserAgent from .Logs import logs from .Config import config as botconfig -from .Prerun import prerun_shared +from .Tools import prerun_shared class BotRead(): diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index 823356d..b47321a 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -20,6 +20,40 @@ from .Logs import logs from .Config import config as botconfig +class Botprerun_shared(): + def __init__(self): + + self.valid_hyphen_args = [ + 'check', 'view', + 'count', 'special', + 'enable', 'disable', + 'block', 'unblock', + "activate", "deactivate", + "on", "off", + 'multirun', 'multiruns', + 'example', 'usage', + 'filename', 'filepath', + 'foldername', 'folderpath', + "author", + 'contribs', 'contrib', "contributors", + 'alias', 'aliases', + 'random' + ] + + self.numdict = { + "last": -1 + } + + self.stockoptions = [ + "?default", "validcoms", "contributors", "author", "type", + "filepath", "filename", "hardcoded_channel_block", "description", + "exampleresponse", "example", "usage", "privs" + ] + + +prerun_shared = Botprerun_shared() + + """Variable References""" github_dict = { From 217df3f35195aa3b0517cc3b7ad2d9b99da267b7 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 09:56:22 -0400 Subject: [PATCH 10/45] patch --- sopel_modules/SpiceBot/Read.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Read.py b/sopel_modules/SpiceBot/Read.py index 9d37159..b6b2a3d 100644 --- a/sopel_modules/SpiceBot/Read.py +++ b/sopel_modules/SpiceBot/Read.py @@ -232,7 +232,7 @@ class BotRead(): dict_from_file["?default"]["responses"] = [] dict_from_file["nonstockoptions"] = [] - for command in list(dict_from_file["dict"].keys()): + for command in list(dict_from_file.keys()): if command not in prerun_shared.stockoptions: dict_from_file["nonstockoptions"].append(command) From 8aa369ef43e0544948c971d19440f8bc04be18cf Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 09:57:57 -0400 Subject: [PATCH 11/45] patch --- sopel_modules/SpiceBot/DictComs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/DictComs.py b/sopel_modules/SpiceBot/DictComs.py index 57bed01..1439c31 100644 --- a/sopel_modules/SpiceBot/DictComs.py +++ b/sopel_modules/SpiceBot/DictComs.py @@ -106,7 +106,7 @@ class BotDictCommands(): dict_from_file = self.dictcom_load_usecases(maincom, dict_from_file, otherkeys) dict_from_file["nonstockoptions"] = [] - for command in list(dict_from_file["dict"].keys()): + for command in list(dict_from_file.keys()): if command not in prerun_shared.stockoptions: dict_from_file["nonstockoptions"].append(command) From a8fc8ba1706a615dad3230b20220c218feec504d Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 10:02:37 -0400 Subject: [PATCH 12/45] ["dict"] --- sopel_modules/SpiceBot/DictComs.py | 2 +- sopel_modules/SpiceBot/Prerun.py | 2 +- sopel_modules/SpiceBot/Tools.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/DictComs.py b/sopel_modules/SpiceBot/DictComs.py index 1439c31..3b41958 100644 --- a/sopel_modules/SpiceBot/DictComs.py +++ b/sopel_modules/SpiceBot/DictComs.py @@ -38,7 +38,7 @@ class BotDictCommands(): "comtype", "type", "validcoms", "author", "contributors", "description", "exampleresponse", "example", - "privs" + "privs", "nonstockoptions", ] self.dictcom_load() diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 1768e05..40d6c74 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -514,7 +514,7 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): return False elif botcom.dict["hyphen_arg"] in ['special']: - bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + str(botcom.dict["nonstockoptions"]) + ".") + bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + str(botcom.dict["dict"]["nonstockoptions"]) + ".") return False elif botcom.dict["hyphen_arg"] in [ diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index b47321a..fbca002 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -47,7 +47,7 @@ class Botprerun_shared(): self.stockoptions = [ "?default", "validcoms", "contributors", "author", "type", "filepath", "filename", "hardcoded_channel_block", "description", - "exampleresponse", "example", "usage", "privs" + "exampleresponse", "example", "usage", "privs", "nonstockoptions", ] From c71e1e379a334d1c30276c387174368751c28e03 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 10:04:47 -0400 Subject: [PATCH 13/45] nice list --- 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 40d6c74..ecf7b7d 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -514,7 +514,7 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): return False elif botcom.dict["hyphen_arg"] in ['special']: - bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + str(botcom.dict["dict"]["nonstockoptions"]) + ".") + bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + spicemanip(botcom.dict["dict"]["nonstockoptions"], "andlist") + ".") return False elif botcom.dict["hyphen_arg"] in [ From ad2eddcc97143dbd4d8eb25d30ecd51c2b41624e Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 10:05:51 -0400 Subject: [PATCH 14/45] cleanup --- sopel_modules/SpiceBot/Tools.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index fbca002..5dbcf60 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -48,6 +48,7 @@ class Botprerun_shared(): "?default", "validcoms", "contributors", "author", "type", "filepath", "filename", "hardcoded_channel_block", "description", "exampleresponse", "example", "usage", "privs", "nonstockoptions", + 'folderpath', 'foldername', 'comtype', ] From 84f6026c0b3ad59de57370adad4e655ae162a6dd Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 10:06:25 -0400 Subject: [PATCH 15/45] test --- sopel_modules/SpiceBot/Prerun.py | 2 +- sopel_modules/SpiceBot/Tools.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index ecf7b7d..943c8be 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -513,7 +513,7 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command has " + str(len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])) + " entries.") return False - elif botcom.dict["hyphen_arg"] in ['special']: + elif botcom.dict["hyphen_arg"] in ['special', 'options']: bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + spicemanip(botcom.dict["dict"]["nonstockoptions"], "andlist") + ".") return False diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index 5dbcf60..598d1d1 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -25,7 +25,7 @@ class Botprerun_shared(): self.valid_hyphen_args = [ 'check', 'view', - 'count', 'special', + 'count', 'special', 'options', 'enable', 'disable', 'block', 'unblock', "activate", "deactivate", From 454019d799df210318d81dabae781ed444c5211c Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 10:08:08 -0400 Subject: [PATCH 16/45] not len() --- 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 943c8be..3ecb116 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -514,7 +514,10 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): return False elif botcom.dict["hyphen_arg"] in ['special', 'options']: - bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + spicemanip(botcom.dict["dict"]["nonstockoptions"], "andlist") + ".") + if not len(botcom.dict["dict"]["nonstockoptions"]): + bot.osd("There appear to be no special options for " + str(botcom.dict["realcom"]) + ".") + else: + bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + spicemanip(botcom.dict["dict"]["nonstockoptions"], "andlist") + ".") return False elif botcom.dict["hyphen_arg"] in [ From a1f4608523dca3a4d82f681a4711013ae1d57d88 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 11:24:32 -0400 Subject: [PATCH 17/45] test --- sopel_modules/SpiceBot/Prerun.py | 16 +++++++++++++++- sopel_modules/SpiceBot/Read.py | 17 +++++++++++++++++ .../SpiceBot_Core_Commands/DictComs.py | 15 +++------------ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 3ecb116..49b2336 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -105,7 +105,7 @@ def prerun(t_command_type='module', t_command_subtype=None): botcom.dict["args"], botcom.dict["hyphen_arg"] = trigger_hyphen_args(botcom.dict["args"]) # special handling - botcom.dict["responsekey"] = "?default" + botcom = special_handling(botcom) args_pass = trigger_hyphen_arg_handler(bot, trigger, botcom) @@ -118,6 +118,20 @@ def prerun(t_command_type='module', t_command_subtype=None): return actual_decorator +def special_handling(botcom): + botcom.dict["responsekey"] = "?default" + + # handling for special cases + posscom = spicemanip(botcom.dict['args'], 1) + if posscom.lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]: + for command in botcom.dict["dict"]["nonstockoptions"]: + if command.lower() == posscom.lower(): + posscom = command + botcom.dict["responsekey"] = posscom + + return botcom + + def prerun_query(t_command_type='module', t_command_subtype=None): def actual_decorator(function): diff --git a/sopel_modules/SpiceBot/Read.py b/sopel_modules/SpiceBot/Read.py index b6b2a3d..8957167 100644 --- a/sopel_modules/SpiceBot/Read.py +++ b/sopel_modules/SpiceBot/Read.py @@ -228,6 +228,10 @@ class BotRead(): if "?default" not in list(dict_from_file.keys()): dict_from_file["?default"] = {} + # check that type is set, use cases will inherit this if not set + if "type" not in list(dict_from_file.keys()): + dict_from_file["type"] = 'module' + if "responses" not in list(dict_from_file["?default"].keys()): dict_from_file["?default"]["responses"] = [] @@ -236,6 +240,19 @@ class BotRead(): if command not in prerun_shared.stockoptions: dict_from_file["nonstockoptions"].append(command) + for specialcase in dict_from_file["nonstockoptions"]: + + # All of the above need to be in the dict if not + if specialcase not in list(dict_from_file.keys()): + dict_from_file[specialcase] = dict() + + # verify if already there, that the key is a dict + if not isinstance(dict_from_file[specialcase], dict): + dict_from_file[specialcase] = dict() + + if "type" not in list(dict_from_file[specialcase].keys()): + dict_from_file[specialcase]["type"] = "module" + return dict_from_file diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index 32eff3a..4e13283 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -31,17 +31,8 @@ def command_dictcom(bot, trigger, botcom): def bot_dictcom_process(bot, trigger, botcom): # use the default key, unless otherwise specified - botcom.dict["responsekey"] = "?default" - - # handling for special cases - posscom = spicemanip(botcom.dict['args'], 1) - if posscom.lower() in [command.lower() for command in list(botcom.dict["dict"].keys())]: - for command in botcom.dict["dict"].keys(): - if command.lower() == posscom.lower(): - posscom = command - botcom.dict["responsekey"] = posscom + if botcom.dict["responsekey"] != "?default": botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') - botcom.dict["dict"][botcom.dict["responsekey"]]["type"] = botcom.dict["dict"][botcom.dict["responsekey"]]["type"] # This allows users to specify which reply by number by using an ! and a digit (first or last in string) validspecifides = ['last', 'random', 'count', 'add', 'del', 'remove'] @@ -52,7 +43,7 @@ def bot_dictcom_process(bot, trigger, botcom): botcom.dict["specified"] = int(argone[2:]) elif SpiceBot.inlist(str(argone[2:]), validspecifides): botcom.dict["specified"] = str(argone[2:]).lower() - elif SpiceBot.inlist(str(argone[2:]), botcom.dict["nonstockoptions"]): + elif SpiceBot.inlist(str(argone[2:]), botcom.dict["dict"]["nonstockoptions"]): botcom.dict["specified"] = str(argone[2:]).lower() botcom.dict["responsekey"] = botcom.dict["specified"] else: @@ -296,7 +287,7 @@ def bot_dictcom_reply_shared(bot, trigger, botcom): # display special options for this command if "$specialoptions" in rply: - nonstockoptions = spicemanip(botcom.dict["nonstockoptions"], "andlist") + nonstockoptions = spicemanip(botcom.dict["dict"]["nonstockoptions"], "andlist") rply = rply.replace("$specialoptions", nonstockoptions) # saying, or action? From f7f7d51cac7c01ac99ff7db22f32c1cc06095e7f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 11:27:57 -0400 Subject: [PATCH 18/45] tweak --- sopel_modules/SpiceBot_Core_Commands/DictComs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index 4e13283..718cd9b 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -35,7 +35,7 @@ def bot_dictcom_process(bot, trigger, botcom): botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') # This allows users to specify which reply by number by using an ! and a digit (first or last in string) - validspecifides = ['last', 'random', 'count', 'add', 'del', 'remove'] + validspecifides = ['last', 'random', 'add', 'del', 'remove'] botcom.dict["specified"] = None argone = spicemanip(botcom.dict['args'], 1) if str(argone).startswith("--") and len(str(argone)) > 2: From 355145d33d10bcb1b6785fb5c1130e476cc99710 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 11:49:26 -0400 Subject: [PATCH 19/45] test --- sopel_modules/SpiceBot/Prerun.py | 42 +++++++++++-------- .../SpiceBot_Core_Commands/DictComs.py | 31 +++++--------- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 49b2336..1cdd234 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -104,12 +104,13 @@ def prerun(t_command_type='module', t_command_subtype=None): botcom.dict["args"], botcom.dict["hyphen_arg"] = trigger_hyphen_args(botcom.dict["args"]) - # special handling - botcom = special_handling(botcom) - args_pass = trigger_hyphen_arg_handler(bot, trigger, botcom) if args_pass: + + # special handling + botcom = special_handling(botcom) + if trigger_runstatus(bot, trigger, botcom): function(bot, trigger, botcom, *args, **kwargs) botmessagelog.messagelog_exit(bot, argsdict_default["log_id"]) @@ -118,20 +119,6 @@ def prerun(t_command_type='module', t_command_subtype=None): return actual_decorator -def special_handling(botcom): - botcom.dict["responsekey"] = "?default" - - # handling for special cases - posscom = spicemanip(botcom.dict['args'], 1) - if posscom.lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]: - for command in botcom.dict["dict"]["nonstockoptions"]: - if command.lower() == posscom.lower(): - posscom = command - botcom.dict["responsekey"] = posscom - - return botcom - - def prerun_query(t_command_type='module', t_command_subtype=None): def actual_decorator(function): @@ -447,6 +434,25 @@ def trigger_cant_run(bot, trigger, botcom, message=None): return False +def special_handling(botcom): + botcom.dict["responsekey"] = "?default" + + if str(botcom.dict["hyphen_arg"]).lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]: + botcom.dict["responsekey"] = str(botcom.dict["hyphen_arg"]).lower() + + else: + + # handling for special cases + posscom = spicemanip(botcom.dict['args'], 1) + if posscom.lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]: + for command in botcom.dict["dict"]["nonstockoptions"]: + if command.lower() == posscom.lower(): + posscom = command + botcom.dict["responsekey"] = posscom + + return botcom + + def trigger_hyphen_args(trigger_args_part): hyphen_args = [] @@ -472,7 +478,7 @@ def trigger_hyphen_args(trigger_args_part): clipped_word = w2n.word_to_num(str(clipped_word)) hyphen_args.append(int(clipped_word)) - # word is not a valid arg or number + # word is not a valid arg or number except ValueError: trigger_args_unhyphend.append(worditem) else: diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index 718cd9b..f24a5be 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -11,7 +11,6 @@ import sopel_modules.SpiceBot as SpiceBot from sopel_modules.spicemanip import spicemanip -from word2number import w2n from random import randint import time @@ -35,25 +34,17 @@ def bot_dictcom_process(bot, trigger, botcom): botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') # This allows users to specify which reply by number by using an ! and a digit (first or last in string) - validspecifides = ['last', 'random', 'add', 'del', 'remove'] - botcom.dict["specified"] = None - argone = spicemanip(botcom.dict['args'], 1) - if str(argone).startswith("--") and len(str(argone)) > 2: - if str(argone[2:]).isdigit(): - botcom.dict["specified"] = int(argone[2:]) - elif SpiceBot.inlist(str(argone[2:]), validspecifides): - botcom.dict["specified"] = str(argone[2:]).lower() - elif SpiceBot.inlist(str(argone[2:]), botcom.dict["dict"]["nonstockoptions"]): - botcom.dict["specified"] = str(argone[2:]).lower() - botcom.dict["responsekey"] = botcom.dict["specified"] - else: - try: - botcom.dict["specified"] = w2n.word_to_num(str(argone[1:])) - botcom.dict["specified"] = int(botcom.dict["specified"]) - except ValueError: - botcom.dict["specified"] = None - if botcom.dict["specified"]: - botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') + if botcom.dict["hyphen_arg"]: + botcom.dict["specified"] = botcom.dict["hyphen_arg"] + else: + validspecifides = ['last', 'random', 'add', 'del', 'remove'] + botcom.dict["specified"] = None + argone = spicemanip(botcom.dict['args'], 1) + if str(argone).startswith("--") and len(str(argone)) > 2: + if SpiceBot.inlist(str(argone[2:]), validspecifides): + botcom.dict["specified"] = str(argone[2:]).lower() + if botcom.dict["specified"]: + botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') # commands that can be updated if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: From ec240c8efbaffb6853adb7948cc6ee2cfe07de75 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 11:59:20 -0400 Subject: [PATCH 20/45] test --- sopel_modules/SpiceBot/Prerun.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 1cdd234..f460213 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -102,7 +102,7 @@ def prerun(t_command_type='module', t_command_subtype=None): botcom.dict["runcount"] = runcount - botcom.dict["args"], botcom.dict["hyphen_arg"] = trigger_hyphen_args(botcom.dict["args"]) + botcom.dict["args"], botcom.dict["hyphen_arg"] = trigger_hyphen_args(botcom) args_pass = trigger_hyphen_arg_handler(bot, trigger, botcom) @@ -453,11 +453,11 @@ def special_handling(botcom): return botcom -def trigger_hyphen_args(trigger_args_part): +def trigger_hyphen_args(botcom): hyphen_args = [] trigger_args_unhyphend = [] - for worditem in trigger_args_part: + for worditem in botcom.dict["args"]: if str(worditem).startswith("--"): clipped_word = str(worditem[2:]).lower() @@ -465,6 +465,10 @@ def trigger_hyphen_args(trigger_args_part): if clipped_word in prerun_shared.valid_hyphen_args: hyphen_args.append(clipped_word) + # include nonstock options here as well + elif str(clipped_word).lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]: + hyphen_args.append(clipped_word) + # numbered args elif str(clipped_word).isdigit(): hyphen_args.append(int(clipped_word)) From 2c795a1c41fbc5c4d9123b3e005a18edb08c138c Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 12:00:57 -0400 Subject: [PATCH 21/45] test --- sopel_modules/SpiceBot/Prerun.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index f460213..1d5644f 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -505,8 +505,12 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): if not botcom.dict["hyphen_arg"]: return True + # include nonstock options here as well + elif str(botcom.dict["hyphen_arg"]).lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]: + return True + # handle numbered args - if str(botcom.dict["hyphen_arg"]).isdigit() or botcom.dict["hyphen_arg"] in [-1, 'random']: + elif str(botcom.dict["hyphen_arg"]).isdigit() or botcom.dict["hyphen_arg"] in [-1, 'random']: return True elif botcom.dict["hyphen_arg"] in ['check']: From 63ded5527b4e9151fdc3375bcd4bc36b2311adde Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 12:06:26 -0400 Subject: [PATCH 22/45] test --- sopel_modules/SpiceBot_Core_Commands/DictComs.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index f24a5be..cdeec1f 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -34,11 +34,12 @@ def bot_dictcom_process(bot, trigger, botcom): botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') # This allows users to specify which reply by number by using an ! and a digit (first or last in string) + botcom.dict["specified"] = None if botcom.dict["hyphen_arg"]: - botcom.dict["specified"] = botcom.dict["hyphen_arg"] + if str(botcom.dict["hyphen_arg"]).isdigit() or botcom.dict["hyphen_arg"] in [-1, 'random']: + botcom.dict["specified"] = botcom.dict["hyphen_arg"] else: - validspecifides = ['last', 'random', 'add', 'del', 'remove'] - botcom.dict["specified"] = None + validspecifides = ['random', 'add', 'del', 'remove'] argone = spicemanip(botcom.dict['args'], 1) if str(argone).startswith("--") and len(str(argone)) > 2: if SpiceBot.inlist(str(argone[2:]), validspecifides): From 69cea3c0fd1e9e6638b926edca90729c6b244db5 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 12:11:06 -0400 Subject: [PATCH 23/45] fix handling remove redundant hyphen args --- sopel_modules/SpiceBot/Prerun.py | 33 ++++++++++---------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 1d5644f..8af2727 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -104,13 +104,13 @@ def prerun(t_command_type='module', t_command_subtype=None): botcom.dict["args"], botcom.dict["hyphen_arg"] = trigger_hyphen_args(botcom) + # special handling + botcom = special_handling(botcom) + args_pass = trigger_hyphen_arg_handler(bot, trigger, botcom) if args_pass: - # special handling - botcom = special_handling(botcom) - if trigger_runstatus(bot, trigger, botcom): function(bot, trigger, botcom, *args, **kwargs) botmessagelog.messagelog_exit(bot, argsdict_default["log_id"]) @@ -437,18 +437,13 @@ def trigger_cant_run(bot, trigger, botcom, message=None): def special_handling(botcom): botcom.dict["responsekey"] = "?default" - if str(botcom.dict["hyphen_arg"]).lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]: - botcom.dict["responsekey"] = str(botcom.dict["hyphen_arg"]).lower() - - else: - - # handling for special cases - posscom = spicemanip(botcom.dict['args'], 1) - if posscom.lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]: - for command in botcom.dict["dict"]["nonstockoptions"]: - if command.lower() == posscom.lower(): - posscom = command - botcom.dict["responsekey"] = posscom + # handling for special cases + posscom = spicemanip(botcom.dict['args'], 1) + if posscom.lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]: + for command in botcom.dict["dict"]["nonstockoptions"]: + if command.lower() == posscom.lower(): + posscom = command + botcom.dict["responsekey"] = posscom return botcom @@ -465,10 +460,6 @@ def trigger_hyphen_args(botcom): if clipped_word in prerun_shared.valid_hyphen_args: hyphen_args.append(clipped_word) - # include nonstock options here as well - elif str(clipped_word).lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]: - hyphen_args.append(clipped_word) - # numbered args elif str(clipped_word).isdigit(): hyphen_args.append(int(clipped_word)) @@ -505,10 +496,6 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): if not botcom.dict["hyphen_arg"]: return True - # include nonstock options here as well - elif str(botcom.dict["hyphen_arg"]).lower() in [command.lower() for command in botcom.dict["dict"]["nonstockoptions"]]: - return True - # handle numbered args elif str(botcom.dict["hyphen_arg"]).isdigit() or botcom.dict["hyphen_arg"] in [-1, 'random']: return True From 250b07f293e17eb5779f2955c060e934b638812e Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 12:57:59 -0400 Subject: [PATCH 24/45] tests --- sopel_modules/SpiceBot/MessageLog.py | 11 ++++++++ sopel_modules/SpiceBot/Prerun.py | 28 +++++++++++++++---- sopel_modules/SpiceBot/Read.py | 22 +++++++++------ sopel_modules/SpiceBot/Tools.py | 4 ++- .../SpiceBot_Core_Commands/DictComs.py | 20 ++----------- 5 files changed, 52 insertions(+), 33 deletions(-) diff --git a/sopel_modules/SpiceBot/MessageLog.py b/sopel_modules/SpiceBot/MessageLog.py index 1947bc7..5b53e30 100644 --- a/sopel_modules/SpiceBot/MessageLog.py +++ b/sopel_modules/SpiceBot/MessageLog.py @@ -100,6 +100,14 @@ class MessageLog(): self.message_display[log_id]["messages"].append(messagedict) + def messagelog_private(self, log_id, message): + + recipients = [self.message_display[log_id]["trigger"]["nick"]] + + messagedict = {"type": "private", "message": message, "recipients": recipients} + + self.message_display[log_id]["messages"].append(messagedict) + def messagelog_exit(self, bot, log_id): current_messages = [] @@ -132,6 +140,9 @@ class MessageLog(): if messagedict["type"] == 'error': bot.osd(messagedict['message'], self.message_display[log_id]["trigger"]["nick"], 'notice') + elif messagedict["type"] == 'private': + bot.osd(messagedict['message'], messagedict["recipients"], 'notice') + elif len(messagedict["recipients"]) > 1: bot.osd(messagedict['message'], messagedict["recipients"], 'notice') diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 8af2727..44d96d4 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -445,6 +445,9 @@ def special_handling(botcom): posscom = command botcom.dict["responsekey"] = posscom + if botcom.dict["responsekey"] != "?default": + botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') + return botcom @@ -511,7 +514,7 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): if not len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]): botmessagelog.messagelog(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command appears to have no entries!") else: - bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command contains:", trigger.nick, 'notice') + botmessagelog.messagelog_private(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command contains:") listnumb, relist = 0, [] for item in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]: listnumb += 1 @@ -521,20 +524,33 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): relist.append(str("[#" + str(listnumb) + "] COMPLEX list Entry")) else: relist.append(str("[#" + str(listnumb) + "] " + str(item))) - bot.osd(relist, trigger.nick, 'notice') + botmessagelog.messagelog_private(botcom.dict["log_id"], relist) return False elif botcom.dict["hyphen_arg"] in ['count']: - bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command has " + str(len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])) + " entries.") + botmessagelog.messagelog(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command has " + str(len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])) + " entries.") return False - elif botcom.dict["hyphen_arg"] in ['special', 'options']: + elif botcom.dict["hyphen_arg"] in ['special', 'options', 'list']: if not len(botcom.dict["dict"]["nonstockoptions"]): - bot.osd("There appear to be no special options for " + str(botcom.dict["realcom"]) + ".") + botmessagelog.messagelog(botcom.dict["log_id"], "There appear to be no special options for " + str(botcom.dict["realcom"]) + ".") else: - bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + spicemanip(botcom.dict["dict"]["nonstockoptions"], "andlist") + ".") + botmessagelog.messagelog(botcom.dict["log_id"], "The special options for " + str(botcom.dict["realcom"]) + " command include: " + spicemanip(botcom.dict["dict"]["nonstockoptions"], "andlist") + ".") return False + elif botcom.dict["hyphen_arg"] in ['add', 'del', 'remove']: + if botcom.dict["hyphen_arg"] in ['add', 'remove']: + directionword = botcom.dict["hyphen_arg"] + elif botcom.dict["hyphen_arg"] in ['del']: + directionword = "remove" + if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: + botmessagelog.messagelog_error(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list cannot be updated.") + + fulltext = spicemanip(botcom.dict['args'], 0) + if not fulltext: + botmessagelog.messagelog(botcom.dict["log_id"], "What would you like to " + directionword + " from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?") + return True + elif botcom.dict["hyphen_arg"] in [ 'enable', 'disable', 'block', 'unblock', diff --git a/sopel_modules/SpiceBot/Read.py b/sopel_modules/SpiceBot/Read.py index 8957167..4e2cc66 100644 --- a/sopel_modules/SpiceBot/Read.py +++ b/sopel_modules/SpiceBot/Read.py @@ -224,18 +224,11 @@ class BotRead(): if "hardcoded_channel_block" not in list(dict_from_file.keys()): dict_from_file["hardcoded_channel_block"] = [] - # ensure creation of '?default' - if "?default" not in list(dict_from_file.keys()): - dict_from_file["?default"] = {} - # check that type is set, use cases will inherit this if not set if "type" not in list(dict_from_file.keys()): dict_from_file["type"] = 'module' - if "responses" not in list(dict_from_file["?default"].keys()): - dict_from_file["?default"]["responses"] = [] - - dict_from_file["nonstockoptions"] = [] + dict_from_file["nonstockoptions"] = ["?default"] for command in list(dict_from_file.keys()): if command not in prerun_shared.stockoptions: dict_from_file["nonstockoptions"].append(command) @@ -250,9 +243,22 @@ class BotRead(): if not isinstance(dict_from_file[specialcase], dict): dict_from_file[specialcase] = dict() + if "responses" not in list(dict_from_file[specialcase].keys()): + dict_from_file[specialcase]["responses"] = [] + if "type" not in list(dict_from_file[specialcase].keys()): dict_from_file[specialcase]["type"] = "module" + # each usecase needs to know if it can be updated. Default is false + if "updates_enabled" not in list(dict_from_file[specialcase].keys()): + dict_from_file[specialcase]["updates_enabled"] = False + if dict_from_file[specialcase]["updates_enabled"]: + if dict_from_file[specialcase]["updates_enabled"] not in ["shared", "user"]: + dict_from_file[specialcase]["updates_enabled"] = "shared" + + if "?default" in dict_from_file["nonstockoptions"]: + dict_from_file["nonstockoptions"].remove("?default") + return dict_from_file diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index 598d1d1..ec45482 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -25,7 +25,9 @@ class Botprerun_shared(): self.valid_hyphen_args = [ 'check', 'view', - 'count', 'special', 'options', + 'count', + 'special', 'options', 'list', + 'add', 'del', 'remove', 'enable', 'disable', 'block', 'unblock', "activate", "deactivate", diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index cdeec1f..51595fc 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -29,23 +29,13 @@ def command_dictcom(bot, trigger, botcom): def bot_dictcom_process(bot, trigger, botcom): - # use the default key, unless otherwise specified - if botcom.dict["responsekey"] != "?default": - botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') - # This allows users to specify which reply by number by using an ! and a digit (first or last in string) botcom.dict["specified"] = None if botcom.dict["hyphen_arg"]: if str(botcom.dict["hyphen_arg"]).isdigit() or botcom.dict["hyphen_arg"] in [-1, 'random']: botcom.dict["specified"] = botcom.dict["hyphen_arg"] - else: - validspecifides = ['random', 'add', 'del', 'remove'] - argone = spicemanip(botcom.dict['args'], 1) - if str(argone).startswith("--") and len(str(argone)) > 2: - if SpiceBot.inlist(str(argone[2:]), validspecifides): - botcom.dict["specified"] = str(argone[2:]).lower() - if botcom.dict["specified"]: - botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') + elif str(botcom.dict["hyphen_arg"]).lower() in ['add', 'del', 'remove']: + botcom.dict["specified"] = botcom.dict["hyphen_arg"] # commands that can be updated if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: @@ -58,9 +48,6 @@ def bot_dictcom_process(bot, trigger, botcom): elif botcom.dict["specified"] == 'add': - if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: - return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list cannot be updated.") - fulltext = spicemanip(botcom.dict['args'], 0) if not fulltext: return bot.osd("What would you like to add to the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?") @@ -77,9 +64,6 @@ def bot_dictcom_process(bot, trigger, botcom): elif botcom.dict["specified"] in ['del', 'remove']: - if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: - return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list cannot be updated.") - fulltext = spicemanip(botcom.dict['args'], 0) if not fulltext: return bot.osd("What would you like to remove from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?") From b966af8f8bb64d428e4ed9157b896995d90184cd Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 13:01:07 -0400 Subject: [PATCH 25/45] test --- 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 44d96d4..52edcb8 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -545,6 +545,7 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): directionword = "remove" if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: botmessagelog.messagelog_error(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list cannot be updated.") + return True fulltext = spicemanip(botcom.dict['args'], 0) if not fulltext: From 1d578a8f5f64f4fa30592caeb4e4e75a9342009a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 13:02:09 -0400 Subject: [PATCH 26/45] cleanup --- sopel_modules/SpiceBot_Core_Commands/DictComs.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index 51595fc..7fb3ac7 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -48,10 +48,6 @@ def bot_dictcom_process(bot, trigger, botcom): elif botcom.dict["specified"] == 'add': - fulltext = spicemanip(botcom.dict['args'], 0) - if not fulltext: - return bot.osd("What would you like to add to the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?") - if fulltext in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]: return bot.osd("The following was already in the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") @@ -64,10 +60,6 @@ def bot_dictcom_process(bot, trigger, botcom): elif botcom.dict["specified"] in ['del', 'remove']: - fulltext = spicemanip(botcom.dict['args'], 0) - if not fulltext: - return bot.osd("What would you like to remove from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?") - if fulltext not in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]: return bot.osd("The following was already not in the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") From 06f0f1271633886a0b7dcb3523e127b190dd34c0 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 13:02:40 -0400 Subject: [PATCH 27/45] patch --- sopel_modules/SpiceBot_Core_Commands/DictComs.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index 7fb3ac7..c06eda5 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -37,6 +37,8 @@ def bot_dictcom_process(bot, trigger, botcom): elif str(botcom.dict["hyphen_arg"]).lower() in ['add', 'del', 'remove']: botcom.dict["specified"] = botcom.dict["hyphen_arg"] + fulltext = spicemanip(botcom.dict['args'], 0) + # commands that can be updated if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": From 66b4807d5c27fa1ba40e6bab8debc7c777a7961b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 13:04:27 -0400 Subject: [PATCH 28/45] fix --- 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 52edcb8..8ea37cd 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -545,12 +545,12 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): directionword = "remove" if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: botmessagelog.messagelog_error(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list cannot be updated.") - return True + return False fulltext = spicemanip(botcom.dict['args'], 0) if not fulltext: - botmessagelog.messagelog(botcom.dict["log_id"], "What would you like to " + directionword + " from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?") - return True + botmessagelog.messagelog_error(botcom.dict["log_id"], "What would you like to " + directionword + " from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?") + return False elif botcom.dict["hyphen_arg"] in [ 'enable', 'disable', From 69db357eb8a553feaadd84bcbcaf0ebdf4572c81 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 13:07:25 -0400 Subject: [PATCH 29/45] note --- sopel_modules/SpiceBot_Core_Commands/DictComs.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index c06eda5..8ffafd3 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -23,6 +23,8 @@ def command_dictcom(bot, trigger, botcom): return bot_dictcom_process(bot, trigger, botcom) + + # import hack TODO return time.time() From 8aa5c14b25da2494dec818583de60ec8f2b6f89a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 13:52:23 -0400 Subject: [PATCH 30/45] test --- sopel_modules/SpiceBot/Prerun.py | 65 ++++++++++--------- .../SpiceBot_Core_Commands/DictComs.py | 5 +- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 8ea37cd..ade03c4 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -107,7 +107,7 @@ def prerun(t_command_type='module', t_command_subtype=None): # special handling botcom = special_handling(botcom) - args_pass = trigger_hyphen_arg_handler(bot, trigger, botcom) + args_pass, botcom = trigger_hyphen_arg_handler(bot, trigger, botcom) if args_pass: @@ -496,19 +496,22 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): # Commands that cannot run via privmsg # TODO --check should work for commands that don't exist + botcom.dict["specified"] = None + if not botcom.dict["hyphen_arg"]: - return True + return True, botcom # handle numbered args elif str(botcom.dict["hyphen_arg"]).isdigit() or botcom.dict["hyphen_arg"] in [-1, 'random']: - return True + botcom.dict["specified"] = botcom.dict["hyphen_arg"] + return True, botcom elif botcom.dict["hyphen_arg"] in ['check']: if botcom.dict["com"].lower() != botcom.dict["realcom"]: botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is a valid alias command for " + botcom.dict["realcomtext"]) else: botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is a valid command") - return False + return False, botcom elif botcom.dict["hyphen_arg"] in ['view']: if not len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]): @@ -525,18 +528,18 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): else: relist.append(str("[#" + str(listnumb) + "] " + str(item))) botmessagelog.messagelog_private(botcom.dict["log_id"], relist) - return False + return False, botcom elif botcom.dict["hyphen_arg"] in ['count']: botmessagelog.messagelog(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " command has " + str(len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])) + " entries.") - return False + return False, botcom elif botcom.dict["hyphen_arg"] in ['special', 'options', 'list']: if not len(botcom.dict["dict"]["nonstockoptions"]): botmessagelog.messagelog(botcom.dict["log_id"], "There appear to be no special options for " + str(botcom.dict["realcom"]) + ".") else: botmessagelog.messagelog(botcom.dict["log_id"], "The special options for " + str(botcom.dict["realcom"]) + " command include: " + spicemanip(botcom.dict["dict"]["nonstockoptions"], "andlist") + ".") - return False + return False, botcom elif botcom.dict["hyphen_arg"] in ['add', 'del', 'remove']: if botcom.dict["hyphen_arg"] in ['add', 'remove']: @@ -545,12 +548,12 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): directionword = "remove" if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: botmessagelog.messagelog_error(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list cannot be updated.") - return False + return False, botcom fulltext = spicemanip(botcom.dict['args'], 0) if not fulltext: botmessagelog.messagelog_error(botcom.dict["log_id"], "What would you like to " + directionword + " from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?") - return False + return False, botcom elif botcom.dict["hyphen_arg"] in [ 'enable', 'disable', @@ -565,12 +568,12 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I enabling " + str(botcom.dict["comtext"]) + " usage for?") else: botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I disabling " + str(botcom.dict["comtext"]) + " usage for?") - return False + return False, botcom botcom.dict["args"] = spicemanip(botcom.dict["args"], "2+", "list") if not botdb.check_nick_id(target) and not botchannels.check_channel_bot(target, True): botmessagelog.messagelog_error(botcom.dict["log_id"], "I don't know who/what " + str(target) + " is.") - return False + return False, botcom if not botusers.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): if target != trigger.nick: @@ -578,37 +581,37 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to enable this command for " + str(target) + " due to privilege issues.") else: botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to disable this command for " + str(target) + " due to privilege issues.") - return False + return False, botcom if botcom.dict["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]: if not botcommands.check_commands_disabled(botcom.dict["realcomref"], target): botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " is already enabled for " + str(target)) - return False + return False, botcom botcommands.unset_command_disabled(botcom.dict["realcomref"], target) botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is now enabled for " + str(target)) - return False + return False, botcom else: if botcommands.check_commands_disabled(botcom.dict["realcomref"], target): botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " is already disabled for " + str(target)) - return False + return False, botcom trailingmessage = spicemanip(botcom.dict["args"], 0) or "No reason given." timestamp = str(datetime.datetime.utcnow()) botcommands.set_command_disabled(botcom.dict["realcomref"], target, timestamp, trailingmessage, trigger.nick) botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is now disabled for " + str(target)) - return False + return False, botcom if botcom.dict["hyphen_arg"] in ['multirun', 'multiruns']: onoff = spicemanip(botcom.dict["args"], 1) or None if not onoff or onoff not in ['enable', 'unblock', "activate", "on"]: botmessagelog.messagelog_error(botcom.dict["log_id"], "Do you want to enable or disable " + str(botcom.dict["comtext"]) + " multirun usage?") - return False + return False, botcom target = spicemanip(botcom.dict["args"], 1) or trigger.nick if not target: @@ -616,12 +619,12 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I enabling " + str(botcom.dict["comtext"]) + " multirun usage for?") else: botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I disabling " + str(botcom.dict["comtext"]) + " multirun usage for?") - return False + return False, botcom botcom.dict["args"] = spicemanip(botcom.dict["args"], "2+", "list") if not botdb.check_nick_id(target) and not botchannels.check_channel_bot(target, True): botmessagelog.messagelog_error(botcom.dict["log_id"], "I don't know who/what " + str(target) + " is.") - return False + return False, botcom if not botusers.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): if target != trigger.nick: @@ -629,53 +632,53 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to enable multirun usage on " + str(botcom.dict["comtext"]) + " for " + str(target) + " due to privilege issues.") else: botmessagelog.messagelog_error(botcom.dict["log_id"], "I was unable to enable multirun usage on " + str(botcom.dict["comtext"]) + " for " + str(target) + " due to privilege issues.") - return False + return False, botcom if onoff in ['enable', 'unblock', "activate", "on"]: if not botcommands.check_commands_disabled(botcom.dict["realcomref"], target, "multirun"): botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " multirun is already enabled for " + str(target)) - return False + return False, botcom botcommands.unset_command_disabled(botcom.dict["realcomref"], target, "multirun") botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " multirun is now enabled for " + str(target)) - return False + return False, botcom else: if botcommands.check_commands_disabled(botcom.dict["realcomref"], target, "multirun"): botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " multirun is already disabled for " + str(target)) - return False + return False, botcom trailingmessage = spicemanip(botcom.dict["args"], 0) or "No reason given." timestamp = str(datetime.datetime.utcnow()) botcommands.set_command_disabled(botcom.dict["realcomref"], target, timestamp, trailingmessage, trigger.nick, "multirun") botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " multirun is now disabled for " + str(target)) - return False + return False, botcom elif botcom.dict["hyphen_arg"] in ['example', 'usage']: botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + ": " + str(botcom.dict["dict"]["example"])) - return False + return False, botcom elif botcom.dict["hyphen_arg"] in ['filename', 'filepath']: botmessagelog.messagelog(botcom.dict["log_id"], "The " + str(botcom.dict["comtext"]) + " file is located at " + str(botcom.dict["dict"][botcom.dict["hyphen_arg"]])) - return False + return False, botcom elif botcom.dict["hyphen_arg"] in ['foldername', 'folderpath']: botmessagelog.messagelog(botcom.dict["log_id"], "The " + str(botcom.dict["comtext"]) + " folder is located at " + str(botcom.dict["dict"][botcom.dict["hyphen_arg"]])) - return False + return False, botcom elif botcom.dict["hyphen_arg"] in ['author']: botmessagelog.messagelog(botcom.dict["log_id"], "The author of the " + str(botcom.dict["comtext"]) + " command is " + botcom.dict["dict"]["author"] + ".") - return False + return False, botcom elif botcom.dict["hyphen_arg"] in ['contribs', 'contrib', "contributors"]: botmessagelog.messagelog(botcom.dict["log_id"], "The contributors of the " + str(botcom.dict["comtext"]) + " command are " + spicemanip(botcom.dict["dict"]["contributors"], "andlist") + ".") - return False + return False, botcom elif botcom.dict["hyphen_arg"] in ['alias', 'aliases']: botmessagelog.messagelog(botcom.dict["log_id"], "The alaises of the " + str(botcom.dict["comtext"]) + " command are " + spicemanip(botcom.dict["dict"]["validcoms"], "andlist") + ".") - return False + return False, botcom - return False + return False, botcom diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index 8ffafd3..a6a5e93 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -32,11 +32,8 @@ def command_dictcom(bot, trigger, botcom): def bot_dictcom_process(bot, trigger, botcom): # This allows users to specify which reply by number by using an ! and a digit (first or last in string) - botcom.dict["specified"] = None if botcom.dict["hyphen_arg"]: - if str(botcom.dict["hyphen_arg"]).isdigit() or botcom.dict["hyphen_arg"] in [-1, 'random']: - botcom.dict["specified"] = botcom.dict["hyphen_arg"] - elif str(botcom.dict["hyphen_arg"]).lower() in ['add', 'del', 'remove']: + if str(botcom.dict["hyphen_arg"]).lower() in ['add', 'del', 'remove']: botcom.dict["specified"] = botcom.dict["hyphen_arg"] fulltext = spicemanip(botcom.dict['args'], 0) From 6b54366e39e5c192bb6b3b0d43a7470b4a6cb250 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 14:04:57 -0400 Subject: [PATCH 31/45] test AI --- sopel_modules/SpiceBot_Core_Commands/AI.py | 30 ++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/sopel_modules/SpiceBot_Core_Commands/AI.py b/sopel_modules/SpiceBot_Core_Commands/AI.py index c3929ef..c24561d 100644 --- a/sopel_modules/SpiceBot_Core_Commands/AI.py +++ b/sopel_modules/SpiceBot_Core_Commands/AI.py @@ -106,11 +106,31 @@ def bot_command_rule_ai(bot, trigger): 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) + "!"] - # TODO - # 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') + # hyphen args handling + valid_args = ["check"] + hyphen_args = [] + argssplit = spicemanip(fulltrigger, "2+", 'list') + for worditem in argssplit: + if str(worditem).startswith("--"): + clipped_word = str(worditem[2:]).lower() + # valid arg above + if clipped_word in valid_args: + hyphen_args.append(clipped_word) + # only one arg allowed + invalid_display = [] + if len(hyphen_args): + hyphenarg = hyphen_args[0] + if hyphenarg in ['check']: + invalid_display = ["I don't seem to have a command for " + str(trigger_command) + "!"] + else: + invalid_display = [] + # invalid_display = ["I don't seem to have a command for " + str(trigger_command) + "!"] + # TODO + # 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') + if len(invalid_display): + bot.osd(invalid_display, trigger.nick, 'notice') return elif command_type == 'nickname': From 88416fbe94b1d2a5124f1f69661daca834d39bfc Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 14:06:43 -0400 Subject: [PATCH 32/45] test --- sopel_modules/SpiceBot_Core_Commands/AI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_Core_Commands/AI.py b/sopel_modules/SpiceBot_Core_Commands/AI.py index c24561d..5e42dc5 100644 --- a/sopel_modules/SpiceBot_Core_Commands/AI.py +++ b/sopel_modules/SpiceBot_Core_Commands/AI.py @@ -120,7 +120,7 @@ def bot_command_rule_ai(bot, trigger): invalid_display = [] if len(hyphen_args): hyphenarg = hyphen_args[0] - if hyphenarg in ['check']: + if hyphenarg in SpiceBot.prerun_shared.valid_hyphen_args: invalid_display = ["I don't seem to have a command for " + str(trigger_command) + "!"] else: invalid_display = [] From 33279e3c4fba10257bba6d00ae4192de7efce6e5 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 14:11:15 -0400 Subject: [PATCH 33/45] test --- sopel_modules/SpiceBot_Core_Commands/AI.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot_Core_Commands/AI.py b/sopel_modules/SpiceBot_Core_Commands/AI.py index 5e42dc5..3bc9527 100644 --- a/sopel_modules/SpiceBot_Core_Commands/AI.py +++ b/sopel_modules/SpiceBot_Core_Commands/AI.py @@ -8,6 +8,8 @@ import sopel_modules.SpiceBot as SpiceBot from sopel_modules.spicemanip import spicemanip +from word2number import w2n + # TODO split functionality for "no command" @@ -107,15 +109,27 @@ def bot_command_rule_ai(bot, trigger): if not SpiceBot.letters_in_string(trigger_command): return # hyphen args handling - valid_args = ["check"] hyphen_args = [] argssplit = spicemanip(fulltrigger, "2+", 'list') for worditem in argssplit: if str(worditem).startswith("--"): clipped_word = str(worditem[2:]).lower() # valid arg above - if clipped_word in valid_args: + if clipped_word in SpiceBot.prerun_shared.valid_hyphen_args: hyphen_args.append(clipped_word) + # numbered args + elif str(clipped_word).isdigit(): + hyphen_args.append(int(clipped_word)) + elif clipped_word in list(SpiceBot.prerun_shared.numdict.keys()): + hyphen_args.append(int(SpiceBot.prerun_shared.numdict[clipped_word])) + else: + # check if arg word is a number + try: + clipped_word = w2n.word_to_num(str(clipped_word)) + hyphen_args.append(int(clipped_word)) + # word is not a valid arg or number + except ValueError: + clipped_word = None # only one arg allowed invalid_display = [] if len(hyphen_args): @@ -128,7 +142,6 @@ def bot_command_rule_ai(bot, trigger): # TODO # 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') if len(invalid_display): bot.osd(invalid_display, trigger.nick, 'notice') return From 743b74ab308e008ef6a5bebf0c4125db349196e1 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 14:22:00 -0400 Subject: [PATCH 34/45] test --- sopel_modules/SpiceBot_Core_Commands/AI.py | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/sopel_modules/SpiceBot_Core_Commands/AI.py b/sopel_modules/SpiceBot_Core_Commands/AI.py index 3bc9527..8bf9015 100644 --- a/sopel_modules/SpiceBot_Core_Commands/AI.py +++ b/sopel_modules/SpiceBot_Core_Commands/AI.py @@ -108,6 +108,17 @@ def bot_command_rule_ai(bot, trigger): 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) + "!"] + + # create list of valid commands + commands_list = dict() + for commandstype in list(SpiceBot.commands.dict['commands'].keys()): + if commandstype not in ['rule', 'nickname']: + for com in list(SpiceBot.commands.dict['commands'][commandstype].keys()): + if com not in list(commands_list.keys()): + commands_list[com] = SpiceBot.commands.dict['commands'][commandstype][com] + # hyphen args handling hyphen_args = [] argssplit = spicemanip(fulltrigger, "2+", 'list') @@ -130,18 +141,23 @@ def bot_command_rule_ai(bot, trigger): # word is not a valid arg or number except ValueError: clipped_word = None - # only one arg allowed - invalid_display = [] if len(hyphen_args): hyphenarg = hyphen_args[0] - if hyphenarg in SpiceBot.prerun_shared.valid_hyphen_args: - invalid_display = ["I don't seem to have a command for " + str(trigger_command) + "!"] + if hyphenarg: + invalid_display.append("Hyphen Argument Not Valid.") + + closestmatches = SpiceBot.similar_list(trigger_command, list(commands_list.keys()), 10, 'reverse') + if len(closestmatches) and len(hyphen_args): # TODO + invalid_display.append("The following commands may match " + str(trigger_command) + ": " + spicemanip(closestmatches, 'andlist') + ".") + + # there is simply no command else: - invalid_display = [] + # TODO check other commands spelling, maybe there is a similar command # invalid_display = ["I don't seem to have a command for " + str(trigger_command) + "!"] # TODO # 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 = [] if len(invalid_display): bot.osd(invalid_display, trigger.nick, 'notice') return From 009d91e94a77dba6d9d4192fe22f550ff9cb602c Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 14:25:56 -0400 Subject: [PATCH 35/45] test --- sopel_modules/SpiceBot/Prerun.py | 2 +- sopel_modules/SpiceBot/Tools.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index ade03c4..932cd8d 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -506,7 +506,7 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): botcom.dict["specified"] = botcom.dict["hyphen_arg"] return True, botcom - elif botcom.dict["hyphen_arg"] in ['check']: + elif botcom.dict["hyphen_arg"] in ['check', "test"]: if botcom.dict["com"].lower() != botcom.dict["realcom"]: botmessagelog.messagelog(botcom.dict["log_id"], botcom.dict["comtext"] + " is a valid alias command for " + botcom.dict["realcomtext"]) else: diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index ec45482..07c03f3 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -24,7 +24,8 @@ class Botprerun_shared(): def __init__(self): self.valid_hyphen_args = [ - 'check', 'view', + 'check', 'test', + 'view', 'count', 'special', 'options', 'list', 'add', 'del', 'remove', From edac63c5074b6ae173ff767b06266682df5e10f2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 14:31:00 -0400 Subject: [PATCH 36/45] test --- sopel_modules/SpiceBot_Core_Commands/AI.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_Core_Commands/AI.py b/sopel_modules/SpiceBot_Core_Commands/AI.py index 8bf9015..46ca645 100644 --- a/sopel_modules/SpiceBot_Core_Commands/AI.py +++ b/sopel_modules/SpiceBot_Core_Commands/AI.py @@ -157,7 +157,8 @@ def bot_command_rule_ai(bot, trigger): # TODO # 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 = [] + if not len(hyphen_args): + invalid_display = [] if len(invalid_display): bot.osd(invalid_display, trigger.nick, 'notice') return From 540f5f20cd314b58e002b69515d68899af141af2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 14:36:04 -0400 Subject: [PATCH 37/45] nickname ai --- sopel_modules/SpiceBot_Core_Commands/AI.py | 37 +++++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/sopel_modules/SpiceBot_Core_Commands/AI.py b/sopel_modules/SpiceBot_Core_Commands/AI.py index 46ca645..1f60084 100644 --- a/sopel_modules/SpiceBot_Core_Commands/AI.py +++ b/sopel_modules/SpiceBot_Core_Commands/AI.py @@ -271,11 +271,38 @@ def bot_command_rule_ai(bot, trigger): # return # TODO + invalid_display = ["I don't know what you are asking me to do!"] + + # hyphen args handling + hyphen_args = [] + argssplit = spicemanip(fulltrigger, "2+", 'list') + for worditem in argssplit: + if str(worditem).startswith("--"): + clipped_word = str(worditem[2:]).lower() + # valid arg above + if clipped_word in SpiceBot.prerun_shared.valid_hyphen_args: + hyphen_args.append(clipped_word) + # numbered args + elif str(clipped_word).isdigit(): + hyphen_args.append(int(clipped_word)) + elif clipped_word in list(SpiceBot.prerun_shared.numdict.keys()): + hyphen_args.append(int(SpiceBot.prerun_shared.numdict[clipped_word])) + else: + # check if arg word is a number + try: + clipped_word = w2n.word_to_num(str(clipped_word)) + hyphen_args.append(int(clipped_word)) + # word is not a valid arg or number + except ValueError: + clipped_word = None + if len(hyphen_args): + hyphenarg = hyphen_args[0] + if hyphenarg: + invalid_display.append("Hyphen Argument Not Valid.") + closestmatches = SpiceBot.similar_list(trigger_command, list(SpiceBot.commands.dict['commands']["nickname"].keys()), 3, 'reverse') if len(closestmatches): closestmatches = spicemanip(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 + invalid_display.append("Did you mean: " + str(closestmatches) + "?") + + bot.osd(invalid_display, trigger.nick, 'notice') From c9347b7f54070e94c4a3b2e0b6c8eac1b2e2a15c Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 15:17:20 -0400 Subject: [PATCH 38/45] test specified --- sopel_modules/SpiceBot/Prerun.py | 29 ++++++++++++++++++- sopel_modules/SpiceBot/Read.py | 3 ++ .../SpiceBot_Core_Commands/DictComs.py | 14 +-------- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 932cd8d..4525de1 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -106,6 +106,7 @@ def prerun(t_command_type='module', t_command_subtype=None): # special handling botcom = special_handling(botcom) + botcom = updatable_content(bot, botcom, trigger) args_pass, botcom = trigger_hyphen_arg_handler(bot, trigger, botcom) @@ -434,6 +435,28 @@ def trigger_cant_run(bot, trigger, botcom, message=None): return False +def updatable_content(bot, botcom, trigger): + # commands that can be updated + if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: + customresponses = [] + if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": + customresponses = botdb.get_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": + customresponses = botdb.get_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + if not len(customresponses): + if len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]): + savevalues = botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] + else: + savevalues = ["Please use --add to add custom content!"] + if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": + botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), savevalues) + elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": + botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), savevalues) + else: + botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = customresponses + return botcom + + def special_handling(botcom): botcom.dict["responsekey"] = "?default" @@ -504,7 +527,11 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): # handle numbered args elif str(botcom.dict["hyphen_arg"]).isdigit() or botcom.dict["hyphen_arg"] in [-1, 'random']: botcom.dict["specified"] = botcom.dict["hyphen_arg"] - return True, botcom + if not botcom.dict["dict"][botcom.dict["responsekey"]]["selection_allowed"]: + botmessagelog.messagelog_error(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " response list cannot be specified.") + return False, botcom + else: + return True, botcom elif botcom.dict["hyphen_arg"] in ['check', "test"]: if botcom.dict["com"].lower() != botcom.dict["realcom"]: diff --git a/sopel_modules/SpiceBot/Read.py b/sopel_modules/SpiceBot/Read.py index 4e2cc66..e717f53 100644 --- a/sopel_modules/SpiceBot/Read.py +++ b/sopel_modules/SpiceBot/Read.py @@ -256,6 +256,9 @@ class BotRead(): if dict_from_file[specialcase]["updates_enabled"] not in ["shared", "user"]: dict_from_file[specialcase]["updates_enabled"] = "shared" + if "selection_allowed" not in list(dict_from_file[specialcase].keys()): + dict_from_file[specialcase]["selection_allowed"] = True + if "?default" in dict_from_file["nonstockoptions"]: dict_from_file["nonstockoptions"].remove("?default") diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index a6a5e93..eaac311 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -38,16 +38,7 @@ def bot_dictcom_process(bot, trigger, botcom): fulltext = spicemanip(botcom.dict['args'], 0) - # commands that can be updated - if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: - if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - SpiceBot.dictcoms.adjust_nick_array(str(SpiceBot.config.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"], 'startup') - botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = SpiceBot.db.get_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] - elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - SpiceBot.dictcoms.adjust_nick_array(str(trigger.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"], 'startup') - botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = SpiceBot.db.get_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] - - elif botcom.dict["specified"] == 'add': + if botcom.dict["specified"] == 'add': if fulltext in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]: return bot.osd("The following was already in the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") @@ -71,9 +62,6 @@ def bot_dictcom_process(bot, trigger, botcom): return bot.osd("The following was removed from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") - elif botcom.dict["specified"] and not botcom.dict["dict"][botcom.dict["responsekey"]]["selection_allowed"]: - return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " response list cannot be specified.") - botcom.dict["target"] = False botcom.dict["success"] = True From a9cacbd33cca52505d9d477b6376226ef7aceff5 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 15:31:15 -0400 Subject: [PATCH 39/45] test me --- sopel_modules/SpiceBot/Prerun.py | 33 ++++++++++++++++++- .../SpiceBot_Core_Commands/DictComs.py | 26 --------------- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 4525de1..a553330 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -575,13 +575,44 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): directionword = "remove" if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: botmessagelog.messagelog_error(botcom.dict["log_id"], "The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list cannot be updated.") - return False, botcom + return False, botcom fulltext = spicemanip(botcom.dict['args'], 0) if not fulltext: botmessagelog.messagelog_error(botcom.dict["log_id"], "What would you like to " + directionword + " from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?") return False, botcom + if botcom.dict["hyphen_arg"] in ['add']: + if fulltext in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]: + botmessagelog.messagelog_error(botcom.dict["log_id"], "The following was already in the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") + return False, botcom + + botcom.dict["dict"][botcom.dict["responsekey"]]["responses"].append(fulltext) + + if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": + botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]) + elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": + botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]) + + botmessagelog.messagelog(botcom.dict["log_id"], "The following was added to the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") + return False, botcom + + elif botcom.dict["hyphen_arg"] in ['del', 'remove']: + if fulltext not in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]: + botmessagelog.messagelog_error(botcom.dict["log_id"], "The following was already not in the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") + return False, botcom + botcom.dict["dict"][botcom.dict["responsekey"]]["responses"].remove(fulltext) + + if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": + botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]) + elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": + botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]) + + botmessagelog.messagelog(botcom.dict["log_id"], "The following was removed from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") + return False, botcom + + return False, botcom + elif botcom.dict["hyphen_arg"] in [ 'enable', 'disable', 'block', 'unblock', diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index eaac311..852dc47 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -36,32 +36,6 @@ def bot_dictcom_process(bot, trigger, botcom): if str(botcom.dict["hyphen_arg"]).lower() in ['add', 'del', 'remove']: botcom.dict["specified"] = botcom.dict["hyphen_arg"] - fulltext = spicemanip(botcom.dict['args'], 0) - - if botcom.dict["specified"] == 'add': - - if fulltext in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]: - return bot.osd("The following was already in the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") - - if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - SpiceBot.dictcoms.adjust_nick_array(str(bot.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), fulltext, botcom.dict["specified"]) - elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - SpiceBot.dictcoms.adjust_nick_array(str(trigger.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), fulltext, botcom.dict["specified"]) - - return bot.osd("The following was added to the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") - - elif botcom.dict["specified"] in ['del', 'remove']: - - if fulltext not in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]: - return bot.osd("The following was already not in the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") - - if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - SpiceBot.dictcoms.adjust_nick_array(str(bot.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), fulltext, botcom.dict["specified"]) - elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - SpiceBot.dictcoms.adjust_nick_array(str(trigger.nick), 'sayings', botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), fulltext, botcom.dict["specified"]) - - return bot.osd("The following was removed from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") - botcom.dict["target"] = False botcom.dict["success"] = True From 8db4017ca26d3642417db6e59e48d53c68de6eab Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 15:43:52 -0400 Subject: [PATCH 40/45] duh --- 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 a553330..7bd7839 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -580,7 +580,7 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): fulltext = spicemanip(botcom.dict['args'], 0) if not fulltext: botmessagelog.messagelog_error(botcom.dict["log_id"], "What would you like to " + directionword + " from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?") - return False, botcom + return False, botcom if botcom.dict["hyphen_arg"] in ['add']: if fulltext in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]: From eda13e004bd05ffc88049aadd0273b32a24192d8 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 15:49:11 -0400 Subject: [PATCH 41/45] test --- sopel_modules/SpiceBot/Prerun.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 7bd7839..6f0cade 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -582,31 +582,36 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): botmessagelog.messagelog_error(botcom.dict["log_id"], "What would you like to " + directionword + " from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?") return False, botcom + if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": + customresponses = botdb.get_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": + customresponses = botdb.get_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + if botcom.dict["hyphen_arg"] in ['add']: - if fulltext in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]: + if fulltext in customresponses: botmessagelog.messagelog_error(botcom.dict["log_id"], "The following was already in the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") return False, botcom - botcom.dict["dict"][botcom.dict["responsekey"]]["responses"].append(fulltext) + customresponses.append(fulltext) if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]) + botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), customresponses) elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]) + botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), customresponses) botmessagelog.messagelog(botcom.dict["log_id"], "The following was added to the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") return False, botcom elif botcom.dict["hyphen_arg"] in ['del', 'remove']: - if fulltext not in botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]: + if fulltext not in customresponses: botmessagelog.messagelog_error(botcom.dict["log_id"], "The following was already not in the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") return False, botcom - botcom.dict["dict"][botcom.dict["responsekey"]]["responses"].remove(fulltext) + customresponses.remove(fulltext) if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]) + botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), customresponses) elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]) + botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), customresponses) botmessagelog.messagelog(botcom.dict["log_id"], "The following was removed from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") return False, botcom From 98b38e46b84afad8eaa27b7542f12382a8f5445a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 15:54:46 -0400 Subject: [PATCH 42/45] , 'sayings' --- sopel_modules/SpiceBot/Prerun.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 6f0cade..ad399bd 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -440,18 +440,18 @@ def updatable_content(bot, botcom, trigger): if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: customresponses = [] if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - customresponses = botdb.get_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + customresponses = botdb.get_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - customresponses = botdb.get_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + customresponses = botdb.get_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] if not len(customresponses): if len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]): savevalues = botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] else: savevalues = ["Please use --add to add custom content!"] if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), savevalues) + botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), savevalues, 'sayings') elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), savevalues) + botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), savevalues, 'sayings') else: botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = customresponses return botcom @@ -583,9 +583,9 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): return False, botcom if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - customresponses = botdb.get_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + customresponses = botdb.get_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - customresponses = botdb.get_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + customresponses = botdb.get_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] if botcom.dict["hyphen_arg"] in ['add']: if fulltext in customresponses: @@ -595,9 +595,9 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): customresponses.append(fulltext) if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), customresponses) + botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), customresponses) + botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') botmessagelog.messagelog(botcom.dict["log_id"], "The following was added to the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") return False, botcom @@ -609,9 +609,9 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): customresponses.remove(fulltext) if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), customresponses) + botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), customresponses) + botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') botmessagelog.messagelog(botcom.dict["log_id"], "The following was removed from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") return False, botcom From 0cee91cf21ab1431abde6287e602385e7b37c465 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 15:56:45 -0400 Subject: [PATCH 43/45] realcom --- sopel_modules/SpiceBot/Prerun.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index ad399bd..66861ff 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -440,18 +440,18 @@ def updatable_content(bot, botcom, trigger): if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: customresponses = [] if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - customresponses = botdb.get_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + customresponses = botdb.get_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - customresponses = botdb.get_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + customresponses = botdb.get_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] if not len(customresponses): if len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]): savevalues = botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] else: savevalues = ["Please use --add to add custom content!"] if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), savevalues, 'sayings') + botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), savevalues, 'sayings') elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), savevalues, 'sayings') + botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), savevalues, 'sayings') else: botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = customresponses return botcom @@ -583,9 +583,9 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): return False, botcom if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - customresponses = botdb.get_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + customresponses = botdb.get_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - customresponses = botdb.get_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + customresponses = botdb.get_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] if botcom.dict["hyphen_arg"] in ['add']: if fulltext in customresponses: @@ -595,9 +595,9 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): customresponses.append(fulltext) if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') + botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') + botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') botmessagelog.messagelog(botcom.dict["log_id"], "The following was added to the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") return False, botcom @@ -609,9 +609,9 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): customresponses.remove(fulltext) if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') + botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"][0] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') + botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') botmessagelog.messagelog(botcom.dict["log_id"], "The following was removed from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") return False, botcom From f8d1f82399e99d465f5fd5e013509e0a45f94009 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 15:58:18 -0400 Subject: [PATCH 44/45] botcom.dict["realcom"] --- sopel_modules/SpiceBot/Prerun.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 66861ff..3dfc1e9 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -440,18 +440,18 @@ def updatable_content(bot, botcom, trigger): if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]: customresponses = [] if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - customresponses = botdb.get_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + customresponses = botdb.get_nick_value(str(bot.nick), botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - customresponses = botdb.get_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + customresponses = botdb.get_nick_value(str(trigger.nick), botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] if not len(customresponses): if len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"]): savevalues = botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] else: savevalues = ["Please use --add to add custom content!"] if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), savevalues, 'sayings') + botdb.set_nick_value(str(bot.nick), botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), savevalues, 'sayings') elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), savevalues, 'sayings') + botdb.set_nick_value(str(trigger.nick), botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), savevalues, 'sayings') else: botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = customresponses return botcom @@ -583,9 +583,9 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): return False, botcom if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - customresponses = botdb.get_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + customresponses = botdb.get_nick_value(str(bot.nick), botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - customresponses = botdb.get_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] + customresponses = botdb.get_nick_value(str(trigger.nick), botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), 'sayings') or [] if botcom.dict["hyphen_arg"] in ['add']: if fulltext in customresponses: @@ -595,9 +595,9 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): customresponses.append(fulltext) if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') + botdb.set_nick_value(str(bot.nick), botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') + botdb.set_nick_value(str(trigger.nick), botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') botmessagelog.messagelog(botcom.dict["log_id"], "The following was added to the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") return False, botcom @@ -609,9 +609,9 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom): customresponses.remove(fulltext) if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "shared": - botdb.set_nick_value(str(bot.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') + botdb.set_nick_value(str(bot.nick), botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') elif botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"] == "user": - botdb.set_nick_value(str(trigger.nick), botcom.dict["dict"]["realcom"] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') + botdb.set_nick_value(str(trigger.nick), botcom.dict["realcom"] + "_" + str(botcom.dict["responsekey"]), customresponses, 'sayings') botmessagelog.messagelog(botcom.dict["log_id"], "The following was removed from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list: '" + str(fulltext) + "'") return False, botcom From 9770c4456ce03519f553a3cb6928d62291ea1911 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 16:00:23 -0400 Subject: [PATCH 45/45] done --- sopel_modules/SpiceBot_Core_Commands/DictComs.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index 852dc47..67e07ed 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -31,11 +31,6 @@ def command_dictcom(bot, trigger, botcom): def bot_dictcom_process(bot, trigger, botcom): - # This allows users to specify which reply by number by using an ! and a digit (first or last in string) - if botcom.dict["hyphen_arg"]: - if str(botcom.dict["hyphen_arg"]).lower() in ['add', 'del', 'remove']: - botcom.dict["specified"] = botcom.dict["hyphen_arg"] - botcom.dict["target"] = False botcom.dict["success"] = True