This commit is contained in:
levina 2021-10-27 21:08:39 +07:00 committed by GitHub
parent 8abd0736c0
commit 4ebace210a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,12 +2,12 @@ import os
import re import re
import asyncio import asyncio
from driver.veez import call_py from driver.veez import call_py
from config import BOT_USERNAME
from pytgcalls import StreamType from pytgcalls import StreamType
from driver.filters import command from driver.filters import command
from pyrogram.types import Message from pyrogram.types import Message
from pyrogram import Client, filters from pyrogram import Client, filters
from youtubesearchpython import VideosSearch from youtubesearchpython import VideosSearch
from config import BOT_USERNAME, IMG_1, IMG_2
from driver.queues import QUEUE, add_to_queue from driver.queues import QUEUE, add_to_queue
from pytgcalls.types.input_stream import AudioPiped from pytgcalls.types.input_stream import AudioPiped
@ -18,7 +18,7 @@ def ytsearch(query):
for r in search.result()["result"]: for r in search.result()["result"]:
ytid = r['id'] ytid = r['id']
if len(r['title']) > 34: if len(r['title']) > 34:
songname = r['title'][:35] + "..." songname = r['title'][:45] + "..."
else: else:
songname = r['title'] songname = r['title']
url = f"https://www.youtube.com/watch?v={ytid}" url = f"https://www.youtube.com/watch?v={ytid}"
@ -47,6 +47,20 @@ async def ytdl(link):
@Client.on_message(command(["play", f"play@{BOT_USERNAME}"]) & other_filters) @Client.on_message(command(["play", f"play@{BOT_USERNAME}"]) & other_filters)
async def play(client, m: Message): async def play(client, m: Message):
keyboard = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="✨ ɢʀᴏᴜᴘ",
url=f"https://t.me/{GROUP_SUPPORT}"),
InlineKeyboardButton(
text="🌻 ᴄʜᴀɴɴᴇʟ",
url=f"https://t.me/{UPDATES_CHANNEL}")
]
]
)
replied = m.reply_to_message replied = m.reply_to_message
chat_id = m.chat.id chat_id = m.chat.id
if replied: if replied:
@ -56,14 +70,19 @@ async def play(client, m: Message):
link = replied.link link = replied.link
if replied.audio: if replied.audio:
if replied.audio.title: if replied.audio.title:
songname = replied.audio.title[:35] + "..." songname = replied.audio.title[:45] + "..."
else: else:
songname = replied.audio.file_name[:35] + "..." songname = replied.audio.file_name[:45] + "..."
elif replied.voice: elif replied.voice:
songname = "Voice Note" songname = "Voice Note"
if chat_id in QUEUE: if chat_id in QUEUE:
pos = add_to_queue(chat_id, songname, dl, link, "Audio", 0) pos = add_to_queue(chat_id, songname, dl, link, "Audio", 0)
await suhu.edit(f"💡 **Track added to the queue**\n🔢 At position » `{pos}`") await suhu.delete()
await m.reply_photo(
photo=f"{IMG_1}",
caption=f"💡 **Track added to the queue**\n\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`",
reply_markup=keyboard,
)
else: else:
await call_py.join_group_call( await call_py.join_group_call(
chat_id, chat_id,
@ -73,7 +92,12 @@ async def play(client, m: Message):
stream_type=StreamType().pulse_stream, stream_type=StreamType().pulse_stream,
) )
add_to_queue(chat_id, songname, dl, link, "Audio", 0) add_to_queue(chat_id, songname, dl, link, "Audio", 0)
await suhu.edit(f"💡 **music streaming started.**\n\n🏷 **Name:** [{songname}]({link})\n💬 **Chat:** `{chat_id}`", disable_web_page_preview=True) await m.reply_photo(
photo=f"{IMG_2}",
caption=f"💡 **music streaming started.**\n\n🏷 **Name:** [{songname}]({link})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}",
disable_web_page_preview=True,
reply_markup=keyboard,
)
else: else:
if len(m.command) < 2: if len(m.command) < 2:
await m.reply("» reply to an **audio file** or **give something to search.**") await m.reply("» reply to an **audio file** or **give something to search.**")
@ -92,7 +116,12 @@ async def play(client, m: Message):
else: else:
if chat_id in QUEUE: if chat_id in QUEUE:
pos = add_to_queue(chat_id, songname, ytlink, url, "Audio", 0) pos = add_to_queue(chat_id, songname, ytlink, url, "Audio", 0)
await suhu.edit(f"💡 **Track added to the queue**\n🔢 At position » `{pos}`") await suhu.delete()
await m.reply_photo(
photo=f"{IMG_1}",
caption=f"💡 **Track added to the queue**\n\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`",
reply_markup=keyboard,
)
else: else:
try: try:
await call_py.join_group_call( await call_py.join_group_call(
@ -103,7 +132,13 @@ async def play(client, m: Message):
stream_type=StreamType().pulse_stream, stream_type=StreamType().pulse_stream,
) )
add_to_queue(chat_id, songname, ytlink, url, "Audio", 0) add_to_queue(chat_id, songname, ytlink, url, "Audio", 0)
await suhu.edit(f"💡 **music streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n💬 **Chat:** `{chat_id}`", disable_web_page_preview=True) await suhu.delete()
await m.reply_photo(
photo=f"{IMG_2}",
caption=f"💡 **music streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}",
disable_web_page_preview=True,
reply_markup=keyboard,
)
except Exception as ep: except Exception as ep:
await suhu.edit(f"❌ issues: `{ep}`") await suhu.edit(f"❌ issues: `{ep}`")
@ -125,7 +160,12 @@ async def play(client, m: Message):
else: else:
if chat_id in QUEUE: if chat_id in QUEUE:
pos = add_to_queue(chat_id, songname, ytlink, url, "Audio", 0) pos = add_to_queue(chat_id, songname, ytlink, url, "Audio", 0)
await suhu.edit(f"💡 **Track added to the queue**\n🔢 At position » `{pos}`") await suhu.delete()
await m.reply_photo(
photo=f"{IMG_1}",
caption=f"💡 **Track added to the queue**\n\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`",
reply_markup=keyboard,
)
else: else:
try: try:
await call_py.join_group_call( await call_py.join_group_call(
@ -136,12 +176,33 @@ async def play(client, m: Message):
stream_type=StreamType().pulse_stream, stream_type=StreamType().pulse_stream,
) )
add_to_queue(chat_id, songname, ytlink, url, "Audio", 0) add_to_queue(chat_id, songname, ytlink, url, "Audio", 0)
await suhu.edit(f"💡 **music streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n💬 **Chat:** `{chat_id}`", disable_web_page_preview=True) await suhu.delete()
await m.reply_photo(
photo=f"{IMG_2}",
caption=f"💡 **music streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}",
disable_web_page_preview=True,
reply_markup=keyboard,
)
except Exception as ep: except Exception as ep:
await suhu.edit(f"❌ issues: `{ep}`") await suhu.edit(f"❌ issues: `{ep}`")
@Client.on_message(command(["stream", f"stream@{BOT_USERNAME}"]) & other_filters) @Client.on_message(command(["stream", f"stream@{BOT_USERNAME}"]) & other_filters)
async def stream(client, m: Message): async def stream(client, m: Message):
keyboard = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="✨ ɢʀᴏᴜᴘ",
url=f"https://t.me/{GROUP_SUPPORT}"),
InlineKeyboardButton(
text="🌻 ᴄʜᴀɴɴᴇʟ",
url=f"https://t.me/{UPDATES_CHANNEL}")
]
]
)
chat_id = m.chat.id chat_id = m.chat.id
if len(m.command) < 2: if len(m.command) < 2:
await m.reply("» give me a live-link/m3u8 url/youtube link to stream.") await m.reply("» give me a live-link/m3u8 url/youtube link to stream.")
@ -162,7 +223,12 @@ async def stream(client, m: Message):
else: else:
if chat_id in QUEUE: if chat_id in QUEUE:
pos = add_to_queue(chat_id, "Radio", livelink, link, "Audio", 0) pos = add_to_queue(chat_id, "Radio", livelink, link, "Audio", 0)
await suhu.edit(f"💡 **Track added to the queue**\n🔢 At position » `{pos}`") await suhu.delete()
await m.reply_photo(
photo=f"{IMG_1}",
caption=f"💡 **Track added to the queue**\n\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {m.from_user.mention()}\n🔢 **At position »** `{pos}`",
reply_markup=keyboard,
)
else: else:
try: try:
await call_py.join_group_call( await call_py.join_group_call(
@ -173,6 +239,12 @@ async def stream(client, m: Message):
stream_type=StreamType().pulse_stream, stream_type=StreamType().pulse_stream,
) )
add_to_queue(chat_id, "Radio", livelink, link, "Audio", 0) add_to_queue(chat_id, "Radio", livelink, link, "Audio", 0)
await suhu.edit(f"💡 **[Radio]({link}) live stream started.**\n💬 Chat: `{chat_id}`", disable_web_page_preview=True) await suhu.delete()
await m.reply_photo(
photo=f"{IMG_2}",
caption=f"💡 **[Radio Live]({link}) stream started.**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {m.from_user.mention()}",
disable_web_page_preview=True,
reply_markup=keyboard,
)
except Exception as ep: except Exception as ep:
await suhu.edit(f"❌ issues: `{ep}`") await suhu.edit(f"❌ issues: `{ep}`")