2

I am using pyrogram to run multiple clients ( about 30 client ) at the same time . I need clients to appear online in groups . They are showing online status in profile but not in groups ( only about 2 users appear online in groups even if all 30 users are online )

Each client is running in a separate thread with asyncio lib , and each running user check if user status is offline and sends UpdateStatus request to set status to online , here is the main function that is running as a thread :

async def openUser(session_string):

   app = Client("sessions/session", session_string=session_string, api_id=API_ID, api_hash=API_HASH, in_memory=True,  app_version="1.2.3", device_model="PC", system_version="Linux")
   await app.start()
   me = await app.get_me()
   print(f'success login user: {me.first_name}')
   while True:
      if UserStatus(me.status) == "OFFLINE":
         await app.invoke(UpdateStatus(offline=False))

I am running threads with asyncio this way :

tasks = [openUser(obj["session"]) for obj in db]
      await asyncio.gather(*tasks)

so how to make all users appear as online in group members list ?

Nour Eldin
  • 21
  • 3

0 Answers0