AnixartBot/utils/keyboards.js
2022-08-10 13:06:23 +02:00

521 lines
18 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const functions = require('../utils/functions');
const modelUser = require('../models/user');
exports.profileKeyboard = async (fromId, profile) => { // /profile
let keyboard = {
inline_keyboard: [
[
{
text: `🔶 Открыть профиль в Anixart`,
url: `https://anixart.tv/profile/${profile.id}`
}
],
[
{
text: '📺 Аниме в закладках',
callback_data: `${fromId};userAnimeMenu;${profile.id}`
}
]
]
}
let user = await modelUser.findOne({ _id: fromId })
if (user && user.anixartId != profile.id) {
keyboard.inline_keyboard.push([{
text: '↩️ Назад к своему профилю',
callback_data: `${fromId};profile;${user.anixartId}`
}])
}
return keyboard
};
exports.userAnimeMenuKeyboard = async (fromId, profile) => { //Меню аниме в /profile
let keyboard = {
inline_keyboard: [
[
{
text: `🟩 Смотрю: ${profile.watching_count}`,
callback_data: `${fromId};userAnimeList;1;1;0;${profile.id}` // {user id}, {callback command}, {list type}, {new page}, {this page}, {anixart id}
},
{
text: `🟪 В планах: ${profile.plan_count}`,
callback_data: `${fromId};userAnimeList;2;1;0;${profile.id}`
}
],
[
{
text: `🟦 Просмотрено: ${profile.completed_count}`,
callback_data: `${fromId};userAnimeList;3;1;0;${profile.id}`
}
],
[
{
text: `🟨 Отложено: ${profile.hold_on_count}`,
callback_data: `${fromId};userAnimeList;4;1;0;${profile.id}`
},
{
text: `🟥 Брошено: ${profile.dropped_count}`,
callback_data: `${fromId};userAnimeList;5;1;0;${profile.id}`
}
],
[
{
text: '⬅️ Назад к профилю',
callback_data: `${fromId};profile;${profile.id}`
}
]
]
}
return keyboard
};
exports.userAnimePages = async (fromId, listType, page, maxPage, animeList, profile) => { //Страницы аниме в /profile
let keyboard = {
inline_keyboard: [
[
{
text: `${animeList[0] ? functions.getNumberEmoji(animeList[0].count) : ``}`,
callback_data: `${fromId};userCheckAnime;${listType};${page};${animeList[0] ? animeList[0].id : "none"};${profile.id}` // {user id}, {callback command}, {list type}, {page}
},
{
text: `${animeList[1] ? functions.getNumberEmoji(animeList[1].count) : ``}`,
callback_data: `${fromId};userCheckAnime;${listType};${page};${animeList[1] ? animeList[1].id : "none"};${profile.id}`
},
{
text: `${animeList[2] ? functions.getNumberEmoji(animeList[2].count) : ``}`,
callback_data: `${fromId};userCheckAnime;${listType};${page};${animeList[2] ? animeList[2].id : "none"};${profile.id}`
},
{
text: `${animeList[3] ? functions.getNumberEmoji(animeList[3].count) : ``}`,
callback_data: `${fromId};userCheckAnime;${listType};${page};${animeList[3] ? animeList[3].id : "none"};${profile.id}`
},
{
text: `${animeList[4] ? functions.getNumberEmoji(animeList[4].count) : ``}`,
callback_data: `${fromId};userCheckAnime;${listType};${page};${animeList[4] ? animeList[4].id : "none"};${profile.id}`
}
],
[
{
text: ``,
callback_data: `${fromId};userAnimeList;${listType};1;${page};${profile.id}`
},
{
text: `◀️`,
callback_data: `${fromId};userAnimeList;${listType};${page-1};${page};${profile.id}`
},
{
text: `▶️`,
callback_data: `${fromId};userAnimeList;${listType};${page+1};${page};${profile.id}`
},
{
text: ``,
callback_data: `${fromId};userAnimeList;${listType};${maxPage};${page};${profile.id}`
}
],
[
{
text: `🔙 Назад к категориям`,
callback_data: `${fromId};userAnimeMenu;${profile.id}`
},
{
text: `↩️ Назад к профилю`,
callback_data: `${fromId};profile;${profile.id}`
}
]
]
}
return keyboard
};
exports.animeCheckHistory = async (fromId, listType, page, animeId, profile) => { //Посмотреть аниме в /profile
let keyboard = {
inline_keyboard: [
[
{
text: `⏸ Открыть аниме в Anixart`,
url: `https://anixart.tv/release/${animeId}`
}
],
[
{
text: `⬅️ Назад к списку`,
callback_data: `${fromId};userAnimeList;${listType};${page};0;${profile.id}` // {user id}, {callback command}, {list type}, {page}, {anixart.id}
}
],
[
{
text: `🔙 Назад к категориям`,
callback_data: `${fromId};userAnimeMenu;${profile.id}`
}
],
[
{
text: `↩️ Назад к профилю`,
callback_data: `${fromId};profile;${profile.id}`
}
]
]
}
return keyboard
};
exports.authMenu = async (fromId) => { // /account
let keyboard = {
inline_keyboard: [
[
{
text: `1⃣ Ник`,
callback_data: `${fromId};auth;nickname`
},
{
text: `2⃣ Айди`,
callback_data: `${fromId};auth;id`
}
]
]
}
return keyboard
};
exports.authBack = async (fromId) => { //Кнопки в /account (назад)
let keyboard = {
inline_keyboard: [
[
{
text: `🔙 Назад к выбору`,
callback_data: `${fromId};authMenu`
}
]
]
}
return keyboard
}
exports.authConfirm = async (fromId, anixartId, anixartLogin) => { //Подтверждение авторизации
let keyboard = {
inline_keyboard: [
[
{
text: `✅ Подтвердить`,
callback_data: `${fromId};authConfirm;${anixartId};${anixartLogin}`
}
],
[
{
text: `❌ Отклонить`,
callback_data: `${fromId};deleteMessage`
}
]
]
}
return keyboard
}
exports.animeMenu = async (fromId) => { // /anime
let keyboard = {
inline_keyboard: [
[
{
text: `🆕 Последнее`,
callback_data: `${fromId};animeList;0;1;0` //{user id}, {callback command}, {anime type}, {newpage}, {page}
},
{
text: `📈 Популярное`,
callback_data: `${fromId};animeList;1;1;0`
}
],
[
{
text: `🔥 Интересное`,
callback_data: `${fromId};interesting;1;0`
},
{
text: `❓ Случайное аниме`,
callback_data: `${fromId};animeRandom`
}
],
[
{
text: `🔎 Поиск аниме`,
callback_data: `${fromId};searchAnimeMenu`
}
]
]
}
return keyboard
}
exports.animeCheck = async (fromId, animeType, page, animeId) => { //Инфа об аниме в команде /anime
let keyboard = {
inline_keyboard: [
[
{
text: `⏸ Открыть аниме в Anixart`,
url: `https://anixart.tv/release/${animeId}`
}
],
[
{
text: `⬅️ Назад к списку`,
callback_data: `${fromId};animeList;${animeType};${page};0;` //{user id}, {callback command}, {anime type}, {newpage}, {page}
}
],
[
{
text: `🔙 Назад к меню аниме`,
callback_data: `${fromId};animeMenu`
}
]
]
}
return keyboard
};
exports.animeRandom = async (fromId, animeId) => { //Случайное аниме
let keyboard = {
inline_keyboard: [
[
{
text: `⏸ Открыть аниме в Anixart`,
url: `https://anixart.tv/release/${animeId}`
}
],
[
{
text: `🔙 Назад к категориям`,
callback_data: `${fromId};animeMenu`
}
],
[
{
text: `❓ Найти другое случайное`,
callback_data: `${fromId};animeRandom`
}
]
]
}
return keyboard
};
exports.animePages = async (fromId, animeType, maxPage, page, animeList) => { //Страницы в популярном, интересном
let keyboard = {
inline_keyboard: [
[
{
text: `${animeList[0] ? functions.getNumberEmoji(animeList[0].count) : ``}`,
callback_data: `${fromId};checkAnime;${animeType};${page};${animeList[0] ? animeList[0].id : "none"}` // {user id}, {callback command}, {list type}, {page}
},
{
text: `${animeList[1] ? functions.getNumberEmoji(animeList[1].count) : ``}`,
callback_data: `${fromId};checkAnime;${animeType};${page};${animeList[1] ? animeList[1].id : "none"}`
},
{
text: `${animeList[2] ? functions.getNumberEmoji(animeList[2].count) : ``}`,
callback_data: `${fromId};checkAnime;${animeType};${page};${animeList[2] ? animeList[2].id : "none"}`
},
{
text: `${animeList[3] ? functions.getNumberEmoji(animeList[3].count) : ``}`,
callback_data: `${fromId};checkAnime;${animeType};${page};${animeList[3] ? animeList[3].id : "none"}`
},
{
text: `${animeList[4] ? functions.getNumberEmoji(animeList[4].count) : ``}`,
callback_data: `${fromId};checkAnime;${animeType};${page};${animeList[4] ? animeList[4].id : "none"}`
}
],
[
{
text: ``,
callback_data: `${fromId};animeList;${animeType};1;${page}`
},
{
text: `◀️`,
callback_data: `${fromId};animeList;${animeType};${page-1};${page}`
},
{
text: `▶️`,
callback_data: `${fromId};animeList;${animeType};${page+1};${page}`
},
{
text: ``,
callback_data: `${fromId};animeList;${animeType};${maxPage};${page}`
}
],
[
{
text: `🔙 Назад к меню аниме`,
callback_data: `${fromId};animeMenu`
}
]
]
}
return keyboard
};
exports.interestingPages = async (fromId, newPage, maxPage, animeId) => { //Страницы в популярном, интересном
let keyboard = {
inline_keyboard: [
[
{
text: `🔥 Открыть тайтл`,
callback_data: `${fromId};checkInteresting;${newPage};${animeId};` // {user id}, {callback command}, {list type}, {page}
}
],
[
{
text: ``,
callback_data: `${fromId};interesting;1;${newPage}`
},
{
text: `◀️`,
callback_data: `${fromId};interesting;${newPage-1};${newPage}`
},
{
text: `▶️`,
callback_data: `${fromId};interesting;${newPage+1};${newPage}`
},
{
text: ``,
callback_data: `${fromId};interesting;${maxPage};${newPage}`
}
],
[
{
text: `🔙 Назад к меню аниме`,
callback_data: `${fromId};animeMenu`
}
]
]
}
return keyboard
};
exports.checkInterestingAnime = async (fromId, animeId, newPage) => { //Посмотреть интересное аниме
let keyboard = {
inline_keyboard: [
[
{
text: `⏸ Открыть аниме в Anixart`,
url: `https://anixart.tv/release/${animeId}`
}
],
[
{
text: `🔥 Назад к интересному`,
callback_data: `${fromId};interesting;${newPage};0`
}
],
[
{
text: `🔙 Назад к меню аниме`,
callback_data: `${fromId};animeMenu`
}
]
]
}
return keyboard
};
exports.searchAnimeMenu = async (fromId) => { //Как найти аниме
let keyboard = {
inline_keyboard: [
[
{
text: `🔙 Назад к меню аниме`,
callback_data: `${fromId};animeMenu`
}
]
]
}
return keyboard
};
exports.searchAnimeBack = async (fromId, page, animeName, animeId) => { //Как найти аниме
let keyboard = {
inline_keyboard: [
[
{
text: `⏸ Открыть аниме в Anixart`,
url: `https://anixart.tv/release/${animeId}`
}
],
[
{
text: `🔙 Назад к результатам`,
callback_data: `${fromId};searchAnime;${page};0;${animeName}`
}
],
[
{
text: `❌ Закрыть поиск`,
callback_data: `${fromId};deleteMessage`
}
]
]
}
return keyboard
};
exports.searchAnime = async (fromId, maxPage, page, animeList, animeName) => { //Страницы в популярном, интересном
let keyboard = {
inline_keyboard: [
[
{
text: `${animeList[0] ? functions.getNumberEmoji(animeList[0].count) : ``}`,
callback_data: `${fromId};searchResult;${page};${animeName};${animeList[0] ? animeList[0].id : "none"}` // {user id}, {callback command}, {list type}, {page}
},
{
text: `${animeList[1] ? functions.getNumberEmoji(animeList[1].count) : ``}`,
callback_data: `${fromId};searchResult;${page};${animeName};${animeList[1] ? animeList[1].id : "none"}`
},
{
text: `${animeList[2] ? functions.getNumberEmoji(animeList[2].count) : ``}`,
callback_data: `${fromId};searchResult;${page};${animeName};${animeList[2] ? animeList[2].id : "none"}`
},
{
text: `${animeList[3] ? functions.getNumberEmoji(animeList[3].count) : ``}`,
callback_data: `${fromId};searchResult;${page};${animeName};${animeList[3] ? animeList[3].id : "none"}`
},
{
text: `${animeList[4] ? functions.getNumberEmoji(animeList[4].count) : ``}`,
callback_data: `${fromId};searchResult;${page};${animeName};${animeList[4] ? animeList[4].id : "none"}`
}
],
[
{
text: ``,
callback_data: `${fromId};searchAnime;1;${page};${animeName}`
},
{
text: `◀️`,
callback_data: `${fromId};searchAnime;${page-1};${page};${animeName}`
},
{
text: `▶️`,
callback_data: `${fromId};searchAnime;${page+1};${page};${animeName}`
},
{
text: ``,
callback_data: `${fromId};searchAnime;${maxPage};${page};${animeName}`
}
],
[
{
text: `❌ Закрыть поиск`,
callback_data: `${fromId};deleteMessage`
}
]
]
}
return keyboard
};