@Neolq

Как изменить сообщение отправленное телеграм ботом?

Бот на node-telegram-bot-api. Нужно изменить уже отправленное ботом сообщение. Как это реализовать?

bot.on('message', async (msg) => {
   const text = msg.text.toLowerCase()
   const chatId = msg.chat.id

   const message = 'TEXT'

   if (text.match('123')) {
      setTimeout(() => {
         bot.sendMessage(chatId, message)

         setTimeout(() => {
            bot.editMessageText(`${message} (edit)`, {
               chat_id = chatId,
               
            })
         }, 500)
         //
      }, 500)
   }
})
  • Вопрос задан
  • 2782 просмотра
Решения вопроса 1
lastuniverse
@lastuniverse
Всегда вокруг да около IT тем
bot.on('message', async (msg) => {
  const text = msg.text.toLowerCase()
  const chatId = msg.chat.id
  const message = 'TEXT'
  if (text.match('123')) {
     setTimeout(() => {
        bot.sendMessage(chatId, message)
        .then(msgData=>{
          let count = 0;
          const timerId = setInterval(() => {
              count+=Math.floor(Math.random()*10);
              if(count>100){
                count=100;
                clearInterval(timerId);
              }
              bot.editMessageText(`${message} (edit) ${count}%`, 
              {
                chat_id: msgData.chat.id,
                message_id: msgData.message_id
              });
          }, 500)
        })
     }, 500)
  }
})
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы