[英]How to request all chats/groups of the user through Telegram Database Library(TDLib) for Node.js
The official example from telegram explains that in order to use getChats()
command, one needs to set two parameters ' offset_order
' and ' offset_chat_id
'.电报的官方例子解释说,为了使用
getChats()
命令,需要设置两个参数“ offset_order
”和“ offset_chat_id
”。 I'm using this node.js wrapper for the TDLib .我正在为 TDLib使用这个node.js 包装器。 So when I use
getChats()
with the following params:因此,当我使用带有以下参数的
getChats()
时:
'offset_order': '9223372036854775807',
'offset_chat_id': 0,
'limit': 100
just like it is explained in the official docs :就像官方文档中解释的那样:
For example, to get a list of chats from the beginning, the offset_order should be equal to 2^63 - 1
例如,要从开头获取聊天列表,offset_order 应等于 2^63 - 1
as a result I get 100 chats from the top of the user's list.结果,我从用户列表的顶部获得了 100 个聊天记录。
What I can't understand is how do I iterate through that list?我不明白的是如何遍历该列表? How do I use the API pagination?
如何使用 API 分页?
When I try to enter a legitimate chat_id from the middle of the first 100, I still get the same first 100, so it seems like it makes no difference.当我尝试从前 100 个中间输入合法的 chat_id 时,我仍然得到相同的前 100 个,因此似乎没有区别。
If I change that offset_order to ANY other number, I get an empty list of chats in return...如果我将该 offset_order 更改为任何其他数字,我会得到一个空的聊天列表作为回报......
Completely lost here, as every singleexample I found says the same thing as the official docs, ie how to get the first 100.在这里完全迷失了,因为我发现的每一个例子都和官方文档说的一样,即如何获得前 100 个。
Had the same problem, have tried different approaches and re-read documentation for a long time, and here is a decision:遇到同样的问题,尝试了不同的方法并重新阅读文档很长一段时间,这里是一个决定:
getChats
as you do with '9223372036854775807'
offset_order
parametergetChats
就如同使用'9223372036854775807'
offset_order
参数getChat
request with id of the last chat you have got.getChat
请求。 It's an offline request, just to tdlib. positions: [
{
_: 'chatPosition',
list: [Object],
order: '6910658003385450706',
is_pinned: false
}
],
getChats
- use the positions[0].order
from (3) as offset_order
getChats
- 使用 (3) 中的positions[0].order
offset_order
作为offset_order
It wasn't easy to come to this, so would be glad if it helps anybody who came from google like me :)做到这一点并不容易,所以如果它可以帮助像我这样来自谷歌的人,我会很高兴:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.