⚡ Sangsakala Proxy 🏠 Home
Skip to content

Commit e8e0c16

Browse files
committed
Add get_contacts_count method
1 parent 4e77ead commit e8e0c16

3 files changed

Lines changed: 38 additions & 1 deletion

File tree

‎docs/source/pyrogram/Client.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ Contacts
126126

127127
add_contacts
128128
get_contacts
129+
get_contacts_count
129130
delete_contacts
130131

131132
Password

‎pyrogram/client/methods/contacts/__init__.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
from .add_contacts import AddContacts
2020
from .delete_contacts import DeleteContacts
2121
from .get_contacts import GetContacts
22+
from .get_contacts_count import GetContactsCount
2223

2324

2425
class Contacts(
2526
GetContacts,
2627
DeleteContacts,
27-
AddContacts
28+
AddContacts,
29+
GetContactsCount
2830
):
2931
pass
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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)

0 commit comments

Comments
 (0)