mirror of
https://github.com/Redume/Shirino.git
synced 2025-02-04 09:58:57 +03:00
fix: Fixed conditions with negative numbers and if text is written instead of number
This commit is contained in:
parent
0ca150eec8
commit
0537bfe3cf
1 changed files with 14 additions and 9 deletions
23
main.py
23
main.py
|
@ -25,14 +25,15 @@ async def currency(query: types.InlineQuery) -> None:
|
||||||
args = text.split()
|
args = text.split()
|
||||||
result_id = hashlib.md5(text.encode()).hexdigest()
|
result_id = hashlib.md5(text.encode()).hexdigest()
|
||||||
|
|
||||||
|
get_bot = await bot.get_me()
|
||||||
|
|
||||||
if len(args) < 2:
|
if len(args) < 2:
|
||||||
get_bot = await bot.get_me()
|
return await reply(result_id,
|
||||||
return await reply(result_id,
|
[("2 or 3 arguments are required.",
|
||||||
[("2 or 3 arguments are required.",
|
f'@{get_bot.username} USD RUB \n'
|
||||||
f'@{get_bot.username} USD RUB \n'
|
f'@{get_bot.username} 12 USD RUB',
|
||||||
f'@{get_bot.username} 12 USD RUB',
|
None, None)],
|
||||||
None, None)],
|
query)
|
||||||
query)
|
|
||||||
|
|
||||||
conv = Converter()
|
conv = Converter()
|
||||||
|
|
||||||
|
@ -42,9 +43,13 @@ async def currency(query: types.InlineQuery) -> None:
|
||||||
try:
|
try:
|
||||||
conv.amount = float(args[0].replace(',', '.'))
|
conv.amount = float(args[0].replace(',', '.'))
|
||||||
if conv.amount < 0:
|
if conv.amount < 0:
|
||||||
raise ValueError("Negative amounts are not supported.")
|
return await reply(result_id, [("Negative amounts are not supported.", None, None)], query)
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return await reply(result_id, [("Please enter a positive amount.", None, None)], query)
|
return await reply(result_id, [("Please enter a valid number for the amount.",
|
||||||
|
f'@{get_bot.username} USD RUB \n'
|
||||||
|
f'@{get_bot.username} 12 USD RUB',
|
||||||
|
None, None)], query)
|
||||||
|
|
||||||
from_currency = args[1]
|
from_currency = args[1]
|
||||||
conv_currency = args[2]
|
conv_currency = args[2]
|
||||||
|
|
Loading…
Add table
Reference in a new issue