【发布时间】:2021-06-11 19:54:50
【问题描述】:
我在 python3.7 中使用 Telethon。 我想获取我所有联系人的列表并向他们发送“嗨”。
代码:
async def main():
try:
async with TelegramClient('anon', api_id, api_hash) as client:
result = await client(functions.contacts.GetContactsRequest(
hash=0
))
await print(result.stringify())
except Exception as e:
print(e)
for u in result.users:
await client.send_message(InputPeerUser(u.id, u.access_hash), "hi")
with client:
client.loop.run_until_complete(main())
但我得到了错误:raise ConnectionError('Cannot send requests while disconnected') ConnectionError:断开连接时无法发送请求
【问题讨论】:
标签: python-3.x telegram telethon