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>
This commit is contained in:
co-authored by
kr0sh512
parent
7da7b95e8b
commit
6553e4b5ff
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user