2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Update restrict_chat_member and set_chat_permissions methods

This commit is contained in:
Dan 2020-04-12 13:42:00 +02:00
parent ef5fa8f70b
commit 99604baaf4
2 changed files with 24 additions and 109 deletions

View File

@ -71,66 +71,23 @@ class RestrictChatMember(BaseClient):
# Chat member can only send text messages
app.restrict_chat_member(chat_id, user_id, ChatPermissions(can_send_messages=True))
"""
send_messages = True
send_media = True
send_stickers = True
send_gifs = True
send_games = True
send_inline = True
embed_links = True
send_polls = True
change_info = True
invite_users = True
pin_messages = True
if permissions.can_send_messages:
send_messages = None
if permissions.can_send_media_messages:
send_messages = None
send_media = None
if permissions.can_send_other_messages:
send_messages = None
send_stickers = None
send_gifs = None
send_games = None
send_inline = None
if permissions.can_add_web_page_previews:
send_messages = None
embed_links = None
if permissions.can_send_polls:
send_messages = None
send_polls = None
if permissions.can_change_info:
change_info = None
if permissions.can_invite_users:
invite_users = None
if permissions.can_pin_messages:
pin_messages = None
r = self.send(
functions.channels.EditBanned(
channel=self.resolve_peer(chat_id),
user_id=self.resolve_peer(user_id),
banned_rights=types.ChatBannedRights(
until_date=until_date,
send_messages=send_messages,
send_media=send_media,
send_stickers=send_stickers,
send_gifs=send_gifs,
send_games=send_games,
send_inline=send_inline,
embed_links=embed_links,
send_polls=send_polls,
change_info=change_info,
invite_users=invite_users,
pin_messages=pin_messages
send_messages=True if not permissions.can_send_messages else None,
send_media=True if not permissions.can_send_media_messages else None,
send_stickers=True if not permissions.can_send_stickers else None,
send_gifs=True if not permissions.can_send_animations else None,
send_games=True if not permissions.can_send_games else None,
send_inline=True if not permissions.can_use_inline_bots else None,
embed_links=True if not permissions.can_add_web_page_previews else None,
send_polls=True if not permissions.can_send_polls else None,
change_info=True if not permissions.can_change_info else None,
invite_users=True if not permissions.can_invite_users else None,
pin_messages=True if not permissions.can_pin_messages else None,
)
)
)

View File

@ -58,69 +58,27 @@ class SetChatPermissions(BaseClient):
ChatPermissions(
can_send_messages=True,
can_send_media_messages=True,
can_send_other_messages=True
can_send_stickers=True,
can_send_animations=True
)
)
"""
send_messages = True
send_media = True
send_stickers = True
send_gifs = True
send_games = True
send_inline = True
embed_links = True
send_polls = True
change_info = True
invite_users = True
pin_messages = True
if permissions.can_send_messages:
send_messages = None
if permissions.can_send_media_messages:
send_messages = None
send_media = None
if permissions.can_send_other_messages:
send_messages = None
send_stickers = None
send_gifs = None
send_games = None
send_inline = None
if permissions.can_add_web_page_previews:
send_messages = None
embed_links = None
if permissions.can_send_polls:
send_messages = None
send_polls = None
if permissions.can_change_info:
change_info = None
if permissions.can_invite_users:
invite_users = None
if permissions.can_pin_messages:
pin_messages = None
r = self.send(
functions.messages.EditChatDefaultBannedRights(
peer=self.resolve_peer(chat_id),
banned_rights=types.ChatBannedRights(
until_date=0,
send_messages=send_messages,
send_media=send_media,
send_stickers=send_stickers,
send_gifs=send_gifs,
send_games=send_games,
send_inline=send_inline,
embed_links=embed_links,
send_polls=send_polls,
change_info=change_info,
invite_users=invite_users,
pin_messages=pin_messages
send_messages=True if not permissions.can_send_messages else None,
send_media=True if not permissions.can_send_media_messages else None,
send_stickers=True if not permissions.can_send_stickers else None,
send_gifs=True if not permissions.can_send_animations else None,
send_games=True if not permissions.can_send_games else None,
send_inline=True if not permissions.can_use_inline_bots else None,
embed_links=True if not permissions.can_add_web_page_previews else None,
send_polls=True if not permissions.can_send_polls else None,
change_info=True if not permissions.can_change_info else None,
invite_users=True if not permissions.can_invite_users else None,
pin_messages=True if not permissions.can_pin_messages else None,
)
)
)