Skip to content

Commit 26a1042

Browse files
committed
Remove certain phrases before comparing arguments
1 parent 3c3508e commit 26a1042

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

mandatory_close_duration/mandatory_close_duration.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,20 @@ async def safe_close(
5252
"""
5353
modifiers = {'silently', 'silent', 'cancel'}
5454

55-
argument_passed = bool(after)
56-
not_a_modifier = after.arg not in modifiers
55+
argument_passed = after is not None
5756

58-
if argument_passed and not_a_modifier and after.arg == after.raw:
57+
if argument_passed:
58+
not_a_modifier = after.arg not in modifiers
59+
60+
# These changes are always made to the argument by the super
61+
# class so they need to be replicated before the raw argument
62+
# is compared with the parsed message.
63+
stripped_argument = after.raw.strip()
64+
argument_without_phrases = stripped_argument.removeprefix('in ').removesuffix(' from now')
65+
66+
no_duration = after.arg == argument_without_phrases
67+
68+
if argument_passed and not_a_modifier and no_duration:
5969
# Ask for confirmation since only a close message was provided.
6070
await close_after_confirmation(ctx, after)
6171
else:

0 commit comments

Comments
 (0)