mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 01:16:35 +03:00
Ignore channel-only permissions in megagroups (#1292)
This commit is contained in:
parent
09f27f0dd7
commit
b862f215c5
|
@ -873,6 +873,19 @@ class ChatMethods:
|
|||
)
|
||||
|
||||
if isinstance(entity, types.InputPeerChannel):
|
||||
# If we try to set these permissions in a megagroup, we
|
||||
# would get a RIGHT_FORBIDDEN. However, it makes sense
|
||||
# that an admin can post messages, so we want to avoid the error
|
||||
if post_messages or edit_messages:
|
||||
# TODO get rid of this once sessions cache this information
|
||||
if entity.channel_id not in self._megagroup_cache:
|
||||
full_entity = await self.get_entity(entity)
|
||||
self._megagroup_cache[entity.channel_id] = full_entity.megagroup
|
||||
|
||||
if self._megagroup_cache[entity.channel_id]:
|
||||
post_messages = None
|
||||
edit_messages = None
|
||||
|
||||
perms = locals()
|
||||
return await self(functions.channels.EditAdminRequest(entity, user, types.ChatAdminRights(**{
|
||||
# A permission is its explicit (not-None) value or `is_admin`.
|
||||
|
|
|
@ -340,6 +340,9 @@ class TelegramBaseClient(abc.ABC):
|
|||
self._self_input_peer = None
|
||||
self._bot = None
|
||||
|
||||
# A place to store if channels are a megagroup or not (see `edit_admin`)
|
||||
self._megagroup_cache = {}
|
||||
|
||||
# endregion
|
||||
|
||||
# region Properties
|
||||
|
|
Loading…
Reference in New Issue
Block a user