Hello everyone
I'm creating a bot with this library that scrappes a manga website and return details about the manga with their chapters (name, date and number)
So, first step is sending '/manga' with name of manga you wanna know about, ex: /manga chainsaw man, it returns details about it and a inline keybutton to list their chapters
The problem is: if i search a new manga and press this button of chapters, the code return the array of actual manga and previous manga, example: if i search chainsaw man first and after it I search boku no hero manga, it returns me chainsaw man and boku no hero chapters
I tried reseting array always the scrapping function is called, but is not working... what can I do? pls
the code:
main.js
export async function mangaCommand(message, name) {
let chatId = message.chat.id;
let messageId = message.message_id;
const manga = await mangaController(name);
if (manga.error) {
return bot.sendMessage(chatId, manga.error);
}
Hello everyone I'm creating a bot with this library that scrappes a manga website and return details about the manga with their chapters (name, date and number)
So, first step is sending '/manga' with name of manga you wanna know about, ex: /manga chainsaw man, it returns details about it and a inline keybutton to list their chapters
The problem is: if i search a new manga and press this button of chapters, the code return the array of actual manga and previous manga, example: if i search chainsaw man first and after it I search boku no hero manga, it returns me chainsaw man and boku no hero chapters
I tried reseting array always the scrapping function is called, but is not working... what can I do? pls
the code:
main.js export async function mangaCommand(message, name) { let chatId = message.chat.id; let messageId = message.message_id; const manga = await mangaController(name);
if (manga.error) { return bot.sendMessage(chatId, manga.error); }
const options = { parse_mode: "HTML", reply_markup: JSON.stringify({ inline_keyboard: [ [{ text: "đź“– Leia os capĂtulos", callback_data: "first_page" }], ], }), };
bot.sendPhoto(chatId, manga.poster);
bot.sendMessage( chatId,
<b>Nome:</b> ${manga.name} \n
+<b>Autor:</b> ${manga.author} \n
+<b>Artista:</b> ${manga.artist} \n
+<b>Categorias:</b> ${manga.categories} \n
+<b>Descrição:</b> ${manga.description} \n
+<b>NĂşmero de CapĂtulos:</b> ${manga.chapters_count} \n
+<b>Nota:</b> ${transformScore(manga.score)} \n
+<b>Link do mangá:</b> ${manga.link} \n
, options );bot.on("callback_query", async (callbackQuery) => { const action = callbackQuery.data; let setupInlineKeyboard = {};
}); }
let chaptersPage = 1;
async function inlineKeyboardChapters(id_serie, message_id, page) { let idReleaseManga = id_serie; let arrayChaptersManga = [];
arrayChaptersManga = await getChaptersController(idReleaseManga, page);
let buttonsChaptersManga = arrayChaptersManga.map((chapter) => { return [ { text:
#${chapter.number} - ${chapter.chapter_name}
, callback_data: "1", }, ]; });buttonsChaptersManga.push([ { text: "Página anterior", callback_data: "previous_page" }, { text: "Próxima página", callback_data: "next_page" }, ]);
let optionsChapters = { reply_markup: JSON.stringify({ inline_keyboard: buttonsChaptersManga, }), };
return optionsChapters; }
getChaptersController.js
export async function getChaptersController(manga_id, page) { // let chapters = [];
try { const response = await api.get(
https://mangalivre.net/series/chapters_list.json?page=${page}&id_serie=${manga_id}
);} catch (error) { console.log(error); } }