diff --git a/telethon/utils.py b/telethon/utils.py index 6f0d21d3..b78284ce 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -724,6 +724,10 @@ def get_peer(peer): elif isinstance(peer, types.ChannelFull): return types.PeerChannel(peer.id) + if peer.SUBCLASS_OF_ID in (0x7d7c6f86, 0xd9c7fc18): + # ChatParticipant, ChannelParticipant + return types.PeerUser(peer.user_id) + peer = get_input_peer(peer, allow_self=False, check_hash=False) if isinstance(peer, types.InputPeerUser): return types.PeerUser(peer.user_id) diff --git a/telethon_examples/README.md b/telethon_examples/README.md index acab382d..21b7d988 100644 --- a/telethon_examples/README.md +++ b/telethon_examples/README.md @@ -8,18 +8,17 @@ You should have the `telethon` library installed with `pip`. Run `python3 -m pip install --upgrade telethon --user` if you don't have it installed yet (this is the most portable way to install it). -Examples assume you have the following environment variables defined: +The scripts will ask you for your API ID, hash, etc. through standard input. +You can also define the following environment variables to avoid doing so: * `TG_API_ID`, this is your API ID from https://my.telegram.org. * `TG_API_HASH`, this is your API hash from https://my.telegram.org. * `TG_TOKEN`, this is your bot token from [@BotFather] for bot examples. * `TG_SESSION`, this is the name of the `*.session` file to use. -You can ignore any of these, and the scripts will prompt you to enter them. - ## Downloading Examples -You may download all and run any example with by typing in a terminal: +You may download all and run any example by typing in a terminal: ```sh git clone https://github.com/LonamiWebs/Telethon.git cd Telethon @@ -37,7 +36,7 @@ them as the base for your own code without worrying about copyright. ### [`print_updates.py`] -* Usable as a: **user and bot**. +* Usable as: **user and bot**. * Difficulty: **easy**. Trivial example that just prints all the updates Telegram originally @@ -46,7 +45,7 @@ some characters on screen. ### [`print_messages.py`] -* Usable as a: **user and bot**. +* Usable as: **user and bot**. * Difficulty: **easy**. This example uses the different `@client.on` syntax to register event @@ -57,7 +56,7 @@ documentation of [`events.NewMessage`] since this is only a simple example. ### [`replier.py`] -* Usable as a: **user and bot**. +* Usable as: **user and bot**. * Difficulty: **easy**. This example showcases a third way to add event handlers (using decorators @@ -78,7 +77,7 @@ assumes some [`asyncio`] knowledge, but otherwise is easy to follow. ### [`interactive_telegram_client.py`] -* Usable as a: **user and bot**. +* Usable as: **user**. * Difficulty: **medium**. Interactive terminal client that you can use to list your dialogs, @@ -88,7 +87,7 @@ state in order for downloads to work later. ### [`gui.py`] -* Usable as a: **user and bot**. +* Usable as: **user and bot**. * Difficulty: **high**. This is a simple GUI written with [`tkinter`] which becomes more complicated diff --git a/telethon_generator/data/errors.csv b/telethon_generator/data/errors.csv index 36cb735f..aa4909e5 100644 --- a/telethon_generator/data/errors.csv +++ b/telethon_generator/data/errors.csv @@ -38,7 +38,7 @@ CHANNEL_PUBLIC_GROUP_NA,403,channel/supergroup not available CHAT_ABOUT_NOT_MODIFIED,400,About text has not changed CHAT_ABOUT_TOO_LONG,400,Chat about too long CHAT_ADMIN_INVITE_REQUIRED,403,You do not have the rights to do this -CHAT_ADMIN_REQUIRED,400 403,"Chat admin privileges are required to do that in the specified chat (for example, to send a message in a channel which is not yours)" +CHAT_ADMIN_REQUIRED,400 403,"Chat admin privileges are required to do that in the specified chat (for example, to send a message in a channel which is not yours), or invalid permissions used for the channel or group" CHAT_FORBIDDEN,,You cannot write in this chat CHAT_ID_EMPTY,400,The provided chat ID is empty CHAT_ID_INVALID,400,"Invalid object ID for a chat. Make sure to pass the right types, for instance making sure that the request is designed for chats (not channels/megagroups) or otherwise look for a different one more suited\nAn example working with a megagroup and AddChatUserRequest, it will fail because megagroups are channels. Use InviteToChannelRequest instead"