A
A
Alex_8882021-03-11 13:35:50
Bots
Alex_888, 2021-03-11 13:35:50

How to organize simultaneous work of several sessions of "userbots" in one pyrogram client?

I use pyrogram.
It is necessary that 2-3 sessions (userbots) work simultaneously in one client.
the view is that it is done through multithreading or asynchrony. But I can't find any example.
I would be grateful for help, and a good example in doubly!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sheff98, 2021-07-29
@Sheff98

from pyrogram import Client, idle
from pyrogram.handlers import MessageHandler

my_apps = [
    Client("session1",  app, "hash"),
    Client("session2",  app, "hash"),
    Client("session3",  app, "hash"),
]

async def test(client, message):
     print(message)

for app in my_apps:
    app.add_handler(MessageHandler(test))
    app.start()

idle()

for app in my_apps:
    app.stop()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question