E
E
Ernest Vardanyan2020-06-19 00:36:15
Python
Ernest Vardanyan, 2020-06-19 00:36:15

How to add a user to a telegram chat?

Hello everyone, I have a code and there is a function, it collects an audience, just gets their data from the chat. Having received their data, that is, id and username, I want to add the users that I received to the chat, which I will create later. There are 2 codes in the documentation, they are essentially the same:

Первый:

from telethon.sync import TelegramClient
from telethon import functions, types

with TelegramClient(name, api_id, api_hash) as client:
 result = client(functions.messages.GetMessagesViewsRequest(
 peer='username',
 id=[42],
 increment=False
 ))
 for x in result:
 print(x)

Второй:

await client(GetMessagesViewsRequest(
    peer=channel,
    id=msg_ids,
    increment=True
))


But, no matter how I write data to variables, an error appears, if it doesn’t make it difficult for you, you can simply explain what you need to make it work fine, I’ll leave a documentation link:

https://docs.telethon.dev/en/latest/examples /chats... (at the very bottom)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question