65 lines
2.1 KiB
JavaScript
65 lines
2.1 KiB
JavaScript
const axios = require('axios');
|
|
|
|
// Функция для запроса профиля Anixart
|
|
async function getProfileFromAnixart(profileId, token = '') {
|
|
const url = `https://api.anixart.tv/profile/${profileId}${token ? `?token=${token}` : ''}`;
|
|
|
|
try {
|
|
const response = await axios.get(url);
|
|
const profileData = response.data;
|
|
const profileBadgeData = response.data;
|
|
|
|
if (!profileBadgeData.profile.badge) {
|
|
profileBadgeData.profile = {};
|
|
}
|
|
profileBadgeData.profile.badge.id = 6;
|
|
|
|
// Убедимся, что profile существует
|
|
if (!profileData.profile) {
|
|
profileData.profile = {};
|
|
}
|
|
profileData.profile.avatar = "https://64.media.tumblr.com/14e5ee9705bfd7a72e671bd2936921a0/tumblr_ovonr0n6rW1snbyiqo1_540.gif";
|
|
// Проверка верификации
|
|
try {
|
|
const verifiedResponse = await axios.get('https://anixart.seele.su/api/is_verified');
|
|
const verifiedList = verifiedResponse.data;
|
|
|
|
const alreadyVerified = !!profileData.profile.is_verified;
|
|
|
|
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;
|
|
|
|
const userRoles = rolesList.find(entry => entry.id === Number(profileId));
|
|
if (userRoles && Array.isArray(userRoles.roles)) {
|
|
profileData.profile.roles = userRoles.roles;
|
|
}
|
|
} catch {
|
|
// Ошибку загрузки ролей игнорируем
|
|
}
|
|
|
|
return profileData;
|
|
} catch {
|
|
return {
|
|
code: 2,
|
|
profile: null,
|
|
is_my_profile: false,
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = { getProfileFromAnixart };
|
|
|