support for remnawave api 2.x

This commit is contained in:
Vladless
2025-07-30 20:02:40 +03:00
parent b59b3f0e53
commit 3aa7b1edc5
5 changed files with 22 additions and 24 deletions
+13 -15
View File
@@ -208,8 +208,8 @@ async def handle_subscription_url_input(message: Message, state: FSMContext):
await state.update_data(subscription_url=subscription_url)
await message.answer(
text=f"<b>Введите inbound_id для сервера {server_name} в кластере {cluster_name}:</b>\n\n"
f"Для Remnawave это UUID Инбаунда, для 3x-ui — просто ID (например, <code>1</code>).",
text=f"<b>Введите inbound_id/Squads для сервера {server_name} в кластере {cluster_name}:</b>\n\n"
f"Для Remnawave это UUID Squads, для 3x-ui — просто ID (например, <code>1</code>).",
reply_markup=build_admin_back_kb("clusters"),
)
await state.set_state(AdminClusterStates.waiting_for_inbound_id)
@@ -393,21 +393,19 @@ async def handle_cluster_availability(
total_online_users += online_remna_users
nodes_info = nodes_data["nodes"]
if len(nodes_info) > 1:
result_text += f"🌍 <b>{prefix} {server_name}</b> - {online_remna_users} онлайн\n"
for node_info in nodes_info:
country_code = node_info.get("country_code", "Unknown")
node_name = node_info.get("name", "Unknown")
online_users = node_info.get("online_users", 0)
result_text += f"🌍 <b>{prefix} {server_name}</b> - {online_remna_users} онлайн\n"
seen = set()
for node_info in nodes_info:
node_name = node_info.get("name", "Unknown")
if node_name in seen:
continue
seen.add(node_name)
if country_code != "Unknown" and len(country_code) == 2:
flag = "".join(chr(ord(c) + 127397) for c in country_code.upper())
else:
flag = country_code
country_code = node_info.get("country_code", "Unknown")
online_users = node_info.get("online_users", 0)
result_text += f"{flag} ({node_name}): {online_users} онлайн\n"
else:
result_text += f"🌍 <b>{prefix} {server_name}</b> - {online_remna_users} онлайн\n"
flag = "".join(chr(ord(c) + 127397) for c in country_code.upper()) if country_code != "Unknown" and len(country_code) == 2 else country_code
result_text += f"{flag} ({node_name}): {online_users} онлайн\n"
except Exception as e:
error_text = str(e) or "Сервер недоступен"
+1 -1
View File
@@ -63,7 +63,7 @@ def build_edit_server_fields_kb(server_name: str, server_data: dict) -> InlineKe
)
)
builder.row(InlineKeyboardButton(text="🔑 Inbound ID", callback_data=f"edit_server_field|{server_name}|inbound_id"))
builder.row(InlineKeyboardButton(text="🔑 Inbound ID/Squads", callback_data=f"edit_server_field|{server_name}|inbound_id"))
builder.row(InlineKeyboardButton(text="⚙️ Тип панели", callback_data=f"select_panel_type|{server_name}"))
+5 -5
View File
@@ -77,7 +77,7 @@ async def handle_server_manage(
text += f"🌐 Subscription URL: <b>{subscription_url}</b>\n"
text += (
f"🔑 Inbound ID: <b>{inbound_id}</b>\n"
f"🔑 Inbound ID/Squads: <b>{inbound_id}</b>\n"
f"⚙️ Тип панели: <b>{panel_type}</b>\n"
f"📈 Лимит ключей: <b>{limit_display}</b>\n"
)
@@ -258,7 +258,7 @@ async def toggle_server_enabled(
f"<b>🔧 Информация о сервере {server_name}:</b>\n\n"
f"<b>📡 API URL:</b> {server['api_url']}\n"
f"<b>🌐 Subscription URL:</b> {server['subscription_url']}\n"
f"<b>🔑 Inbound ID:</b> {server['inbound_id']}\n"
f"<b>🔑 Inbound ID/Squads:</b> {server['inbound_id']}\n"
f"<b>📈 Лимит ключей:</b> {limit_display}"
)
@@ -311,7 +311,7 @@ async def save_server_limit(message: types.Message, state: FSMContext, session:
f"<b>🔧 Информация о сервере {server_name}:</b>\n\n"
f"<b>📡 API URL:</b> {server['api_url']}\n"
f"<b>🌐 Subscription URL:</b> {server['subscription_url']}\n"
f"<b>🔑 Inbound ID:</b> {server['inbound_id']}\n"
f"<b>🔑 Inbound ID/Squads:</b> {server['inbound_id']}\n"
f"<b>📈 Лимит ключей:</b> {limit_display}"
)
@@ -361,7 +361,7 @@ async def ask_new_field_value(callback: CallbackQuery, state: FSMContext, sessio
"server_name": "имя сервера",
"api_url": "API URL",
"subscription_url": "Subscription URL",
"inbound_id": "Inbound ID",
"inbound_id": "Inbound ID/Squads",
}
await callback.message.edit_text(
@@ -438,7 +438,7 @@ async def apply_field_edit(message: types.Message, state: FSMContext, session: A
"server_name": "имя сервера",
"api_url": "API URL",
"subscription_url": "Subscription URL",
"inbound_id": "Inbound ID",
"inbound_id": "Inbound ID/Squads",
}
await message.answer(
+3 -3
View File
@@ -108,7 +108,7 @@ async def create_key_on_cluster(
"trafficLimitStrategy": "NO_RESET",
"expireAt": expire_at,
"telegramId": tg_id,
"activeUserInbounds": inbound_ids,
"activeInternalSquads": inbound_ids,
}
if traffic_limit_bytes and traffic_limit_bytes > 0:
@@ -352,7 +352,7 @@ async def renew_key_in_cluster(
"trafficLimitStrategy": "NO_RESET",
"expireAt": expire_iso,
"telegramId": tg_id,
"activeUserInbounds": remnawave_inbound_ids,
"activeInternalSquads": remnawave_inbound_ids,
}
if remnawave_link and "/" in remnawave_link:
user_data["shortUuid"] = remnawave_link.rstrip("/").split("/")[-1]
@@ -567,7 +567,7 @@ async def update_key_on_cluster(
"trafficLimitStrategy": "NO_RESET",
"expireAt": expire_iso,
"telegramId": tg_id,
"activeUserInbounds": inbound_ids,
"activeInternalSquads": inbound_ids,
}
if traffic_limit is not None:
user_data["trafficLimitBytes"] = traffic_limit * 1024**3
Binary file not shown.