Skip to content

Commit

Permalink
Create until.py
Browse files Browse the repository at this point in the history
  • Loading branch information
xtsea authored Oct 19, 2024
1 parent 445b069 commit a11ee4b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions akenoai/until.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
class LoopAutomatic:
@classmethod
async def start_running_loop(cls, sessions, ClientClass) -> None:
for i, data in enumerate(sessions):
yield i, data

@classmethod
async def run_until_complete(
cls,
sessions,
ClientClass,
logs=None,
my_api_id=None,
my_api_hash=None,
plugins_dir=None,
is_token: bool = False,
) -> None:
async for i, data in LoopAutomatic.start_running_loop(sessions, ClientClass):
if is_token:
bot_token_str = data.get("bot_token")
client = ClientClass(
api_id=api_id,
api_hash=api_hash,
bot_token=bot_token_str,
plugins=dict(root=plugins_dir),
)
else:
api_id = data.get("api_id")
api_hash = data.get("api_hash")
session_str = data.get("session")
client = ClientClass(
api_id=my_api_id,
api_hash=my_api_hash,
bot_token=bot_token_str,
plugins=dict(root=plugins_dir)
)
await client.start()
get_me = await client.get_me()
if logs:
logs.info(f"Starting: {i + 1} {get_me.first_name}")
else:
print(f"Starting: {i + 1} {get_me.first_name}")

0 comments on commit a11ee4b

Please sign in to comment.