diff --git a/bot_s3rius/actions/converters/crypto_currency.py b/bot_s3rius/actions/converters/crypto_currency.py index 36eee365c7996ac2fc70e7e9aa7a4ee20dedbee0..365f69e56d6253439cf057c66363b7f329aeb764 100644 --- a/bot_s3rius/actions/converters/crypto_currency.py +++ b/bot_s3rius/actions/converters/crypto_currency.py @@ -8,7 +8,7 @@ from telethon import events from bot_s3rius.config import config from bot_s3rius.utils.converters import get_info_from_group -from bot_s3rius.utils.responses import mark_unread +from bot_s3rius.utils.responses import cur_message, mark_unread logger = logging.getLogger(__name__) @@ -52,6 +52,7 @@ CURRENCY_PATTERN = ( pattern=re.compile(f".*{CURRENCY_PATTERN}.*", re.IGNORECASE | re.DOTALL) ) ) +@cur_message @mark_unread async def replace_crypto_currency(event: events.NewMessage.Event): groups = re.findall(CURRENCY_PATTERN, event.message.message, re.IGNORECASE) @@ -90,6 +91,7 @@ async def replace_crypto_currency(event: events.NewMessage.Event): @config.telegram_client.on(events.NewMessage(pattern="^.scc$")) +@cur_message @mark_unread async def supported_currencies(event): async with httpx.AsyncClient() as client: diff --git a/bot_s3rius/actions/converters/currency.py b/bot_s3rius/actions/converters/currency.py index da1951b9e36616c0ad551dde4a4d625ac74b7f15..06bbe6f1c0fdacc5de2d041a81ee0e9411bce712 100644 --- a/bot_s3rius/actions/converters/currency.py +++ b/bot_s3rius/actions/converters/currency.py @@ -7,7 +7,7 @@ from telethon import events from bot_s3rius.config import config from bot_s3rius.utils.converters import get_info_from_group -from bot_s3rius.utils.responses import mark_unread +from bot_s3rius.utils.responses import cur_message, mark_unread logger = logging.getLogger(__name__) @@ -43,6 +43,11 @@ CURRENCY_MAPPING = { "гривны": "UAH", "гривен": "UAH", "грiвен": "UAH", + "тенге": "KZT", + "Ñ‚Ñнге": "KZT", + "злоты": "PLN", + "лир": "TRY", + "драм": "AMD", } SUPPORTED_CURRENCIES = [ @@ -57,6 +62,10 @@ SUPPORTED_CURRENCIES = [ "CHF", "KRW", "JPY", + "KZT", + "PLN", + "TRY", + "AMD", ] MEMES = { @@ -76,6 +85,7 @@ CURRENCY_PATTERN = ( pattern=re.compile(f".*{CURRENCY_PATTERN}.*", re.IGNORECASE | re.DOTALL) ) ) +@cur_message @mark_unread async def replace_currency(event): async with httpx.AsyncClient() as f: @@ -113,6 +123,7 @@ async def replace_currency(event): @config.telegram_client.on(events.NewMessage(pattern="^.sc$")) +@cur_message @mark_unread async def supported_currencies(event): async with httpx.AsyncClient() as f: diff --git a/bot_s3rius/config.py b/bot_s3rius/config.py index 417c058a87e3314eed90e3dec1307bc868000718..55c5f0613c304ec770404df1675e5f09f67c5a16 100644 --- a/bot_s3rius/config.py +++ b/bot_s3rius/config.py @@ -21,6 +21,7 @@ class Config(BaseSettings): debug_mode: bool = False flask_port: str = Field(name="flask_port", default="8080", env="BOT_FLASK_PORT") excluded_chats: List[str] = Field([], env="BOT_EXCLUDED_CHATS") + cur_excluded_chats: List[str] = Field([], env="CURRECNY_EXCLUDED_CHATS") telegram_client: TelegramClient = None @property diff --git a/bot_s3rius/utils/responses.py b/bot_s3rius/utils/responses.py index 9573c52d20ac4ff44356de0e2620ca257f00cebc..934c6dc748550b6516b0878f32ebe8f88a786cfb 100644 --- a/bot_s3rius/utils/responses.py +++ b/bot_s3rius/utils/responses.py @@ -88,5 +88,17 @@ def danger_message(f): return wrapper +def cur_message(f): + @functools.wraps(f) + async def wrapper(event: events.NewMessage.Event): + chat = await event.get_chat() + if str(chat.id) in set(config.cur_excluded_chats): + logger.debug("Skipping sending message") + return + await f(event) + + return wrapper + + def check_if_only_smiles(message: str): return all([x in ")0." for x in message])