2022-06-30 16:32:56 +03:00
|
|
|
import Long from 'long'
|
|
|
|
|
2021-04-25 17:10:37 +03:00
|
|
|
import { TelegramClient } from '../../client'
|
|
|
|
import { User } from '../../types'
|
|
|
|
import { assertTypeIs } from '../../utils/type-assertion'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get list of contacts from your Telegram contacts list.
|
|
|
|
* @internal
|
|
|
|
*/
|
2021-06-06 15:20:41 +03:00
|
|
|
export async function getContacts(this: TelegramClient): Promise<User[]> {
|
2021-04-25 17:10:37 +03:00
|
|
|
const res = await this.call({
|
|
|
|
_: 'contacts.getContacts',
|
2021-11-23 00:03:59 +03:00
|
|
|
hash: Long.ZERO,
|
2021-04-25 17:10:37 +03:00
|
|
|
})
|
|
|
|
assertTypeIs('getContacts', res, 'contacts.contacts')
|
|
|
|
|
2021-04-26 23:26:57 +03:00
|
|
|
return res.users.map((user) => new User(this, user))
|
2021-04-25 17:10:37 +03:00
|
|
|
}
|