fix: did a check for negative numbers

This commit is contained in:
Данил 2025-01-09 00:29:34 +03:00
parent a1ad2d1694
commit 0ca150eec8

View file

@ -39,7 +39,13 @@ async def currency(query: types.InlineQuery) -> None:
from_currency, conv_currency = '', '' from_currency, conv_currency = '', ''
if len(args) == 3: if len(args) == 3:
conv.amount = float(args[0].replace(',', '.')) try:
conv.amount = float(args[0].replace(',', '.'))
if conv.amount < 0:
raise ValueError("Negative amounts are not supported.")
except ValueError:
return await reply(result_id, [("Please enter a positive amount.", None, None)], query)
from_currency = args[1] from_currency = args[1]
conv_currency = args[2] conv_currency = args[2]
elif len(args) == 2: elif len(args) == 2: