Good afternoon. Until recently, the script worked well:
from telethon.sync import TelegramClient
api_id = '***'
api_hash = '***'
session_name = 'my_session'
client = TelegramClient(session_name, api_id, api_hash)
async def send_telegram_message():
await client.start()
# Отправка сообщения
chat_id = -******
message = '123'
await client.send_message(chat_id, message)
with client:
client.loop.run_until_complete(send_telegram_message())
But, exactly after I was appointed the owner of the group, messages stopped being sent and the following error appeared:
Traceback (most recent call last):
File "/root/send_group2.py", line 20, in <module>
client.loop.run_until_complete(send_telegram_message())
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/root/send_group2.py", line 16, in send_telegram_message
await client.send_message(chat_id, message)
File "/usr/local/lib/python3.10/dist-packages/telethon/client/messages.py", line 905, in send_message
result = await self(request)
File "/usr/local/lib/python3.10/dist-packages/telethon/client/users.py", line 30, in __call__
return await self._call(self._sender, request, ordered=ordered)
File "/usr/local/lib/python3.10/dist-packages/telethon/client/users.py", line 87, in _call
result = await future
telethon.errors.rpcerrorlist.PeerIdInvalidError: An invalid Peer was used. Make sure to pass the right peer type and that the value is valid (for instance, bots cannot start conversations) (caused by SendMessageRequest)
Tell me how can I fix it?
I tried different peering methods, but nothing helps.
New contributor
user26324545 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.