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