Let get_input_peer do its magic

Lonami 2017-06-15 17:13:37 +02:00
parent 862f63e39c
commit 3623496fb9

@ -6,10 +6,7 @@ Once you have the [entity](Retrieving-an-entity) of the channel you want to join
```python ```python
from telethon.tl.functions.channels import JoinChannelRequest from telethon.tl.functions.channels import JoinChannelRequest
from telethon.helpers import get_input_peer client.invoke(JoinChannelRequest(channel))
input_channel = get_input_peer(channel)
client.invoke(JoinChannelRequest(input_channel))
# In the same way, you can also leave such channel # In the same way, you can also leave such channel
from telethon.tl.functions.channels import LeaveChannelRequest from telethon.tl.functions.channels import LeaveChannelRequest
@ -24,7 +21,6 @@ If all you have is a link like this one: `https://t.me/joinchat/AAAAAFFszQPyPEZ7
```python ```python
from telethon.tl.functions.messages import ImportChatInviteRequest from telethon.tl.functions.messages import ImportChatInviteRequest
updates = client.invoke(ImportChatInviteRequest('AAAAAEHbEkejzxUjAUCfYg')) updates = client.invoke(ImportChatInviteRequest('AAAAAEHbEkejzxUjAUCfYg'))
``` ```
@ -34,11 +30,10 @@ If you don't want to add yourself, maybe because you're already in, you can alwa
```python ```python
from telethon.tl.functions.messages import AddChatUserRequest from telethon.tl.functions.messages import AddChatUserRequest
from telethon.helpers import get_input_peer
client.invoke(AddChatUserRequest( client.invoke(AddChatUserRequest(
chat_id, chat_id,
get_input_peer(user_to_add), user_to_add,
fwd_limit=10 # allow the user to see the 10 last messages fwd_limit=10 # allow the user to see the 10 last messages
)) ))
``` ```