From 5b79f6699b22a9faef15893554a3dcd0157f8256 Mon Sep 17 00:00:00 2001 From: Redume Date: Thu, 26 Sep 2024 16:09:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=84=D0=B8=D0=BA=D1=81=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B1=D0=B0=D0=B3.=20=D0=95=D1=81=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D1=82=D1=8C=20=D1=82=D0=B5?= =?UTF-8?q?=D0=BA=D1=81=D1=82=20=D0=BD=D0=B5=20=D0=BE=D1=82=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=8F=D1=89=D0=B8=D0=B9=D1=81=D1=8F=20=D0=BA=20=D0=B2?= =?UTF-8?q?=D0=B0=D0=BB=D1=8E=D1=82=D0=B5,=20=D1=82=D0=BE=20=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=20=D0=B1=D1=83=D0=B4=D0=B5=D1=82=20=D0=B8=D0=B3=D0=BD?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index a5f3434..2ee56f0 100644 --- a/main.py +++ b/main.py @@ -16,7 +16,7 @@ dp = Dispatcher() @dp.message() @dp.inline_query() async def currency(query: types.Message | types.InlineQuery) -> None: - global result + global result, from_currency_alias, conv_currency_alias try: currency_json = json.load(open('currency.json', 'r', encoding='utf-8')) @@ -26,11 +26,12 @@ async def currency(query: types.Message | types.InlineQuery) -> None: conv = Converter() if len(args) <= 1: - return await reply(result_id, - "2 or 3 arguments are required.", - "@shirino_bot USD RUB " - "\n@shirino_bot 12 USD RUB", - query) + if query.chat.type not in ['supergroup', 'group']: + return await reply(result_id, + "2 or 3 arguments are required.", + "@shirino_bot USD RUB " + "\n@shirino_bot 12 USD RUB", + query) if len(args) == 4: conv.amount = float(args[0]) from_currency_alias = args[1].lower() @@ -43,7 +44,8 @@ async def currency(query: types.Message | types.InlineQuery) -> None: from_currency_alias = args[0].lower() conv_currency_alias = args[1].lower() else: - return await reply(result_id, 'The source and target currency could not be determined.', None, query) + if query.chat.type not in ['supergroup', 'group']: + return await reply(result_id, 'The source and target currency could not be determined.', None, query) from_currency, conv_currency = None, None