telebot icon indicating copy to clipboard operation
telebot copied to clipboard

How do I delete a previous message by the bot?

Open Magush26 opened this issue 6 years ago • 0 comments

I created a bot that does a great job of welcoming new users in my Telegram channel. But I can't seem to grasp the deleteMessage function to delete the previous welcome message to avoid flooding. My code until now deletes the previous message in the channel but I want it to delete the previous message of the bot. Code:

bot.on("new_chat_members", function(msg) {
var chatId = msg.chat.id;
var messageId = msg.message_id;

if (msg.new_chat_members != undefined){
bot.deleteMessage(msg.chat.id, msg.message_id);
  if (msg.new_chat_member.id != undefined){
  var newUserName = msg.new_chat_member.username;
  } else {
  var newUserName = msg.new_chat_member.first_name;
  }
}
console.log(msg);

bot.sendMessage(msg.chat.id, 'Hi @' + newUserName + ', thanks fo..', {
reply_markup: {
  inline_keyboard: [[
    {
      text: '🖥 Visit our website',

....

Magush26 avatar Nov 28 '18 12:11 Magush26