Skip to content

Commit fd4bebf

Browse files
committed
Improve documentation of promote_chat_member
1 parent a9c4cb8 commit fd4bebf

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

pyrogram/methods/chats/promote_chat_member.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ async def promote_chat_member(
3434
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
3535
Pass False for all boolean parameters to demote a user.
3636
37-
.. include:: /_includes/usable-by/users-bots.rst
37+
If the chat_id is a supergroup or channel,
38+
39+
.. include:: /_includes/usable-by/users-bots.rst
40+
41+
If the chat_id is a basicgroup,
42+
43+
.. include:: /_includes/usable-by/users.rst
3844
3945
Parameters:
4046
chat_id (``int`` | ``str``):
@@ -45,7 +51,9 @@ async def promote_chat_member(
4551
For a contact that exists in your Telegram address book you can use his phone number (str).
4652
4753
privileges (:obj:`~pyrogram.types.ChatPrivileges`, *optional*):
48-
New user privileges.
54+
New Rights of the administrator.
55+
In supergroups and channels, there are more detailed options for administrator privileges.
56+
In basic groups, administrators can edit and delete messages sent by others, add new members, ban unprivileged members, and manage video chats.
4957
5058
Returns:
5159
:obj:`~pyrogram.types.Message` | ``bool``: On success, a service message will be returned (when applicable),
@@ -64,6 +72,22 @@ async def promote_chat_member(
6472
if privileges is None:
6573
privileges = types.ChatPrivileges()
6674

75+
if isinstance(chat_id, raw.types.InputPeerChat):
76+
r = await self.invoke(
77+
raw.functions.messages.EditChatAdmin(
78+
chat_id=chat_id.chat_id,
79+
user_id=user_id,
80+
is_admin=privileges.can_manage_chat or any([
81+
privileges.can_edit_messages,
82+
privileges.can_delete_messages,
83+
privileges.can_invite_users,
84+
privileges.can_restrict_members,
85+
privileges.can_manage_video_chats,
86+
])
87+
)
88+
)
89+
return r
90+
6791
try:
6892
raw_chat_member = (await self.invoke(
6993
raw.functions.channels.GetParticipant(

0 commit comments

Comments
 (0)