admin管理员组

文章数量:1335871

i was trying to solve this problem in telethon from a few days , when i run this code @client.on(events.NewMessage(chats=channel_to_listen())) async def all_messages_handler(event): run(event.raw_text) return 0 client.start() it work but after a while , it print a lot of this line because the client wait for the result of the fucntion , and there is a new message to handle , so the creation of wrong session ID

Security error while unpacking a received message: Server replied with a wrong session ID (see FAQ for details)

and the solution is to run it whith async loops as you see in this example

import asyncio
@client.on(events.NewMessage(chats=channel_to_listen()))
async def all_messages_handler(event):
    
    # Create task to run the function in background
    loop = asyncio.get_event_loop()
    # Just create the task directly from run_in_executor
    loop.run_in_executor(None, run, event.raw_text)

have a good day.

making the telethon client run smoothly without blockage, and i get a lot of this message Security error while unpacking a received message: Server replied with a wrong session ID (see FAQ for details) so i fix it using async

本文标签: