我在我的 Python
项目中使用 Telethon
。我正在使用此代码从 Telegram 中的群组获取消息:
full_msg_list = self.client.get_messages(GROUPID, limit=200)
有没有办法从群组中获取接下来的 200 条消息?
最佳答案
根据documentation你可以使用 add_offset
:
full_msg_list = self.client.get_messages(GROUPID, limit=200, add_offset=200)
编辑:
为了获得更可靠的偏移量,即使在新消息到达时,也可以使用 offset_id
代替:
full_msg_list = self.client.get_messages(GROUPID, limit=200, offset_id=200)
next_200_list = self.client.get_messages(GROUPID, limit=200, offset_id=full_msg_list[-1].id)
关于Python Telethon get_messages 偏移量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60151464/