From 6553e4b5ff13eb2ec958a19348a432d1a311ff4d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Apr 2026 12:06:24 +0000 Subject: [PATCH] Fix data limit fallback and narrow traffic parsing exceptions Agent-Logs-Url: https://github.com/kr0sh512/tt-simple/sessions/34c3052e-7b55-4cb8-9fee-0ee1ba315691 Co-authored-by: kr0sh512 <46405586+kr0sh512@users.noreply.github.com> --- bot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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: