translate to rus
This commit is contained in:
+19
-9
@@ -5,6 +5,14 @@ from typing import Any
|
||||
|
||||
from .utils import bytes_to_human, format_remaining_days, format_timestamp
|
||||
|
||||
STATUS_LABELS = {
|
||||
"active": "активен",
|
||||
"disabled": "отключён",
|
||||
"limited": "лимит исчерпан",
|
||||
"expired": "истёк",
|
||||
"on_hold": "на удержании",
|
||||
}
|
||||
|
||||
|
||||
def generate_invite_token() -> str:
|
||||
return secrets.token_urlsafe(24)
|
||||
@@ -18,26 +26,28 @@ def user_display_name(row: dict[str, Any]) -> str:
|
||||
username = username if username.startswith("@") else f"@{username}"
|
||||
if name and username:
|
||||
return f"{name} ({username})"
|
||||
return name or username or str(row.get("tg_user_id") or "unknown")
|
||||
return name or username or str(row.get("tg_user_id") or "неизвестно")
|
||||
|
||||
|
||||
def format_vpn_info(user: dict[str, Any]) -> str:
|
||||
links = user.get("links") or []
|
||||
subscription_url = user.get("subscription_url")
|
||||
status = user.get("status", "неизвестно")
|
||||
status_text = STATUS_LABELS.get(status, status)
|
||||
lines = [
|
||||
"📄 VPN info",
|
||||
"📄 Информация о VPN",
|
||||
"",
|
||||
f"Username: {user.get('username', 'unknown')}",
|
||||
f"Status: {user.get('status', 'unknown')}",
|
||||
f"Expires: {format_timestamp(user.get('expire'))}",
|
||||
f"Remaining: {format_remaining_days(user.get('expire'))}",
|
||||
f"Traffic: {bytes_to_human(user.get('used_traffic'))} / {bytes_to_human(user.get('data_limit'))}",
|
||||
f"Пользователь: {user.get('username', 'неизвестно')}",
|
||||
f"Статус: {status_text}",
|
||||
f"Действует до: {format_timestamp(user.get('expire'))}",
|
||||
f"Осталось: {format_remaining_days(user.get('expire'))}",
|
||||
f"Трафик: {bytes_to_human(user.get('used_traffic'))} / {bytes_to_human(user.get('data_limit'))}",
|
||||
]
|
||||
if subscription_url:
|
||||
lines.extend(["", "Subscription URL:", str(subscription_url)])
|
||||
lines.extend(["", "Ссылка подписки:", str(subscription_url)])
|
||||
if links:
|
||||
lines.append("")
|
||||
lines.append("Config links:")
|
||||
lines.append("Ссылки конфигурации:")
|
||||
lines.extend(str(link) for link in links)
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user