Skip to content

Commit dd32854

Browse files
committed
Squashed commit of the following:
commit d6dcf98d7445cbdc2a036deca57207c14bc354fc Author: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed May 12 09:35:18 2021 +0200 Rename get_chat_onlines to get_chat_online_count commit 21ff2a39d856ebc939ce9b15810198c82a9c23c6 Merge: 808c629 29701a3 Author: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed May 12 09:32:59 2021 +0200 Merge branch 'master' into get-chat-online-count commit 808c629 Author: Andriel Rodrigues <andrielkogama2@gmail.com> Date: Wed May 12 04:28:53 2021 -0300 Add get_chat_online_count method (todo) (pyrogram#654)
1 parent 29701a3 commit dd32854

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

compiler/docs/compiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def get_title_list(s: str) -> list:
222222
set_slow_mode
223223
mark_chat_unread
224224
get_chat_event_log
225+
get_chat_online_count
225226
""",
226227
users="""
227228
Users

pyrogram/methods/chats/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
from .unpin_all_chat_messages import UnpinAllChatMessages
5454
from .unpin_chat_message import UnpinChatMessage
5555
from .update_chat_username import UpdateChatUsername
56+
from .get_chat_online_count import GetChatOnlineCount
5657

5758

5859
class Chats(
@@ -92,6 +93,7 @@ class Chats(
9293
DeleteUserHistory,
9394
UnpinAllChatMessages,
9495
MarkChatUnread,
95-
GetChatEventLog
96+
GetChatEventLog,
97+
GetChatOnlineCount
9698
):
9799
pass
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-2021 Dan <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 typing import Union
20+
21+
from pyrogram import raw
22+
from pyrogram.scaffold import Scaffold
23+
24+
25+
class GetChatOnlineCount(Scaffold):
26+
async def get_chat_online_count(self, chat_id: Union[int, str]) -> int:
27+
"""Get the number of members that are currently online in a chat.
28+
29+
Parameters:
30+
chat_id (``int`` | ``str``):
31+
Unique identifier (int) or username (str) of the target chat.
32+
33+
Returns:
34+
``int``: On success, the chat members online count is returned.
35+
36+
Example:
37+
.. code-block:: python
38+
39+
online = app.get_chat_online_count(chat_id)
40+
print(online)
41+
"""
42+
return (await self.send(
43+
raw.functions.messages.GetOnlines(
44+
peer=await self.resolve_peer(chat_id)
45+
)
46+
)).onlines

0 commit comments

Comments
 (0)