Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
KSKOP69 committed Oct 31, 2024
1 parent 6d3f1a1 commit 91e1c4b
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions AlexaMusic/core/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,47 @@


import sys

from pyrogram import Client
from telethon import TelegramClient, events
from telethon.tl.types import PeerChannel
from telethon.errors import ChatAdminRequiredError
import config
from ..logging import LOGGER
from pyrogram.enums import ChatMemberStatus


class AlexaBot(Client):
class AlexaBot(TelegramClient):
def __init__(self):
super().__init__(
"MusicBot",
api_id=config.API_ID,
api_hash=config.API_HASH,
bot_token=config.BOT_TOKEN,
sleep_threshold=180,
max_concurrent_transmissions=4,
workers=50,
api_hash=config.API_HASH
)
self.bot_token = config.BOT_TOKEN
self.username = None
self.id = None
self.name = None
LOGGER(__name__).info(f"Starting Bot...")

async def start(self):
await super().start()
await super().start(bot_token=self.bot_token)
get_me = await self.get_me()
self.username = get_me.username
self.id = get_me.id
self.mention = get_me.mention
if get_me.last_name:
self.name = get_me.first_name + " " + get_me.last_name
else:
self.name = get_me.first_name
try:
await self.send_message(
config.LOG_GROUP_ID, "» ᴍᴜsɪᴄ ʙᴏᴛ sᴛᴀʀᴛᴇᴅ, ᴡᴀɪᴛɪɴɢ ғᴏʀ ᴀssɪsᴛᴀɴᴛ..."
PeerChannel(config.LOG_GROUP_ID),
"» ᴍᴜsɪᴄ ʙᴏᴛ sᴛᴀʀᴛᴇᴅ, ᴡᴀɪᴛɪɴɢ ғᴏʀ ᴀssɪsᴛᴀɴᴛ..."
)
except:
except ChatAdminRequiredError:
LOGGER(__name__).error(
"Bot has failed to access the log Group. Make sure that you have added your bot to your log channel and promoted as admin!"
"Bot has failed to access the log Group. Make sure that you have added your bot to your log channel and promoted it as admin!"
)
sys.exit()
a = await self.get_chat_member(config.LOG_GROUP_ID, self.id)
if a.status != ChatMemberStatus.ADMINISTRATOR:
participant = await self.get_participant(config.LOG_GROUP_ID, self.id)
if not participant.is_admin:
LOGGER(__name__).error("Please promote Bot as Admin in Logger Group")
sys.exit()
if get_me.last_name:
self.name = get_me.first_name + " " + get_me.last_name
else:
self.name = get_me.first_name
LOGGER(__name__).info(f"MusicBot Started as {self.name}")

0 comments on commit 91e1c4b

Please sign in to comment.