From d1836ab8990cb1ca2c201738e8952210553b8691 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 9 Feb 2022 10:00:20 +0100 Subject: [PATCH] Review errors and remove some type checks If the type is not correct, we can let the API fail instead. This way, if the API supports more types in the future, there does not need to be an update. This has affected participant permissions in groups. --- telethon/_client/chats.py | 8 -------- telethon/_client/telegrambaseclient.py | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/telethon/_client/chats.py b/telethon/_client/chats.py index a9a4a45f..f17d72db 100644 --- a/telethon/_client/chats.py +++ b/telethon/_client/chats.py @@ -484,8 +484,6 @@ async def edit_admin( entity = await self.get_input_entity(entity) user = await self.get_input_entity(user) ty = helpers._entity_type(user) - if ty != helpers._EntityType.USER: - raise ValueError('You must pass a user entity') perm_names = ( 'change_info', 'post_messages', 'edit_messages', 'delete_messages', @@ -549,8 +547,6 @@ async def edit_permissions( pin_messages: bool = True) -> _tl.Updates: entity = await self.get_input_entity(entity) ty = helpers._entity_type(entity) - if ty != helpers._EntityType.CHANNEL: - raise ValueError('You must pass either a channel or a supergroup') rights = _tl.ChatBannedRights( until_date=until_date, @@ -592,8 +588,6 @@ async def kick_participant( ): entity = await self.get_input_entity(entity) user = await self.get_input_entity(user) - if helpers._entity_type(user) != helpers._EntityType.USER: - raise ValueError('You must pass a user entity') ty = helpers._entity_type(entity) if ty == helpers._EntityType.CHAT: @@ -660,8 +654,6 @@ async def get_stats( message: 'typing.Union[int, _tl.Message]' = None, ): entity = await self.get_input_entity(entity) - if helpers._entity_type(entity) != helpers._EntityType.CHANNEL: - raise TypeError('You must pass a channel entity') message = utils.get_message_id(message) if message is not None: diff --git a/telethon/_client/telegrambaseclient.py b/telethon/_client/telegrambaseclient.py index 9db125fd..09b1db51 100644 --- a/telethon/_client/telegrambaseclient.py +++ b/telethon/_client/telegrambaseclient.py @@ -157,7 +157,7 @@ def init( if not api_id or not api_hash: raise ValueError( "Your API ID or Hash cannot be empty or None. " - "Refer to telethon.rtfd.io for more information.") + "Refer to docs.telethon.dev for more information.") if local_addr is not None: if use_ipv6 is False and ':' in local_addr: