Telethon.errors.rpcerrorlist.PeerIdInvalidError: использовался недопустимый узел. Может быть, InputPeerChat(chat_id=....Python

Программы на Python
Гость
Telethon.errors.rpcerrorlist.PeerIdInvalidError: использовался недопустимый узел. Может быть, InputPeerChat(chat_id=....

Сообщение Гость »

Код: Выделить всё

from telethon import TelegramClient, connection, utils
import asyncio
import socks
import random
import time
from telethon.tl.types import InputPeerChat
import nest_asyncio
nest_asyncio.apply()
B = []
A = ["1", "2", "3", "4"]
b = int(len(A) - 1)
api_id = hash
api_hash = 'id'
async def groups():
global entity
async with TelegramClient('3', api_id, api_hash, proxy=(socks.SOCKS5, 'ip', port, True, 'login', 'pwd')) as client:
async for dialog in client.iter_dialogs():
if dialog.is_group:
print('{:>14}: {}'.format(dialog.id, dialog.title))
entity = await client.get_input_entity(dialog.id)
#print(entity)
B.append(entity)

return B
asyncio.run(groups())
async def main():
for i in B:
u = len(B) - 1
while u != -1:
u -= 1
x = B[u]
print(x)
async with TelegramClient('5', api_id, api_hash, proxy=(socks.SOCKS5, 'ip', port, True, 'login', 'pwd')) as client:
await client.send_message(entity=x, message=str(A[random.randint(0, b)]))
asyncio.run(main())
id, hash, ip, port, login, pwd is correct. I just removed 'em (confident ;p ).
Somehow one variant of this code worked once. I think that the given entity is incorrect.
I tried to type entity manually - didnt work.


Источник: https://stackoverflow.com/questions/781 ... used-may-b

Вернуться в «Python»