mirror of
https://github.com/Redume/Shirino.git
synced 2024-11-22 00:06:22 +03:00
Теперь поддерживается плавающая запятая, а не только точка. Фикс (вроде) UnboundLocalError
This commit is contained in:
parent
46a1ecdbf8
commit
5bc5f37723
1 changed files with 3 additions and 5 deletions
8
main.py
8
main.py
|
@ -73,6 +73,7 @@ async def inline_reply(result_id: str, title: str, description: str or None, inl
|
||||||
|
|
||||||
@dp.inline_query()
|
@dp.inline_query()
|
||||||
async def currency(inline_query: types.InlineQuery) -> None:
|
async def currency(inline_query: types.InlineQuery) -> None:
|
||||||
|
global result
|
||||||
query = inline_query.query
|
query = inline_query.query
|
||||||
args = query.split()
|
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)
|
f"@shirino_bot USD RUB \n@shirino_bot 12 USD RUB", inline_query)
|
||||||
|
|
||||||
if len(args) == 3:
|
if len(args) == 3:
|
||||||
conv.amount = float(args[0])
|
conv.amount = float(args[0].replace(',', '.'))
|
||||||
conv.from_currency = args[1].upper()
|
conv.from_currency = args[1].upper()
|
||||||
conv.conv_currency = args[2].upper()
|
conv.conv_currency = args[2].upper()
|
||||||
conv.convert()
|
conv.convert()
|
||||||
|
@ -108,13 +109,10 @@ async def currency(inline_query: types.InlineQuery) -> None:
|
||||||
|
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print(e)
|
|
||||||
await inline_reply(result_id, "Invalid data format",
|
await inline_reply(result_id, "Invalid data format",
|
||||||
"@shirino_bot USD RUB \n@shirino_bot 12 USD RUB",
|
"@shirino_bot USD RUB \n@shirino_bot 12 USD RUB",
|
||||||
inline_query)
|
inline_query)
|
||||||
except UnboundLocalError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
await inline_reply(result_id, result, None, inline_query)
|
await inline_reply(result_id, result, None, inline_query)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue