from hydrogram import Client
from config import API_HASH, API_ID, BOT_TOKEN, SUDO
from .logs import LOGGER


class Bot(Client):
    def __init__(self):
        super().__init__(
            name="session/AutoSubBot",
            bot_token=BOT_TOKEN,
            api_id=API_ID,
            api_hash=API_HASH,
            plugins=dict(root="base/plugins"),
            sleep_threshold=60,
            workers=10,
            max_concurrent_transmissions=10
            )

    async def start(self):
        await super().start()
        me = await self.get_me()
        text = f"New session started for {me.first_name}({me.username})"
        try: await self.send_message(SUDO[0], text)
        except: pass
        LOGGER.info(text)

    async def stop(self):
        await super().stop()
        LOGGER.info("Session stopped. Bye!!")
