Skip to content

Commit

Permalink
Update __init__.py and play_video.py
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Aug 4, 2023
1 parent 5b83baf commit 834fab8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions tlg_bot/kreacher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
8 changes: 4 additions & 4 deletions tlg_bot/kreacher/plugins/play_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def _(event):

@kreacher.on(events.NewMessage(pattern="^[?!/]play_video"))
async def play_video(event):
msg = await event.reply("🔄 <i>Processing ...</i>", parse_mode="HTML")
msg = await event.reply("🔄 <i>Processing...</i>", parse_mode="HTML")
chat = await event.get_chat()
media = await event.get_reply_message()
if not media and not ' ' in event.message.message:
Expand All @@ -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("<i>Joining the voice chat...</i>", parse_mode="HTML")
await call_py.start(chat.id)
if match:
await msg.edit("🔄 `Starting YouTube Video Stream ...`")
await msg.edit("🔄 <i>Starting YouTube Video Stream...</i>", parse_mode="HTML")
try:
meta = ydl().extract_info(url=url, download=False)
formats = meta.get('formats', [meta])
Expand All @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit 834fab8

Please sign in to comment.