-
Notifications
You must be signed in to change notification settings - Fork 2
/
chats.js
42 lines (29 loc) · 917 Bytes
/
chats.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict'
const { Client } = require('tdlnode')
const configExample = require('./config')
const api_id = 'your api_id'
const api_hash = 'your api_hash'
const phone_number = '+12345679021' // or token
const up = async () => {
const client = new Client({ api_id, api_hash, phone_number }, configExample)
const clb = msg => {console.log('event', msg)}
client.on('chats', clb)
client.once('chats', clb)
await client.init()
await client.fetch({
'@type': 'getChats',
'offset_order': '9223372036854775807',
'offset_chat_id': 0,
'limit': 100,
})
client.off('chats', clb)
const chats = await client.fetch({
'@type': 'getChats',
'offset_order': '9223372036854775807',
'offset_chat_id': 0,
'limit': 100,
})
console.log('chats', chats)
client.stop()
}
up()