From 5bc5f37723d2cf9426b70c8727ac2bb26a86aa2e Mon Sep 17 00:00:00 2001 From: Redume Date: Sun, 25 Aug 2024 20:01:25 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=B8=D0=B2=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=D1=81=D1=8F=20=D0=BF=D0=BB=D0=B0=D0=B2=D0=B0=D1=8E=D1=89?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=B7=D0=B0=D0=BF=D1=8F=D1=82=D0=B0=D1=8F,=20?= =?UTF-8?q?=D0=B0=20=D0=BD=D0=B5=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20?= =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BA=D0=B0.=20=D0=A4=D0=B8=D0=BA=D1=81=20(?= =?UTF-8?q?=D0=B2=D1=80=D0=BE=D0=B4=D0=B5)=20UnboundLocalError?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index e8d1d7b..ed0e1c9 100644 --- a/main.py +++ b/main.py @@ -73,6 +73,7 @@ async def inline_reply(result_id: str, title: str, description: str or None, inl @dp.inline_query() async def currency(inline_query: types.InlineQuery) -> None: + global result query = inline_query.query args = query.split() @@ -86,7 +87,7 @@ async def currency(inline_query: types.InlineQuery) -> None: f"@shirino_bot USD RUB \n@shirino_bot 12 USD RUB", inline_query) if len(args) == 3: - conv.amount = float(args[0]) + conv.amount = float(args[0].replace(',', '.')) conv.from_currency = args[1].upper() conv.conv_currency = args[2].upper() conv.convert() @@ -108,13 +109,10 @@ async def currency(inline_query: types.InlineQuery) -> None: await asyncio.sleep(1) - except Exception as e: - print(e) + except Exception: await inline_reply(result_id, "Invalid data format", "@shirino_bot USD RUB \n@shirino_bot 12 USD RUB", inline_query) - except UnboundLocalError: - pass await inline_reply(result_id, result, None, inline_query)