question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to delete the entire previous message by bot ?

See original GitHub issue

Currently bot has option to show welcome messages for the new new_chat_members which shows for each member. There are plenty of welcome messages staying in group due to the high volume of new members. iIt is bit irritating for the current users showing multiple number of welcome messages.

const welcomeMessage = (ctx) => {
  const { new_chat_members } = ctx.message;
  const newMembers = new_chat_members.filter( member => member.is_bot === false)
  var membersName = newMembers.map( usr =>{ 
    let fullname = [usr.first_name,usr.last_name].join(" ");
    return fullname;
  });
  ctx.replyWithMarkdown(`Welcom ${membersName.join(', ')}`);
}
bot.on('new_chat_members', welcomeMessage);

Is there any option to delete all the previous welcome messages ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Piterdencommented, Sep 1, 2018
const newChatMemberHandler = async (ctx) => {
  const names = ctx.message.new_chat_members
    .filter(({ is_bot }) => !is_bot)
    .map(({ first_name, last_name }) => `${first_name} ${last_name}`)

  await ctx.deleteMessage()

  ctx.replyWithMarkdown(`Welcome ${names.join(', ')}!`)
}

bot.on('new_chat_members', newChatMemberHandler)
3reactions
Piterdencommented, Sep 1, 2018
const { message_id } = await ctx.replyWithMarkdown(`Welcom ${membersName.join(', ')}`))
setTimeout(() => ctx.deleteMessage(message_id), 60 * 1000)
console.log(message_id)

I affraid we talk about the service welcome message.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to delete all the previous message by bot?
there is another way which is viable: use telegram core api and 0xafa92846: functions.messages.GetHistoryRequest api to get messages in the ...
Read more >
5 Best Discord Bots to Delete Messages Based on Parameters
A smart list of Discord bots to delete messages based on search parameters, time, user, future and past messages, and command messages.
Read more >
Is there a way to delete all messages from a former user in ...
In a DM conversation, the only messages you can delete are your own, and the only way to hide messages sent by other...
Read more >
How to Clear Discord Chat - Delete all messages in a channel ...
Clearing an entire Discord chat is an option that is widely requested. This is because, unlike some chat apps, Discord doesn't let you...
Read more >
How to Delete All Messages in Discord - Beebom
Discord doesn't encourage the use of self-bots to bulk delete messages. Here, we'll be using a script to get rid of old Discord...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found