2021-04-25 17:10:37 +03:00
|
|
|
import { TelegramClient } from '../../client'
|
|
|
|
import { User } from '../../types'
|
|
|
|
import { assertTypeIs } from '../../utils/type-assertion'
|
2021-08-05 20:38:24 +03:00
|
|
|
import { tl } from '@mtcute/tl'
|
2021-04-25 17:10:37 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-06-06 15:20:41 +03:00
|
|
|
hash: 0,
|
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
|
|
|
}
|