From b3b628a51db00ac3eef26efa2e8b1cf8f7139735 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 09:47:47 -0400 Subject: [PATCH] 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?