Skip to content

[FAQ] run multiple bots simultaneously

Housa Hitomi edited this page Mar 22, 2023 · 3 revisions

for python>=3.10:

import asyncio

from khl import Bot

bot1 = Bot('token')
bot2 = Bot('token')
bot3 = Bot('token')


async def main():
    await asyncio.gather(bot1.start(), bot2.start(), bot3.start())


asyncio.run(main())

for python<3.10:

import asyncio

from khl import Bot

bot1 = Bot('token')
bot2 = Bot('token')
bot3 = Bot('token')

asyncio.get_event_loop().run_until_complete(
    asyncio.gather(bot1.start(), bot2.start(), bot3.start())
)