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
11
main.py
11
main.py
|
@ -25,8 +25,9 @@ async def currency(query: types.InlineQuery) -> None:
|
|||
args = text.split()
|
||||
result_id = hashlib.md5(text.encode()).hexdigest()
|
||||
|
||||
if len(args) < 2:
|
||||
get_bot = await bot.get_me()
|
||||
|
||||
if len(args) < 2:
|
||||
return await reply(result_id,
|
||||
[("2 or 3 arguments are required.",
|
||||
f'@{get_bot.username} USD RUB \n'
|
||||
|
@ -42,9 +43,13 @@ async def currency(query: types.InlineQuery) -> None:
|
|||
try:
|
||||
conv.amount = float(args[0].replace(',', '.'))
|
||||
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:
|
||||
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]
|
||||
conv_currency = args[2]
|
||||
|
|
Loading…
Add table
Reference in a new issue