Td: getChats method seems not work properly!

Created on 8 Feb 2018  路  4Comments  路  Source: tdlib/td

I've used getChats method with offset_order=2^63-1, offset_chat_id=0 and limit=100

getChats (std::int64_t offset_order_, std::int64_t offset_chat_id_, std::int32_t limit_)

It returns first 100 chats, but when I call it again to obtain next 100 chats with offset_order=(2^63-1) - 100, offset_chat_id=0 and limit=100, it returns the first 100 chats again! I've played with many different values for these parameters but it does not work!
if I start offset_order from 0, it does not return any thing!

How should I use it to obtain all available chats in a Telegram account (even if there are thousands of chats)?

Most helpful comment

Chats are sorted in decreasing order by pairs (chat.order, chat.id) and returned in that order. To get chats from 99-th chat onward, you need to pass in getChats order and id of that chat, so the request should be

offset_order=<last_received_chat.order>, offset_chat_id=<last_received_chat.id>, limit=100

Also be aware that chats can change their order very often, so such iterative method may not work. You can find an example of a proper way of getting chat list in our Java example https://github.com/tdlib/td/blob/6c706f45e7a73c936b9f2f267785092c8a73348f/example/java/org/drinkless/tdlib/example/Example.java#L206.

All 4 comments

Thank you! I've tried it but it does not work :-(
For the first time I've set:
offset_order=2^63-1, offset_chat_id=0, limit=1
For the next time:
offset_order=(2^63-1) - 1, offset_chat_id=<last_received_chat_id>, limit=1
but it always returns the same chat_ids!

By the way, the getChats method just returns a list of chat_ids and not a pair of (order, chat_id)!

Chats are sorted in decreasing order by pairs (chat.order, chat.id) and returned in that order. To get chats from 99-th chat onward, you need to pass in getChats order and id of that chat, so the request should be

offset_order=<last_received_chat.order>, offset_chat_id=<last_received_chat.id>, limit=100

Also be aware that chats can change their order very often, so such iterative method may not work. You can find an example of a proper way of getting chat list in our Java example https://github.com/tdlib/td/blob/6c706f45e7a73c936b9f2f267785092c8a73348f/example/java/org/drinkless/tdlib/example/Example.java#L206.

Thank you!
I thought the chat type is like telegram schema and has not order field.
The example was useful :-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Invision70 picture Invision70  路  3Comments

isopen picture isopen  路  5Comments

Losses picture Losses  路  3Comments

L11R picture L11R  路  4Comments

pishnok picture pishnok  路  3Comments