From 69cea3c0fd1e9e6638b926edca90729c6b244db5 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 19 Sep 2019 12:11:06 -0400 Subject: [PATCH] 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