Pouria Parhami
Pouria Parhami

Reputation: 182

Is that possible a telegram bot can remove messages from group

i want create telegram bot . It can join to the group and delete messages in group . Is that possible a telegram bot can remove messages from group ? i search and some people say yes it possible , some people say no

Upvotes: 4

Views: 16841

Answers (3)

Ph4r5h4d
Ph4r5h4d

Reputation: 101

Check this link out, it seems the new bot API made it possible with some restrictions:
https://core.telegram.org/bots/api#deletemessage
The following details are from telegram API page:

  • A message can only be deleted if it was sent less than 48 hours ago.
  • Bots can delete outgoing messages in groups and supergroups.
  • Bots granted can_post_messages permissions can delete outgoing messages in channels.
  • If the bot is an administrator of a group, it can delete any message there.
  • If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.

Returns True on success.

Upvotes: 7

Mayer Spitz
Mayer Spitz

Reputation: 2525

You can use

bot.DeleteMessageAsync(chatId, messageId)

you should make it in a try catch in case the message doesn't exist anymore or you have a wrong messageId,

messageId is a property which you get in MessageEventArgs.Message,

Note: the chatId should be the Group/Channel chatId and not of the user who sent it, get that in Chat.Id property of MessageEventArgs.Message ...

Upvotes: 1

Hoi_A
Hoi_A

Reputation: 492

This is now outdated, please see Darkc0d3r's answer


Using the Telegram Bot API? No, there is no such functionality as of now.

However you can if you are using the Telegram API, where you can use the messages.deleteMessages method, which requires you to give it a list of message id's as a parameter.

Upvotes: 4

Related Questions