From b298b2463cc6d02d25f866e400bf9d1228b54f0e Mon Sep 17 00:00:00 2001 From: Pavel Kirilin <win10@list.ru> Date: Wed, 1 Jul 2020 18:03:18 +0400 Subject: [PATCH] Typos, parentheses. Description: - Fixed typo in converter. - Changed pattern for autoreply. Signed-off-by: Pavel Kirilin <win10@list.ru> --- src/actions/converter.py | 2 +- src/actions/replies.py | 6 ++++-- src/actions/speller.py | 4 +++- src/utils/responses.py | 4 ++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/actions/converter.py b/src/actions/converter.py index 694bc09..745b26f 100644 --- a/src/actions/converter.py +++ b/src/actions/converter.py @@ -72,7 +72,7 @@ async def replace_currency(event): response_json = current_currency.json() currencies = response_json["Valute"] groups = re.findall(CURRENCY_PATTERN, event.message.message) - response = "**ПолагаÑÑÑŒ на текщий ÐºÑƒÑ€Ñ Ð²Ð°Ð»ÑŽÑ‚ могу Ñказать Ñледующее:**\n\n" + response = "**ПолагаÑÑÑŒ на текущий ÐºÑƒÑ€Ñ Ð²Ð°Ð»ÑŽÑ‚ могу Ñказать Ñледующее:**\n\n" currency_mapper = [] for group in groups: scientific = False diff --git a/src/actions/replies.py b/src/actions/replies.py index 1df60a1..165e5b1 100644 --- a/src/actions/replies.py +++ b/src/actions/replies.py @@ -3,7 +3,7 @@ import random import re from src.config import config -from src.utils.responses import mark_unread +from src.utils.responses import check_if_only_smiles, mark_unread from telethon import events logger = logging.getLogger(__name__) @@ -34,7 +34,9 @@ async def hello(event): await event.respond(random.choice(["ЗдравÑтвуте!", "Добрый день!", "ПриветÑтвую."])) -@config.telegram_client.on(events.NewMessage(pattern=r"^\)+\.?$", outgoing=False)) +@config.telegram_client.on( + events.NewMessage(pattern=check_if_only_smiles, outgoing=False) +) @mark_unread async def smile(event: events.NewMessage.Event): await event.respond(event.message.message) diff --git a/src/actions/speller.py b/src/actions/speller.py index 856daa8..db0b093 100644 --- a/src/actions/speller.py +++ b/src/actions/speller.py @@ -8,7 +8,9 @@ def check_missing_dot(message: str): return False if all([x in ")(0" for x in message]): return False - return not message.endswith((".", "?", "!")) and not message.startswith(".") + return not message.endswith((".", ":", ";", "?", "!")) and not message.startswith( + "." + ) def check_spell(message: str): diff --git a/src/utils/responses.py b/src/utils/responses.py index e94d0f0..8da5772 100644 --- a/src/utils/responses.py +++ b/src/utils/responses.py @@ -72,3 +72,7 @@ def mark_unread(f): functions.messages.MarkDialogUnreadRequest(chat, unread=True) return wrapper + + +def check_if_only_smiles(message: str): + return all([x in ")0." for x in message]) -- GitLab