From b7e4bb31f32430f297b3e411abcd8ddfba2103bd Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 5 Jul 2019 11:37:52 -0400 Subject: [PATCH] test last translation --- 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 f389f09..08d3261 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -404,27 +404,44 @@ def trigger_hyphen_args(trigger_args_part): 'contribs', 'contrib', "contributors", 'alias', 'aliases' ] + numdict = { + "last": -1 + } hyphen_args = [] trigger_args_unhyphend = [] for worditem in trigger_args_part: if str(worditem).startswith("--"): - clipped_word = worditem[2:] + clipped_word = str(worditem[2:]).lower() + + # valid arg above if clipped_word in 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])) + 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: trigger_args_unhyphend.append(worditem) else: trigger_args_unhyphend.append(worditem) + + # only one arg allowed per && split if len(hyphen_args): hyphenarg = hyphen_args[0] else: hyphenarg = None + return trigger_args_unhyphend, hyphenarg