mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 04:48:06 +00:00
Make get_contacts return a list of User objects
This commit is contained in:
parent
712b390f77
commit
23a40a45ca
@ -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 <pyrogram.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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user