File tree Expand file tree Collapse file tree
pyrogram/client/methods/contacts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ Contacts
126126
127127 add_contacts
128128 get_contacts
129+ get_contacts_count
129130 delete_contacts
130131
131132Password
Original file line number Diff line number Diff line change 1919from .add_contacts import AddContacts
2020from .delete_contacts import DeleteContacts
2121from .get_contacts import GetContacts
22+ from .get_contacts_count import GetContactsCount
2223
2324
2425class Contacts (
2526 GetContacts ,
2627 DeleteContacts ,
27- AddContacts
28+ AddContacts ,
29+ GetContactsCount
2830):
2931 pass
Original file line number Diff line number Diff line change 1+ # Pyrogram - Telegram MTProto API Client Library for Python
2+ # Copyright (C) 2017-2019 Dan Tès <https://github.com/delivrance>
3+ #
4+ # This file is part of Pyrogram.
5+ #
6+ # Pyrogram is free software: you can redistribute it and/or modify
7+ # it under the terms of the GNU Lesser General Public License as published
8+ # by the Free Software Foundation, either version 3 of the License, or
9+ # (at your option) any later version.
10+ #
11+ # Pyrogram is distributed in the hope that it will be useful,
12+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ # GNU Lesser General Public License for more details.
15+ #
16+ # You should have received a copy of the GNU Lesser General Public License
17+ # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+ from pyrogram .api import functions
20+ from ...ext import BaseClient
21+
22+
23+ class GetContactsCount (BaseClient ):
24+ def get_contacts_count (self ) -> int :
25+ """Use this method to get the total count of contacts from your Telegram address book.
26+
27+ Returns:
28+ On success, an integer is returned.
29+
30+ Raises:
31+ :class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
32+ """
33+
34+ return len (self .send (functions .contacts .GetContacts (hash = 0 )).contacts )
You can’t perform that action at this time.
0 commit comments