[Python] Using Telethon with webhooks

Discussão em 'Python' iniciado por Stack, Junho 26, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using the telethon lib to build a telegram bot. However, when trying to implement a webhook system, to avoid polling, I get this exception:

    raise RuntimeError('The asyncio event loop must not change after connection (see the FAQ for details)')
    RuntimeError: The asyncio event loop must not change after connection (see the FAQ for details)


    I've checked the FAQ and got a few hints at the problem. However, this made me wonder, is there a simpler way to use a webhook and easily dispatch the updates to telethon client?

    Any help is appreciated, I'm stuck.

    I've tried running my server with asyncio.run(), however that triggered even more exceptions.

    I even tried to write:

    client.loop.run_until_complete(uvicorn.run(app, host="localhost", port=8001))


    But I still get the same exception.

    Continue reading...

Compartilhe esta Página