From a9cacbd33cca52505d9d477b6376226ef7aceff5 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 15:31:15 -0400 Subject: [PATCH] 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