From ead8fb2c47bad5c85e153d7ebde542ec177e83cd Mon Sep 17 00:00:00 2001 From: Rongrong Date: Fri, 21 Oct 2022 22:27:45 +0800 Subject: [PATCH] feat: strip `$` from command --- SlashBot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SlashBot.py b/SlashBot.py index b3e8961..83322f6 100644 --- a/SlashBot.py +++ b/SlashBot.py @@ -16,7 +16,7 @@ from random import choice Filters = filters.Filters -parser = re.compile(r'^(?P[\\/]_?)' +parser = re.compile(r'^(?P[\\/]_?\$?)' r'(?P([^\s\\]|\\.)*((?<=\S)\\)?)' r'(\s+(?P.+))?$') ouenParser = re.compile(r'^(' @@ -146,7 +146,7 @@ def parse_command(ctx: telegram.ext.CallbackContext) -> Optional[dict[str, Union result = {'predicate': htmlEscape(predicate), 'complement': htmlEscape(complement or ''), 'slash': parsed['slash'], - 'swap': parsed['slash'] != '/', + 'swap': parsed['slash'] not in ('/', '/$'), 'omit_le': omit_le} return result @@ -166,7 +166,7 @@ def get_text(user_from: User, user_rpl: User, command: dict): command['slash'], command['predicate'], command['complement'], command['omit_le'] if predicate == '': - ret = '!' if slash == '/' else '¡' + ret = '!' if not command['swap'] else '¡' elif predicate == 'me': ret = f"{mention_from}{bool(complement) * ' '}{complement}" ret += get_tail((complement or user_from.mention(pure=True))[-1])