Skip to content

Basic group Patches #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions pyrogram/methods/chats/promote_chat_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ async def promote_chat_member(
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
Pass False for all boolean parameters to demote a user.

.. include:: /_includes/usable-by/users-bots.rst
If the chat_id is a supergroup or channel,

.. include:: /_includes/usable-by/users-bots.rst

If the chat_id is a basicgroup,

.. include:: /_includes/usable-by/users.rst

Parameters:
chat_id (``int`` | ``str``):
Expand All @@ -45,7 +51,9 @@ async def promote_chat_member(
For a contact that exists in your Telegram address book you can use his phone number (str).

privileges (:obj:`~pyrogram.types.ChatPrivileges`, *optional*):
New user privileges.
New Rights of the administrator.
In supergroups and channels, there are more detailed options for administrator privileges.
In basic groups, administrators can edit and delete messages sent by others, add new members, ban unprivileged members, and manage video chats.

Returns:
:obj:`~pyrogram.types.Message` | ``bool``: On success, a service message will be returned (when applicable),
Expand All @@ -64,6 +72,22 @@ async def promote_chat_member(
if privileges is None:
privileges = types.ChatPrivileges()

if isinstance(chat_id, raw.types.InputPeerChat):
r = await self.invoke(
raw.functions.messages.EditChatAdmin(
chat_id=chat_id.chat_id,
user_id=user_id,
is_admin=privileges.can_manage_chat or any([
privileges.can_edit_messages,
privileges.can_delete_messages,
privileges.can_invite_users,
privileges.can_restrict_members,
privileges.can_manage_video_chats,
])
)
)
return r

try:
raw_chat_member = (await self.invoke(
raw.functions.channels.GetParticipant(
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/set_administrator_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ async def set_administrator_title(
title (``str``, *optional*):
A custom title that will be shown to all members instead of "Owner" or "Admin".
Pass None or "" (empty string) to remove the custom title.
0-16 characters without emoji; applicable to supergroups only.

Returns:
``bool``: True on success.
Expand Down