Telegram API:如何从我未参与的 public 频道获取消息?
Telegram API: How do I get messages from a public channel, which I am not participant of?
顺便说一下,我能够通过 channels.getMessages request, once I know their message IDs
. I find channel id by contacts.search 从频道成功检索消息。
目前,消息 ID 是连续的整数,因此获取 max_id 将解决问题。
我相信这是可能的,因为官方客户端会这样做(查看频道而不加入)。我将通过阅读 its sources 来尝试找出官方桌面应用程序是如何做到这一点的,但我们将不胜感激。
我需要这个,因为我正在写一个简单的 public 电报频道 -> rss/web 界面。
请不要混淆 Telegram Client API 和 Telegram Bot API。 Bot API 允许在新消息上接收 'push' 条消息,但不允许 'reading historical logs'.
事实证明 messages.getHistory 没问题,给你最后 N 条消息 + 总计数。
要从您未加入的频道获取消息,您必须执行以下步骤:
- 用
contacts.resolveUsername
将用户名解析成ID和access_hash
- 调用
messages.getHistory
获取您想要的消息。
这里是 messages.getHistory
参数的简短描述:
:param peer: The channel from whom to retrieve the message history
:param limit: Number of messages to be retrieved
:param offset_date: Offset date (messages *previous* to this date will be retrieved)
:param offset_id: Offset message ID (only messages *previous* to the given ID will be retrieved)
:param max_id: All the messages with a higher (newer) ID or equal to this will be excluded
:param min_id: All the messages with a lower (older) ID or equal to this will be excluded
:param add_offset: Additional message offset (all of the specified offsets + this offset = older messages)
顺便说一下,我能够通过 channels.getMessages request, once I know their message IDs
. I find channel id by contacts.search 从频道成功检索消息。
目前,消息 ID 是连续的整数,因此获取 max_id 将解决问题。
我相信这是可能的,因为官方客户端会这样做(查看频道而不加入)。我将通过阅读 its sources 来尝试找出官方桌面应用程序是如何做到这一点的,但我们将不胜感激。
我需要这个,因为我正在写一个简单的 public 电报频道 -> rss/web 界面。
请不要混淆 Telegram Client API 和 Telegram Bot API。 Bot API 允许在新消息上接收 'push' 条消息,但不允许 'reading historical logs'.
事实证明 messages.getHistory 没问题,给你最后 N 条消息 + 总计数。
要从您未加入的频道获取消息,您必须执行以下步骤:
- 用
contacts.resolveUsername
将用户名解析成ID和access_hash
- 调用
messages.getHistory
获取您想要的消息。
这里是 messages.getHistory
参数的简短描述:
:param peer: The channel from whom to retrieve the message history
:param limit: Number of messages to be retrieved
:param offset_date: Offset date (messages *previous* to this date will be retrieved)
:param offset_id: Offset message ID (only messages *previous* to the given ID will be retrieved)
:param max_id: All the messages with a higher (newer) ID or equal to this will be excluded
:param min_id: All the messages with a lower (older) ID or equal to this will be excluded
:param add_offset: Additional message offset (all of the specified offsets + this offset = older messages)