79691410

Date: 2025-07-06 00:30:30
Score: 1
Natty:
Report link

I have finally found a solution, thanks to https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1get_message_thread_history.html

It is explained both in the API and in the code below what each parameter does, in my case I put this in a while loop, I iterate the messages I get and save the ID of the last message I have processed, then in a new iteration of the while loop I get another batch of message from the last message I iterate, so until I get to iterate all the messages of that topic, in case I get a batch of messages and it comes empty is as easy as exiting the while loop.

resp = self.client.call_method(
    'getMessageThreadHistory',
    params={
        'chat_id': group_id, # your group id
        'message_id': message_id, # topic id
        'from_message_id': last_id, # last message you iterated
        'offset': 0, # 0 is fine if we want to iterate from last message
        'limit': 100 # the limit imposed by Telegram is 100, it makes no difference whether you set it or not.
    }
)
Reasons:
  • Blacklisted phrase (0.5): thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: skjolberg