I’m making a telegram channel admin control script that needs checking channel in a loop. I also want some message handlers checking for messages. Here is a part of my code:
async def main(): while True: .... (some code) log=await client.get_admin_log(await client.get_entity(chat),limit=1) .... (some code here) @client.on(telethon.events.NewMessage) async def message_handler(m): .... (handle messages) client.start()
If i use client.loop.run_until_complete(main()), message handler won’t work but main runs prefectly. and if I use client.run_until_disconnected() and run main in another loop using another thread, it stucks at get_admin_log. now what shall I do? (I tried to run main in message handler when a specefic message arrives(I send it manually when I run it) . it runned main but handled messages no more)
Advertisement
Answer
Try async while, and if posible try to use another code(dont use while) beacase its endless.