简体   繁体   English

如何使用电报 bot api 获取特定频道的聊天记录?

[英]How to get specific channel chat history using telegram bot api?

I am using telegram bot api to get the chat history of a channel https://api.telegram.org/botXXXXXXXXXXXXXXXXXX/getupdates我正在使用 telegram bot api 获取频道的聊天记录https://api.telegram.org/botXXXXXXXXXXXXXXXXXX/getupdates

my bot attached to the many channels and my query is that how to get chat history of any specific channel which is using my bot.我的机器人连接到许多频道,我的问题是如何获取使用我的机器人的任何特定频道的聊天记录。

but when I am using getupdates method it shows all the message with all channel.但是当我使用 getupdates 方法时,它会显示所有通道的所有消息。

my query is how to get the solution using telegram bot API?我的问题是如何使用电报机器人 API 获得解决方案?

just like when we need to send a message to any specific channel using the used the https://api.telegram.org/botxxxxxxxxxxxx/sendMessage?chat_id=@channel id&text=message就像我们需要使用https://api.telegram.org/botxxxxxxxxxxxx/sendMessage?chat_id=@channel id&text=message 向任何特定频道发送消息一样

i need a solution where I can send channel id and get the specific channel chat history using telegram bot API我需要一个可以发送频道 ID 并使用电报机器人 API 获取特定频道聊天历史记录的解决方案

my bot attached to the many channels and my query is that how to get chat history of any specific channel which is using my bot我的机器人连接到许多频道,我的问题是如何获取使用我的机器人的任何特定频道的聊天记录

You cannot get the chat history of a channel using the bot API.您无法使用 bot API 获取频道的聊天记录。 However you can use the core API (tdlib etc) to get the chat history.但是,您可以使用核心 API(tdlib 等)来获取聊天记录。 Alternatively you can try and scrape from the posts widget , but that is going to be too tedious.或者,您可以尝试从帖子小部件抓取,但这太乏味了。

but when I am using getupdates method it shows all the message with all channel.但是当我使用 getupdates 方法时,它会显示所有通道的所有消息。

You can manually filter out the channels since the ID is always in the Update object.您可以手动过滤掉频道,因为 ID 始终在更新对象中。 I would suggest you use a library for this since it would be easier to implement the logic.我建议你为此使用一个库,因为它更容易实现逻辑。

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

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