diff --git a/src/actions/__init__.py b/src/actions/__init__.py index e7d88e2495451cfd15a39f706e98e62ff54cb64a..f348dddaf45ecb5db17972cd1a3067fcce910278 100644 --- a/src/actions/__init__.py +++ b/src/actions/__init__.py @@ -9,4 +9,5 @@ def finish(): importlib.import_module("src.actions.converter") importlib.import_module("src.actions.package_indexes") importlib.import_module("src.actions.search_engines") + importlib.import_module("src.actions.speller") logging.info("All actions loaded") diff --git a/src/actions/converter.py b/src/actions/converter.py index 8bd628ff4be4850fa63d44667fd52fa5a559fcdc..010b778ae1d5dd5feeb18dcf31c13a7575f86a29 100644 --- a/src/actions/converter.py +++ b/src/actions/converter.py @@ -70,6 +70,7 @@ async def replace_currency(event): groups = re.findall(CURRENCY_PATTERN, event.message.message) response = "**ПолагаÑÑÑŒ на текщий ÐºÑƒÑ€Ñ Ð²Ð°Ð»ÑŽÑ‚ могу Ñказать Ñледующее:**\n\n" currency_mapper = [] + inf = float("inf") for group in groups: name = group[3] if name in CURRENCY_MAPPING: @@ -78,7 +79,12 @@ async def replace_currency(event): new_val = val * currencies[name]["Value"] / currencies[name]["Nominal"] val_id = f"{val:.2f} {name}" if val_id not in currency_mapper: - response += f"`{val:.2f} {name} = {new_val:.2f} RUB`\n" + if new_val == inf: + response += ( + f"{val:.2f} {name} = там чиÑло реально огромное, мне лень Ñчитать." + ) + else: + response += f"`{val:.2f} {name} = {new_val:.2f} RUB`\n" currency_mapper.append(val_id) await event.reply(response) diff --git a/src/actions/search_engines.py b/src/actions/search_engines.py index 80dfec8b0be376f3a849fc0d221e84ef93a86f91..1bf7d32a9e99834bfb1a99728ce8358dd2622c10 100644 --- a/src/actions/search_engines.py +++ b/src/actions/search_engines.py @@ -59,4 +59,4 @@ async def search_images(event: events.NewMessage.Event): except Exception as e: logger.warning(e) chat = await event.get_chat() - await config.telegram_client.send_file(chat, images) + await event.client.send_file(chat, images) diff --git a/src/actions/speller.py b/src/actions/speller.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..2ee762b1eabd815e796e0947817ea9fdfb5c2391 100644 --- a/src/actions/speller.py +++ b/src/actions/speller.py @@ -0,0 +1,16 @@ +from src.config import config +from src.utils.responses import mark_unread +from telethon import events + + +@config.telegram_client.on( + events.NewMessage( + pattern=lambda x: not x.endswith(".") and not x.startswith("."), + incoming=False, + forwards=False, + ) +) +@mark_unread +async def add_dot(event: events.NewMessage.Event): + text = event.message.text + await event.message.edit(f"{text}.")