I have a piece of code that is listening from a telegram group for new messages, I'm looking to avoid message are put in a queue and only listen for those that already exited from my loop, that loop could take 15 or 20 seconds iterating or doing some other stuff, but as soon the loop is finish, it will go and take a queued message and start iterating it again, is there any way to not put those message in a queue and listen only when it finishes iterating in the loop or when my code is not doing anything and just idle waiting for new messages?
This is what I currently have:
client = TelegramClient('session', API_ID, API_HASH)
@client.on(events.NewMessage(chats=chat_id))
async def my_event_handler(event):
text = event.raw_text
for i in items:
// do something that takes 15 or 20 seconds to finish
client.start()
client.run_until_disconnected()