From f13ff07de736884beabef740bd2c250d3fd1867a Mon Sep 17 00:00:00 2001 From: Redume Date: Sun, 31 Dec 2023 13:26:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D1=83=D1=81=D0=BB=D0=BE=D0=B2=D0=B8=D1=8F=20=D0=B5=D1=89=D0=B5?= =?UTF-8?q?=20=D1=87=D0=B5=20=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 83e222a..dbd9658 100644 --- a/main.py +++ b/main.py @@ -183,6 +183,22 @@ async def currency(inline_query: types.InlineQuery) -> None: conv = CurrencyConverter() try: + log.debug(len(args)) + if len(args) <= 1: + article[0] = types.InlineQueryResultArticle( + id=result_id, + title="Требуется 2, либо 3 аргумента", + description=f"@shirino_bot USD RUB \n@shirino_bot 12 USD RUB", + input_message_content=types.InputTextMessageContent( + message_text="Требуется 2, либо 3 аргумента" + ) + ) + + await inline_query.answer( + article, + cache_time=1, + is_personal=True, + ) if len(args) == 3: conv.amount = float(args[0]) conv.from_currency = args[1].upper() @@ -192,8 +208,6 @@ async def currency(inline_query: types.InlineQuery) -> None: conv.from_currency = args[0].upper() conv.conv_currency = args[1].upper() conv.convert() - else: - raise ValueError('Надо 2 или 3 аргумента') result = ( f'{conv.amount} {conv.from_currency} = '