MCPcopy Create free account
hub / github.com/TechifyBots/File-Stream-Bot / initialize_clients

Function initialize_clients

biisal/bot/clients.py:11–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9
10
11async def initialize_clients():
12 multi_clients[0] = StreamBot
13 work_loads[0] = 0
14 all_tokens = TokenParser().parse_from_env()
15 if not all_tokens:
16 print("No additional clients found, using default client")
17 return
18
19 async def start_client(client_id, token):
20 try:
21 print(f"Starting - Client {client_id}")
22 if client_id == len(all_tokens):
23 await asyncio.sleep(2)
24 print("This will take some time, please wait...")
25 client = await Client(
26 name=str(client_id),
27 api_id=Var.API_ID,
28 api_hash=Var.API_HASH,
29 bot_token=token,
30 sleep_threshold=Var.SLEEP_THRESHOLD,
31 no_updates=True,
32 in_memory=True
33 ).start()
34 work_loads[client_id] = 0
35 return client_id, client
36 except Exception:
37 logging.error(f"Failed starting Client - {client_id} Error:", exc_info=True)
38
39 clients = await asyncio.gather(*[start_client(i, token) for i, token in all_tokens.items()])
40 multi_clients.update(dict(clients))
41 if len(multi_clients) != 1:
42 Var.MULTI_CLIENT = True
43 print("Multi-Client Mode Enabled")
44 else:
45 print("No additional clients were initialized, using default client")

Callers 1

start_servicesFunction · 0.90

Calls 3

TokenParserClass · 0.90
start_clientFunction · 0.85
parse_from_envMethod · 0.80

Tested by

no test coverage detected