В чём ошибка кода?

Хочу добавить пользователя в чат, но выдаёт ошибку

from telethon import TelegramClient

api_id = 00
api_hash = "00"
phone = '+0'
client = TelegramClient('session_name', api_id, api_hash)
client.start()
client.send_message('me', 'Hello! Talking to you from Telethon')

from telethon.tl.functions.messages import AddChatUserRequest
client(AddChatUserRequest(
    chat_id = -000 , #chat_id
         user_id = 0000, # id приглашенного
    fwd_limit=10  # Allow the user to see the 10 last messages
))


Traceback (most recent call last):
  File "C:/Users/Gegam/pypy/PYTHOOON/777.py", line 26, in <module>
    client(AddChatUserRequest(
  File "C:\Users\Gegam\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telethon\sync.py", line 39, in syncified
    return loop.run_until_complete(coro)
  File "C:\Users\Gegam\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 612, in run_until_complete
    return future.result()
  File "C:\Users\Gegam\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telethon\client\users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
  File "C:\Users\Gegam\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telethon\client\users.py", line 39, in _call
    await r.resolve(self, utils)
  File "C:\Users\Gegam\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telethon\tl\functions\messages.py", line 125, in resolve
    self.user_id = utils.get_input_user(await client.get_input_entity(self.user_id))
  File "C:\Users\Gegam\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telethon\client\users.py", line 466, in get_input_entity
    raise ValueError(
ValueError: Could not find the input entity for PeerUser(user_id=459306221) (PeerUser). Please read https://docs.telethon.dev/en/latest/concepts/entities.html to find out more details.
  • Вопрос задан
  • 307 просмотров
Пригласить эксперта
Ответы на вопрос 2
bravebug
@bravebug
Что-то мне подсказывает, что переменные api_id, api_hash, phone, chat_id, user_id должны быть не взятыми с потолка данными.
Ответ написан
Zachey
@Zachey
Ошибка в тут - user_id = 0000, # id, почитай тут www.python.org/peps/pep-0263.html
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы