【发布时间】:2021-09-20 00:13:59
【问题描述】:
我正在使用 Telethon,出于某种原因,我需要使用一个会话来连接和断开我的客户端,所以我希望在收到来自特定聊天的事件(来自特定机器人的一条消息)后,客户端将断开连接,这就是我正在做的……
bot_id = "chat id of telegram bot"
await client.connect()
@client.on(events.NewMessage(chats=bot_id))
async def imp_msg(event):
# print(event)
await client.send_message(123456, event.message)
await client.start()
如果我使用 await client.disconnect() 它不会做任何更改并给我sqlite3.OperationalError: database is locked 可能我做错了。
await client.connect()
@client.on(events.NewMessage(chats=bot_id))
async def imp_msg(event):
# print(event)
await client.send_message(123456, event.message)
await client.disconnect()
await client.start()
【问题讨论】:
-
@ColinShark 这就是我在描述中已经在谈论的内容,但是如果您在发表任何评论之前付出一点努力
标签: python python-3.x asynchronous telethon