Telegram Bot How to delete or remove a message or media from a channel or group

前端 未结 4 704
傲寒
傲寒 2021-02-04 00:21

I want to know an example of removing message or file like a photo

I did not find any functional tutorial in this regard,

相关标签:
4条回答
  • 2021-02-04 00:23

    https://api.telegram.org/botTOKEN/deleteMessage?chat_id=CID&message_id=MID

    Example https://api.telegram.org/bot123456789:zzzzzzzzxxxxxxxxxxyyyyyyyyyy/deleteMessage?chat_id=123456789&message_id=123456,

    It is important that the id of the message temine with a (comma) (,) and you can see it in the json when you send the message

    0 讨论(0)
  • 2021-02-04 00:42

    There are two methods in bot api that let you to edit a message: editMessageText and editMessageCaption. It is not ideal, but you can use it as an alternative.

    For example by editing the message to:

    "This message is unavailable."

    0 讨论(0)
  • 2021-02-04 00:44

    There is no such functionality in Telegram Bot API right now.

    UPD 2017-05-19: There is an official method deleteMessage, more info: https://core.telegram.org/bots/api#deletemessage

    https://stackoverflow.com/a/43965602/1140438

    0 讨论(0)
  • 2021-02-04 00:47

    There is an official support of deleteMessage method in Bot API 3.0. More details here: https://core.telegram.org/bots/api#deletemessage

    https://api.telegram.org/botTOKEN/deleteMessage?chat_id=CID&message_id=MID

    As you can see there are two arguments: chat_id and message_id.

    You can remove bot's messages or other messages (if bot is admin) except service messages (such as join/leave messages).

    1. On success, it will return following JSON object: {"ok":true,"result":true}.

    2. If you are trying to remove service message or other user's message, but bot is not an admin: {"ok":false,"error_code":400,"description":"Bad Request: message can't be deleted"}.

    3. If you are trying to remove non-existent message or its already deleted: {"ok":false,"error_code":400,"description":"Bad Request: message to delete not found"}

    0 讨论(0)
提交回复
热议问题