From 834fab861a602712dc3a7117923a0cb4e0c25a8e Mon Sep 17 00:00:00 2001 From: Santiago Ramirez <94815926+SantiiRepair@users.noreply.github.com> Date: Fri, 4 Aug 2023 20:25:53 +0000 Subject: [PATCH] Update __init__.py and play_video.py --- tlg_bot/kreacher/__init__.py | 7 ++++--- tlg_bot/kreacher/plugins/play_video.py | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tlg_bot/kreacher/__init__.py b/tlg_bot/kreacher/__init__.py index 80b52f7..120b611 100644 --- a/tlg_bot/kreacher/__init__.py +++ b/tlg_bot/kreacher/__init__.py @@ -12,9 +12,10 @@ BOT_USERNAME = config.BOT_USERNAME ASSISTANT_ID = config.ASSISTANT_ID -bot = TelegramClient(None, api_id=config.API_ID, api_hash=config.API_HASH) -kreacher = bot.start(bot_token=config.BOT_TOKEN) +_bot = TelegramClient(None, api_id=config.API_ID, api_hash=config.API_HASH) +kreacher = _bot.start(bot_token=config.BOT_TOKEN) client = TelegramClient(None, config.API_ID, config.API_HASH) client.start() -_call_factory_py = GroupCallFactory(client, GroupCallFactory.MTPROTO_CLIENT_TYPE.TELETHON) +_call_factory_py = GroupCallFactory( + client, GroupCallFactory.MTPROTO_CLIENT_TYPE.TELETHON) call_py = _call_factory_py.get_group_call() diff --git a/tlg_bot/kreacher/plugins/play_video.py b/tlg_bot/kreacher/plugins/play_video.py index b6533e8..886e8f7 100644 --- a/tlg_bot/kreacher/plugins/play_video.py +++ b/tlg_bot/kreacher/plugins/play_video.py @@ -76,7 +76,7 @@ async def _(event): @kreacher.on(events.NewMessage(pattern="^[?!/]play_video")) async def play_video(event): - msg = await event.reply("🔄 Processing ...", parse_mode="HTML") + msg = await event.reply("🔄 Processing...", parse_mode="HTML") chat = await event.get_chat() media = await event.get_reply_message() if not media and not ' ' in event.message.message: @@ -89,8 +89,10 @@ async def play_video(event): return await msg.edit("❗ __Send Me An Live Stream Link / YouTube Video Link / Reply To An Video To Start Video Streaming!__") regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+" match = re.match(regex, url) + await msg.edit("Joining the voice chat...", parse_mode="HTML") + await call_py.start(chat.id) if match: - await msg.edit("🔄 `Starting YouTube Video Stream ...`") + await msg.edit("🔄 Starting YouTube Video Stream...", parse_mode="HTML") try: meta = ydl().extract_info(url=url, download=False) formats = meta.get('formats', [meta]) @@ -114,7 +116,6 @@ async def play_video(event): try: await sleep(2) - await call_py.start(chat.id) await call_py.start_video(link, with_audio=True, repeat=False) await msg.delete() await event.reply( @@ -139,7 +140,6 @@ async def play_video(event): try: await sleep(2) - await call_py.start(chat.id) await call_py.start_video(video, with_audio=True, repeat=False) await msg.delete() await event.reply(