Td: How works getChatHistory

Created on 13 May 2018  路  7Comments  路  Source: tdlib/td

How works the method getChatHistory ?
How can I use the offset function if I havelimit = 50, onlyLocal = false and fromMessageId = chat.lastMessage.Id
I want to get messages from the newest to the oldest using the offset to avoid duplicate messages

Most helpful comment

-51 + 50 does not> 0 anyway, I can not understand why if I make a request with offset = 0 limit = 50 it works, if I do offset = -50 limit = 100 it works but if I do offset = -100 limit = 150 it does not work

immagine

immagine

immagine

All 7 comments

You need to specify offset = -51. TDLib currently requires offset + limit > 0 for getChatHistory, so you will usually receive 1 duplicate message.

-51 + 50 does not> 0 anyway, I can not understand why if I make a request with offset = 0 limit = 50 it works, if I do offset = -50 limit = 100 it works but if I do offset = -100 limit = 150 it does not work

immagine

immagine

immagine

Sorry, I've meant offset = -49.

Request with offset = -100 and limit = 150 doesn't work, because limit must be positive and can't be greater than 100.

so how can I get older messages?

You need to adjust from_message_id accordingly on every request.

Ahhh, ok.
Now how can I see how many messages there are in total in the channel?

This number isn't available currently in TDLib.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Invision70 picture Invision70  路  3Comments

RadRussianRus picture RadRussianRus  路  3Comments

sh-a-v picture sh-a-v  路  3Comments

FJarvan picture FJarvan  路  3Comments

hameda169 picture hameda169  路  3Comments