简体   繁体   English

我可以使用 Telegram bot 删除用户消息吗?

[英]Can I delete user messages with a Telegram bot?

In a private chat (a user and a Bot) is it possible to delete user messages (or text commands after pressing a custom keyboard button)to keep the chat clean and more readable?在私人聊天(用户和机器人)中,是否可以删除用户消息(或按下自定义键盘按钮后的文本命令)以保持聊天干净且更具可读性?

I'm looking for a solution that acts like inline keyboard mechanism (a label for the button and a command to send).我正在寻找一种类似于内联键盘机制(按钮的标签和要发送的命令)的解决方案。

I have tested the deletemessageasync and I was able to remove the Bot sent messages, but couldn't remove user messages.我已经测试了deletemessageasync并且我能够删除机器人发送的消息,但无法删除用户消息。

Any idea?有什么想法吗?

In private chats a bot can delete only his own messages.在私人聊天中,机器人只能删除自己的消息。 in a group or supergroup he can delete only his own messages as normal users;在群组或超级群组中,他只能作为普通用户删除自己的消息; he can delete messages from anyone if he is an administrator.如果他是管理员,他可以删除任何人的消息。

If your goal is to keep chat clean, there are no other solutions than using inline keyboards and editing messages.如果您的目标是保持聊天畅通无阻,那么除了使用内嵌键盘和编辑消息外,别无他法。

Not possible to delete others message in Telegram, bots don't have more permission than normal users.无法删除 Telegram 中的其他消息,机器人没有比普通用户更多的权限。

BTW, if you are in Supergroup, you can use deleteMessage method when you have external permission.顺便说一句,如果您在超级组中,则可以在具有外部权限的情况下使用deleteMessage方法。

https://api.telegram.org/bot123456:AAAAAAAAAA-5555-YOUBOT/deleteMessage?chat_id=-5555&message_id=800`

Your bot must be group administrator您的机器人必须是组管理员

To get the messages you can use:要获取您可以使用的消息:

https://api.telegram.org/bot123456:AAAAAAAAAA-5555-YOUBOT/getUpdates

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM