简体   繁体   English

删除电报机器人发送的消息

[英]Delete messages sent by telegram bot

i have a telegram -bot in a group which sends messages like current weather, stock prices , news and so on. 我在一个小组中有一个电报机器人,它发送诸如当前天气,股票价格,新闻等消息。 at the end of the day i want to clean up the messages sent by bot. 在一天结束时,我想清理机器人发送的消息。 however i unable to get the message id of the messages sent by bot using the api ' https://api.telegram.org/botxxxx:xxxxxxxxxxx/getUpdates ' and hence i am unable to delete message created by bot. 不过,我无法获得使用API“通过机器人发送的消息的消息ID https://api.telegram.org/botxxxx:xxxxxxxxxxx/getUpdates ”,因此我无法删除由机器人创建的消息。 any updates on this issue will be appreciated 此问题的任何更新将不胜感激

you should store the message IDs when invoking the send method (from the message object returned) and delete those messages while emptying out your message id storage later on. 您应该在调用send方法时(从返回的消息对象中)存储消息ID,并在稍后清空消息ID存储时删除这些消息。

This is efficient than your approach for couple of reasons. 由于几个原因,这比您的方法有效。 For instance, with your approach you may have to filter out other messages/updates on that channel that weren't send by the bot (if your bot isn't the only admin who posts content). 例如,使用您的方法,您可能必须过滤掉该渠道未由机器人发送的其他消息/更新(如果您的机器人不是发布内容的唯一管理员)。

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

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