mtcute/packages/client/src/methods/contacts/get-contacts.ts

19 lines
537 B
TypeScript
Raw Normal View History

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
*/
export async function getContacts(this: TelegramClient): Promise<User[]> {
2021-04-25 17:10:37 +03:00
const res = await this.call({
_: 'contacts.getContacts',
hash: 0,
2021-04-25 17:10:37 +03:00
})
assertTypeIs('getContacts', res, 'contacts.contacts')
return res.users.map((user) => new User(this, user))
2021-04-25 17:10:37 +03:00
}