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: 808c629f 29701a3a
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 808c629f43b185bc0df8337a82f5ecc860bbdb94
Author: Andriel Rodrigues <andrielkogama2@gmail.com>
Date: Wed May 12 04:28:53 2021 -0300
Add get_chat_online_count method (todo) (#654)
This commit is contained in:
parent
29701a3a55
commit
dd32854db4
@ -222,6 +222,7 @@ def pyrogram_api():
|
||||
set_slow_mode
|
||||
mark_chat_unread
|
||||
get_chat_event_log
|
||||
get_chat_online_count
|
||||
""",
|
||||
users="""
|
||||
Users
|
||||
|
@ -53,6 +53,7 @@ from .unban_chat_member import UnbanChatMember
|
||||
from .unpin_all_chat_messages import UnpinAllChatMessages
|
||||
from .unpin_chat_message import UnpinChatMessage
|
||||
from .update_chat_username import UpdateChatUsername
|
||||
from .get_chat_online_count import GetChatOnlineCount
|
||||
|
||||
|
||||
class Chats(
|
||||
@ -92,6 +93,7 @@ class Chats(
|
||||
DeleteUserHistory,
|
||||
UnpinAllChatMessages,
|
||||
MarkChatUnread,
|
||||
GetChatEventLog
|
||||
GetChatEventLog,
|
||||
GetChatOnlineCount
|
||||
):
|
||||
pass
|
||||
|
46
pyrogram/methods/chats/get_chat_online_count.py
Normal file
46
pyrogram/methods/chats/get_chat_online_count.py
Normal file
@ -0,0 +1,46 @@
|
||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-2021 Dan <https://github.com/delivrance>
|
||||
#
|
||||
# This file is part of Pyrogram.
|
||||
#
|
||||
# Pyrogram is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Pyrogram is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from typing import Union
|
||||
|
||||
from pyrogram import raw
|
||||
from pyrogram.scaffold import Scaffold
|
||||
|
||||
|
||||
class GetChatOnlineCount(Scaffold):
|
||||
async def get_chat_online_count(self, chat_id: Union[int, str]) -> int:
|
||||
"""Get the number of members that are currently online in a chat.
|
||||
|
||||
Parameters:
|
||||
chat_id (``int`` | ``str``):
|
||||
Unique identifier (int) or username (str) of the target chat.
|
||||
|
||||
Returns:
|
||||
``int``: On success, the chat members online count is returned.
|
||||
|
||||
Example:
|
||||
.. code-block:: python
|
||||
|
||||
online = app.get_chat_online_count(chat_id)
|
||||
print(online)
|
||||
"""
|
||||
return (await self.send(
|
||||
raw.functions.messages.GetOnlines(
|
||||
peer=await self.resolve_peer(chat_id)
|
||||
)
|
||||
)).onlines
|
Loading…
Reference in New Issue
Block a user