K
K
Kirpich2021-12-16 18:29:16
Node.js
Kirpich, 2021-12-16 18:29:16

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

1 answer(s)
K
kapp1, 2021-12-16
@satanicmotherfucker

Specify, do you have such an absolute path that is in the folder? What files? With what extensions?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question