I want to get a specific channel posts after an id (ex. 1245). I write this code:
# After connection to session in cli variable last_post = cli( GetHistoryRequest( peer=entity, limit=100, offset_date=None, add_offset=0, hash=0 ) )
But this gives me the 100 last message. Even with the
max_id argument passed to the GetHistoryRequest, I get the messages from the earlier message to older ones. How can I get messages with opposite order?
You must read the doc first and then ask your question.
You can do it simply with the
iter_messages argument as follow:
next_post = cli.iter_messages( entity, limit=5, min_id=your_post_id, reverse=True )
reverse argument you can get the posts with the reverse order.