From 0ca150eec8822ca114bec20ff2a38e0cddc6a956 Mon Sep 17 00:00:00 2001 From: Redume Date: Thu, 9 Jan 2025 00:29:34 +0300 Subject: [PATCH] fix: did a check for negative numbers --- main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 80a3632..a90008a 100644 --- a/main.py +++ b/main.py @@ -39,7 +39,13 @@ async def currency(query: types.InlineQuery) -> None: from_currency, conv_currency = '', '' 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] conv_currency = args[2] elif len(args) == 2: