Answer the question
In order to leave comments, you need to log in
How to force telegram bot to send images from a folder?
Good day, I am writing a bot for telegrams on node.js one lesson on the Internet, the functionality is quite simple, but I wanted to diversify it. In the lesson itself, the bot sent an image by pressing a certain button, but my idea is to send a random image by pressing one button. I didn’t find anything similar on the Internet, only similar in python and then for the Discord bot
// обработчик событий нажатий на клавиатуру
bot.on('callback_query', (query) => {
const chatId = query.message.chat.id;
let img= ["C:\Users\ewrrr\OneDrive\Documents\CatEchoBot\img"];
if (query.data === 'moreKeks') { // если кот
img = 'C:\Users\ewrrr\OneDrive\Documents\CatEchoBot\img'
}
if (img) {
bot.sendPhoto(chatId, img, { // прикрутим клаву
reply_markup: {
inline_keyboard: keyboard
}
});
} else {
bot.sendMessage(chatId, 'Непонятно, давай попробуем ещё раз?', { // прикрутим клаву
reply_markup: {
inline_keyboard: keyboard
}
});
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question