mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-02 11:10:18 +03:00
Cache if channels are a megagroup or not
This commit is contained in:
parent
a9437db80c
commit
d06f403a62
|
@ -877,8 +877,12 @@ class ChatMethods:
|
|||
# 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:
|
||||
full_entity = await self.get_entity(entity)
|
||||
if full_entity.megagroup:
|
||||
# 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
|
||||
|
||||
|
|
|
@ -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