'How can I disconnect telethon client, when an event handler does not received any new message event, even after waiting for specific time?

I wanna disconnect client if I didn't received any message even after waiting for 2 minutes.

But it keeps on waiting for ever.

I feel await_for is an alternative but I looking for solution right here itself anyone please help.

Thanks in advance.!!

client.connect()
#send message in chat

@client.on(events.NewMessage)
async def handler(event):
# wait for some reply message
    if received message:
        # do some thing
    else no message:
        client.disconnect()

client.run_until_diconnected()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source