From 95fa91576b313e82e79716586d26a60c535b6ddc Mon Sep 17 00:00:00 2001 From: Lonami Date: Sat, 10 Jun 2017 13:26:56 +0200 Subject: [PATCH] Add AddChatUserRequest example --- Joining-a-chat-or-channel.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Joining-a-chat-or-channel.md b/Joining-a-chat-or-channel.md index ce819d2..3c01a00 100644 --- a/Joining-a-chat-or-channel.md +++ b/Joining-a-chat-or-channel.md @@ -26,4 +26,19 @@ If all you have is a link like this one: `https://t.me/joinchat/AAAAAFFszQPyPEZ7 from telethon.tl.functions.messages import ImportChatInviteRequest updates = client.invoke(ImportChatInviteRequest('AAAAAEHbEkejzxUjAUCfYg')) +``` + +## Adding someone else to such chat or channel + +If you don't want to add yourself, maybe because you're already in, you can always add someone else with the [`AddChatUserRequest`](https://lonamiwebs.github.io/Telethon/methods/messages/add_chat_user.html), which use is very straightforward: + +```python +from telethon.tl.functions.messages import AddChatUserRequest +from telethon.helpers import get_input_peer + +client.invoke(AddChatUserRequest( + chat_id, + get_input_peer(user_to_add), + fwd_limit=10 # allow the user to see the 10 last messages +)) ``` \ No newline at end of file