diff --git a/pyrogram/client/methods/contacts/get_contacts.py b/pyrogram/client/methods/contacts/get_contacts.py index 7e90476c..29b7e176 100644 --- a/pyrogram/client/methods/contacts/get_contacts.py +++ b/pyrogram/client/methods/contacts/get_contacts.py @@ -19,7 +19,8 @@ import logging import time -from pyrogram.api import functions, types +import pyrogram +from pyrogram.api import functions from pyrogram.api.errors import FloodWait from ...ext import BaseClient @@ -28,12 +29,10 @@ log = logging.getLogger(__name__) class GetContacts(BaseClient): def get_contacts(self): - """Use this method to get contacts from your Telegram address book - - Requires no parameters. + """Use this method to get contacts from your Telegram address book. Returns: - On success, the user's contacts are returned + On success, a list of :obj:`User` objects is returned. Raises: :class:`Error ` in case of a Telegram RPC error. @@ -44,9 +43,6 @@ class GetContacts(BaseClient): except FloodWait as e: log.warning("get_contacts flood: waiting {} seconds".format(e.x)) time.sleep(e.x) - continue else: - if isinstance(contacts, types.contacts.Contacts): - log.info("Total contacts: {}".format(len(self.peers_by_phone))) - - return contacts + log.info("Total contacts: {}".format(len(self.peers_by_phone))) + return [pyrogram.User._parse(self, user) for user in contacts.users]