fix: telemt -v -> --version, CSV header skip in bot stats

This commit is contained in:
anten-ka
2026-04-12 08:09:03 +03:00
parent 7075ff8696
commit 4fec096676

View File

@@ -389,7 +389,7 @@ async def check_service_status(service: str) -> bool:
async def get_telemt_version() -> str: async def get_telemt_version() -> str:
"""Get telemt version.""" """Get telemt version."""
code, stdout, _ = await sh("telemt", "-v") code, stdout, _ = await sh("telemt", "--version")
if code == 0: if code == 0:
return stdout.strip().split()[-1] if stdout else "unknown" return stdout.strip().split()[-1] if stdout else "unknown"
return "unknown" return "unknown"
@@ -699,18 +699,21 @@ async def get_traffic_stats(user_id: Optional[int] = None) -> str:
except Exception: except Exception:
return f"📊 <b>{_t(user_id, 'stats_title', 'Statistics')}</b>\n\n<i>{_t(user_id, 'stats_unavailable', 'Data unavailable. Make sure stats module is enabled.')}</i>" return f"📊 <b>{_t(user_id, 'stats_title', 'Statistics')}</b>\n\n<i>{_t(user_id, 'stats_unavailable', 'Data unavailable. Make sure stats module is enabled.')}</i>"
# Read history # Read history (skip header and non-numeric rows)
history = [] history = []
try: try:
with open(history_file, "r") as f: with open(history_file, "r") as f:
reader = csv.reader(f) reader = csv.reader(f)
for row in reader: for row in reader:
if len(row) >= 3: if len(row) >= 3:
history.append({ try:
"ts": int(row[0]), history.append({
"proxy": int(row[1]), "ts": int(row[0]),
"site": int(row[2]), "proxy": int(row[1]),
}) "site": int(row[2]),
})
except (ValueError, TypeError):
continue # skip header or malformed rows
except Exception: except Exception:
pass pass