diff --git a/bot.py b/bot.py index 776b056..cee5805 100644 --- a/bot.py +++ b/bot.py @@ -4,7 +4,7 @@ import logging import os from dataclasses import dataclass from datetime import datetime, timezone -from decimal import Decimal, ROUND_HALF_UP +from decimal import Decimal, ROUND_HALF_UP, InvalidOperation from typing import Any import aiohttp @@ -399,7 +399,7 @@ class VpnBot: action = "extended" expire_at = add_months(expire_from, months) - data_limit = int(current.get("data_limit") or 50 * GB) if current else 50 * GB + data_limit = int(current.get("data_limit", 50 * GB)) if current else 50 * GB data_limit_reset_strategy = ( current.get("data_limit_reset_strategy") or "month" ) if current else "month" @@ -552,7 +552,7 @@ class VpnBot: return try: gb_value = Decimal(arg) - except Exception: + except (ValueError, InvalidOperation): await message.answer("Invalid value. Example: /set_traffic 75") return if gb_value <= 0: