如何使用Node-Telegram-bot-api在电信中获取上一个消息的消息ID?
我正在使用node.js和node-telegram-bot-api库开发电报机器人。我想在聊天中获取上一条消息的ID。我该如何实现?
我尝试使用此https://api.telegram.org/botхххх:хххххх/getUpdates?offset= -1 但是它给出以下错误消息:
{"ok":false,"error_code":409,"description":"Conflict: can't use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}
I'm developing a Telegram bot using Node.js and node-telegram-bot-api library. I want to get the id of the previous message in the chat. How can I achieve this?
I tried using this https://api.telegram.org/botХХХХ:ХХХХХХ/getUpdates?offset=-1
but it gives the following error message:
{"ok":false,"error_code":409,"description":"Conflict: can't use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
按 telegram docs :
后来,在
基本上,有两种方法是如何接收电报机器人的更新(消息,新用户等)。一个通过
getupdates
方法 - 使用此方法时,您应该定期运行getupdates
方法,以接收所有新的更新。第二种方法是通过Webhook - 您设置了一个URL,每当您的机器人收到更新时,电报都会发送请求。在大多数情况下,这是一种更实用的接收更新的方法,尽管难以实施。
这两种方法是互斥的 - 如果您设置了Webhook,则不能使用
getupdates
方法。如果要使用getupdates
方法,该解决方案是用 deletewebhook 方法。As per Telegram docs:
Later, in the description of getUpdates method:
Basically, there are two methods of how to receive updates (messages, new users etc.) of your Telegram bot. One is via
getUpdates
method - when using this method, you should rungetUpdates
method regularly to receive all the new updates.The second method is via webhook - you set up a url where Telegram will send a request whenever your bot receives an Update. In most cases this is a more practical way to receive Updates, albeit a bit harder to implement.
These two methods are mutually exclusive - if you have webhook set up, you can't use
getUpdates
method. The solution, if you want to usegetUpdates
method, is to delete the webhook with the deleteWebhook method.