feat(bot): implement HWID device list and deletion
This commit is contained in:
@@ -3,6 +3,8 @@ import urllib.parse
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from random import choice
|
||||
|
||||
from remnawave.models.hwid import HwidDeviceDto
|
||||
|
||||
from bot import texts
|
||||
from config import settings
|
||||
from schemas.subscriptions import InternalSquads, SubscriptionDuration, SubscriptionPlan
|
||||
@@ -271,3 +273,25 @@ def is_same_plan(rw_user: RWUserInfo, new_plan: SubscriptionPlan) -> bool:
|
||||
active_squad_uuids = {squad["uuid"] for squad in rw_user.active_squads}
|
||||
current_has_whitelist = InternalSquads.WHITELISTS in active_squad_uuids
|
||||
return current_has_whitelist == new_plan.whitelists
|
||||
|
||||
|
||||
def _format_os_emoji(os: str) -> str:
|
||||
os = os.lower()
|
||||
if os == "windows":
|
||||
return texts.WINDOWS
|
||||
if os == "linux":
|
||||
return texts.LINUX
|
||||
if os == "ios":
|
||||
return texts.APPLE
|
||||
if os == "android":
|
||||
return texts.ANDROID
|
||||
return texts.UNKNOWN_OS
|
||||
|
||||
|
||||
def format_hwid_device(device: HwidDeviceDto) -> str:
|
||||
os = device.platform
|
||||
model = device.device_model
|
||||
client = device.user_agent.split("/")[0]
|
||||
emoji = _format_os_emoji(os)
|
||||
|
||||
return f"{emoji} {os} | {model} | {client}"
|
||||
|
||||
Reference in New Issue
Block a user