fix change locations/ delete update_subscription_button/ refactoring the deletion function
This commit is contained in:
@@ -32,7 +32,6 @@ from database import (
|
||||
check_user_exists,
|
||||
filter_cluster_by_subgroup,
|
||||
get_key_details,
|
||||
get_servers,
|
||||
get_tariff_by_id,
|
||||
get_trial,
|
||||
update_balance,
|
||||
@@ -508,9 +507,15 @@ async def finalize_key_creation(
|
||||
is_trial=is_trial,
|
||||
)
|
||||
|
||||
servers_map = await get_servers(session=session, include_enabled=True)
|
||||
cluster_all = servers_map.get(cluster_name, [])
|
||||
subgroup_code = tariff.subgroup_title if tariff and tariff.subgroup_title else None
|
||||
cluster_all = [{
|
||||
"server_name": server_info.server_name,
|
||||
"api_url": server_info.api_url,
|
||||
"panel_type": server_info.panel_type,
|
||||
"inbound_id": getattr(server_info, "inbound_id", None),
|
||||
"enabled": True,
|
||||
"max_keys": getattr(server_info, "max_keys", None),
|
||||
}]
|
||||
|
||||
link_to_show = await make_aggregated_link(
|
||||
session=session,
|
||||
@@ -568,13 +573,17 @@ async def finalize_key_creation(
|
||||
builder = InlineKeyboardBuilder()
|
||||
is_full_remnawave = await is_full_remnawave_cluster(cluster_name, session)
|
||||
is_vless = bool(public_link and public_link.lower().startswith("vless://")) or bool(need_vless_key)
|
||||
final_link = public_link or remnawave_link
|
||||
webapp_url = final_link if isinstance(final_link, str) and final_link.strip().lower().startswith(("http://", "https://")) else None
|
||||
|
||||
if panel_type == "remnawave" or is_full_remnawave:
|
||||
if is_vless:
|
||||
builder.row(InlineKeyboardButton(text=ROUTER_BUTTON, callback_data=f"connect_router|{key_name}"))
|
||||
else:
|
||||
if REMNAWAVE_WEBAPP:
|
||||
builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, web_app=WebAppInfo(url=REMNAWAVE_WEBAPP)))
|
||||
if REMNAWAVE_WEBAPP and webapp_url:
|
||||
builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, web_app=WebAppInfo(url=webapp_url)))
|
||||
else:
|
||||
builder.row(InlineKeyboardButton(text=CONNECT_DEVICE, callback_data=f"connect_device|{key_name}"))
|
||||
builder.row(InlineKeyboardButton(text=TV_BUTTON, callback_data=f"connect_tv|{email}"))
|
||||
elif CONNECT_PHONE_BUTTON:
|
||||
builder.row(InlineKeyboardButton(text=CONNECT_PHONE, callback_data=f"connect_phone|{key_name}"))
|
||||
|
||||
@@ -19,7 +19,6 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from config import (
|
||||
CONNECT_PHONE_BUTTON,
|
||||
ENABLE_DELETE_KEY_BUTTON,
|
||||
ENABLE_UPDATE_SUBSCRIPTION_BUTTON,
|
||||
HAPP_CRYPTOLINK,
|
||||
HWID_RESET_BUTTON,
|
||||
QRCODE,
|
||||
@@ -44,7 +43,6 @@ from handlers.buttons import (
|
||||
PC_BUTTON,
|
||||
QR,
|
||||
RENEW_KEY,
|
||||
RENEW_SUB,
|
||||
ROUTER_BUTTON,
|
||||
TV_BUTTON,
|
||||
UNFREEZE,
|
||||
@@ -316,9 +314,6 @@ async def render_key_info(message: Message, session: Any, key_name: str, image_p
|
||||
remna_used_gb=remna_used_gb,
|
||||
)
|
||||
|
||||
if ENABLE_UPDATE_SUBSCRIPTION_BUTTON:
|
||||
builder.row(InlineKeyboardButton(text=RENEW_SUB, callback_data=f"update_subscription|{key_name}"))
|
||||
|
||||
if is_full_remnawave and final_link and REMNAWAVE_WEBAPP and not HAPP_CRYPTOLINK:
|
||||
if vless_enabled:
|
||||
builder.row(InlineKeyboardButton(text=ROUTER_BUTTON, callback_data=f"connect_router|{key_name}"))
|
||||
|
||||
@@ -34,37 +34,11 @@ async def delete_key_from_cluster(cluster_id: str, email: str, client_id: str, s
|
||||
remna_servers = [s for s in cluster if s.get("panel_type", "3x-ui").lower() == "remnawave"]
|
||||
xui_servers = [s for s in cluster if s.get("panel_type", "3x-ui").lower() == "3x-ui"]
|
||||
|
||||
remna_servers = unique_by_api_url(remna_servers)
|
||||
|
||||
for server_info in remna_servers:
|
||||
server_name = server_info.get("server_name", "unknown")
|
||||
remna = RemnawaveAPI(server_info["api_url"])
|
||||
if not await remna.login(REMNAWAVE_LOGIN, REMNAWAVE_PASSWORD):
|
||||
logger.error(f"{PANEL_REMNA} Не удалось войти на сервер {server_name}")
|
||||
continue
|
||||
success = await remna.delete_user(client_id)
|
||||
if success:
|
||||
logger.info(f"{PANEL_REMNA} Клиент {client_id} удалён с {server_name}")
|
||||
else:
|
||||
logger.warning(f"{PANEL_REMNA} Не удалось удалить клиента {client_id} с {server_name}")
|
||||
|
||||
for server_info in xui_servers:
|
||||
server_name = server_info.get("server_name", "unknown")
|
||||
inbound_id = server_info.get("inbound_id")
|
||||
if not inbound_id:
|
||||
logger.warning(f"{PANEL_XUI} INBOUND_ID отсутствует на сервере {server_name}. Пропуск.")
|
||||
continue
|
||||
try:
|
||||
xui = await get_xui_instance(server_info["api_url"])
|
||||
except Exception as e:
|
||||
logger.warning(f"{PANEL_XUI} [{server_name}] недоступна панель 3x-ui при удалении: {e}")
|
||||
continue
|
||||
await delete_client(
|
||||
xui=xui,
|
||||
inbound_id=int(inbound_id),
|
||||
email=email,
|
||||
client_id=client_id,
|
||||
)
|
||||
await asyncio.gather(
|
||||
delete_on_3xui(xui_servers, email, client_id),
|
||||
delete_on_remnawave(remna_servers, client_id),
|
||||
return_exceptions=True,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Ошибка при удалении ключа {client_id} из кластера/сервера {cluster_id}: {e}")
|
||||
|
||||
+4
-2
@@ -227,13 +227,15 @@ async def show_start_menu(
|
||||
snap = await get_user_snapshot(session, message.chat.id)
|
||||
if snap is None:
|
||||
trial_status = 0
|
||||
key_cnt = 0
|
||||
else:
|
||||
trial_status, key_cnt = snap
|
||||
else:
|
||||
trial_status = trial
|
||||
key_cnt = key_count or 0
|
||||
|
||||
show_trial = (trial_status in (-1, 0)) and (not TRIAL_TIME_DISABLE)
|
||||
show_profile = ((not SHOW_START_MENU_ONCE) or (trial_status not in (-1, 0)) or TRIAL_TIME_DISABLE) and (not show_trial)
|
||||
show_trial = (trial_status in (-1, 0)) and (not TRIAL_TIME_DISABLE) and (key_cnt == 0)
|
||||
show_profile = (key_cnt > 0) or (((not SHOW_START_MENU_ONCE) or (trial_status not in (-1, 0)) or TRIAL_TIME_DISABLE) and (not show_trial))
|
||||
|
||||
if show_trial:
|
||||
kb.row(InlineKeyboardButton(text=TRIAL_SUB, callback_data="create_key"))
|
||||
|
||||
Reference in New Issue
Block a user