Spaces:
Paused
Paused
| # | |
| # Copyright (C) 2021-2022 by TeamYukki@Github, < https://github.com/TeamYukki >. | |
| # | |
| # This file is part of < https://github.com/TeamYukki/YukkiMusicBot > project, | |
| # and is released under the "GNU v3.0 License Agreement". | |
| # Please see < https://github.com/TeamYukki/YukkiMusicBot/blob/master/LICENSE > | |
| # | |
| # All rights reserved. | |
| import sys | |
| from pyrogram import Client | |
| import config | |
| from ..logging import LOGGER | |
| assistants = [] | |
| assistantids = [] | |
| multi_clients = {} | |
| work_loads = {} | |
| async def req_client(): | |
| index = min(work_loads, key=work_loads.get) | |
| faster_client = multi_clients[index] | |
| response = dict(index=index, client=faster_client) | |
| return response | |
| class Userbot(Client): | |
| def __init__(self): | |
| self.one = Client( | |
| name="1", | |
| api_id=config.API_ID, | |
| api_hash=config.API_HASH, | |
| session_string=str(config.STRING1), | |
| no_updates=True, | |
| ) | |
| self.two = Client( | |
| name="2", | |
| api_id=config.API_ID, | |
| api_hash=config.API_HASH, | |
| session_string=str(config.STRING2), | |
| no_updates=True, | |
| ) | |
| self.three = Client( | |
| name="3", | |
| api_id=config.API_ID, | |
| api_hash=config.API_HASH, | |
| session_string=str(config.STRING3), | |
| no_updates=True, | |
| ) | |
| self.four = Client( | |
| name="4", | |
| api_id=config.API_ID, | |
| api_hash=config.API_HASH, | |
| session_string=str(config.STRING4), | |
| no_updates=True, | |
| ) | |
| self.five = Client( | |
| name="5", | |
| api_id=config.API_ID, | |
| api_hash=config.API_HASH, | |
| session_string=str(config.STRING5), | |
| no_updates=True, | |
| ) | |
| async def start(self): | |
| LOGGER(__name__).info(f"Starting Assistant Clients") | |
| if config.STRING1: | |
| await self.one.start() | |
| assistants.append(1) | |
| try: | |
| await self.one.send_message(config.LOG_GROUP_ID, f"Assistant Started") | |
| except: | |
| LOGGER(__name__).error( | |
| f"Assistant Account 1 has failed to access the log Group. Make sure that you have added your assistant to your log group and promoted as admin! " | |
| ) | |
| sys.exit() | |
| get_me = await self.one.get_me() | |
| self.one.username = get_me.username | |
| self.one.id = get_me.id | |
| assistantids.append(get_me.id) | |
| if get_me.last_name: | |
| self.one.name = (get_me.first_name + " " + get_me.last_name) | |
| else: | |
| self.one.name = get_me.first_name | |
| LOGGER(__name__).info(f"Assistant Started as {self.one.name}") | |
| if config.STRING2: | |
| await self.two.start() | |
| assistants.append(2) | |
| try: | |
| await self.two.send_message( | |
| config.LOG_GROUP_ID, "Assistant Started" | |
| ) | |
| except: | |
| LOGGER(__name__).error( | |
| f"Assistant Account 2 has failed to access the log Group. Make sure that you have added your assistant to your log group and promoted as admin! " | |
| ) | |
| sys.exit() | |
| get_me = await self.two.get_me() | |
| self.two.username = get_me.username | |
| self.two.id = get_me.id | |
| assistantids.append(get_me.id) | |
| if get_me.last_name: | |
| self.two.name = ( | |
| get_me.first_name + " " + get_me.last_name | |
| ) | |
| else: | |
| self.two.name = get_me.first_name | |
| LOGGER(__name__).info( | |
| f"Assistant Two Started as {self.two.name}" | |
| ) | |
| if config.STRING3: | |
| await self.three.start() | |
| assistants.append(3) | |
| try: | |
| await self.three.send_message( | |
| config.LOG_GROUP_ID, "Assistant Started" | |
| ) | |
| except: | |
| LOGGER(__name__).error( | |
| f"Assistant Account 3 has failed to access the log Group. Make sure that you have added your assistant to your log group and promoted as admin! " | |
| ) | |
| sys.exit() | |
| get_me = await self.three.get_me() | |
| self.three.username = get_me.username | |
| self.three.id = get_me.id | |
| assistantids.append(get_me.id) | |
| if get_me.last_name: | |
| self.three.name = ( | |
| get_me.first_name + " " + get_me.last_name | |
| ) | |
| else: | |
| self.three.name = get_me.first_name | |
| LOGGER(__name__).info( | |
| f"Assistant Three Started as {self.three.name}" | |
| ) | |
| if config.STRING4: | |
| await self.four.start() | |
| assistants.append(4) | |
| try: | |
| await self.four.send_message( | |
| config.LOG_GROUP_ID, "Assistant Started" | |
| ) | |
| except: | |
| LOGGER(__name__).error( | |
| f"Assistant Account 4 has failed to access the log Group. Make sure that you have added your assistant to your log group and promoted as admin! " | |
| ) | |
| sys.exit() | |
| get_me = await self.four.get_me() | |
| self.four.username = get_me.username | |
| self.four.id = get_me.id | |
| assistantids.append(get_me.id) | |
| if get_me.last_name: | |
| self.four.name = ( | |
| get_me.first_name + " " + get_me.last_name | |
| ) | |
| else: | |
| self.four.name = get_me.first_name | |
| LOGGER(__name__).info( | |
| f"Assistant Four Started as {self.four.name}" | |
| ) | |
| if config.STRING5: | |
| await self.five.start() | |
| assistants.append(5) | |
| try: | |
| await self.five.send_message( | |
| config.LOG_GROUP_ID, "Assistant Started" | |
| ) | |
| except: | |
| LOGGER(__name__).error( | |
| f"Assistant Account 5 has failed to access the log Group. Make sure that you have added your assistant to your log group and promoted as admin! " | |
| ) | |
| sys.exit() | |
| get_me = await self.five.get_me() | |
| self.five.username = get_me.username | |
| self.five.id = get_me.id | |
| assistantids.append(get_me.id) | |
| if get_me.last_name: | |
| self.five.name = ( | |
| get_me.first_name + " " + get_me.last_name | |
| ) | |
| else: | |
| self.five.name = get_me.first_name | |
| LOGGER(__name__).info( | |
| f"Assistant Five Started as {self.five.name}" | |
| ) | |