diff options
Diffstat (limited to '')
| -rw-r--r-- | bot/exts/info/information.py | 6 | ||||
| -rw-r--r-- | tests/bot/exts/info/test_information.py | 7 | 
2 files changed, 8 insertions, 5 deletions
| diff --git a/bot/exts/info/information.py b/bot/exts/info/information.py index 44cd55362..2eb9382e3 100644 --- a/bot/exts/info/information.py +++ b/bot/exts/info/information.py @@ -546,8 +546,10 @@ class Information(Cog):                  try:                      rule_numbers.append(int(word))                  except ValueError: -                    if (kw := word.lower()) in keyword_to_rule_number: -                        keywords.append(kw) +                    # Stop on first invalid keyword/index to allow for normal messaging after +                    if (kw := word.lower()) not in keyword_to_rule_number: +                        break +                    keywords.append(kw)          if not rule_numbers and not keywords:              # Neither rules nor keywords were submitted. Return the default description. diff --git a/tests/bot/exts/info/test_information.py b/tests/bot/exts/info/test_information.py index 0444ca465..65595e959 100644 --- a/tests/bot/exts/info/test_information.py +++ b/tests/bot/exts/info/test_information.py @@ -625,8 +625,8 @@ class RuleCommandTests(unittest.IsolatedAsyncioTestCase):          test_cases = [              ("1 2 first", {1, 2}), -            ("1 hello 2 second", {1, 2}), -            ("second third unknown 999", None) +            ("1 hello 2 second", {1}), +            ("second third unknown 999", {2, 3}),          ]          for raw_user_input, expected_matched_rule_numbers in test_cases: @@ -637,7 +637,8 @@ class RuleCommandTests(unittest.IsolatedAsyncioTestCase):      async def test_return_default_rules_when_no_input_or_no_match_are_found(self):          test_cases = [              ("", None), -            ("hello abc", None), +            ("hello 2 second", None), +            ("hello 999", None),          ]          for raw_user_input, expected_matched_rule_numbers in test_cases: | 
