Closed Shrimp6387 closed 12 months ago
If the user is unknown to telethon, you won't be able to change he's permissions whatsoever. If you want to avoid this error, you should fetch entity with await message.get_sender()
beforehand
i do.
my code currently looks like this below, as u can see, i'm sending an User Entity already but it will refetch it from the entity again. you should not refetch the user entity if i already send an entity.
user = await message.get_sender()
if isinstance(user, User)
and (perms := await self.apo_lib.utils.is_member(chat, user))
and perms.is_admin:
This is my is_member
which calls your get_perms_cached
async def is_member(
self,
chat: EntityLike,
user: Optional[EntityLike] = None,
exp: Optional[int] = 5,
force: Optional[bool] = False,
) -> bool:
"""
Checks if a user is a member of a chat
:param entity: Chat ID or Chat Entity
:param user: User ID or User Entity
:param exp: The max time of cached results in seconds
:param force: Whether to force a refresh of the cache
:return: perms if user is a member of the chat, None otherwise
"""
try:
return await self._client.get_perms_cached(
chat,
user,
exp=exp,
force=force,
)
except UserNotParticipantError:
return None
If you acquired this entity legitimately, refetch will not harm you. It will just take the value from cache. If the entity was constructed manually \ tampered with, it will be re-fetched from Telegram servers.
[x] This bug is related to Hikka userbot itself. It is not related to modules.
Describe the bug In
async def get_perms_cached
the user is fetched again even when i send a user entity, this can lead into the telethon errorCould not find the input entity for PeerUser(user_id=1234) (PeerUser). Please read https://docs.telethon.dev/en/stable/concepts/entities.html to find out more details.
https://github.com/hikariatama/Hikka/blob/ce1f24f03313f8500de671815dde065fc8d86897/hikka/tl_cache.py#L225
Expected behavior Check if the User is actually an Entity or an Int.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Something like that would fix it.