treewide: some fixes & improvements
This commit is contained in:
parent
2cf26a7258
commit
f19605a7a5
@ -36,7 +36,6 @@ from pyrogram import Client
|
|||||||
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
|
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
|
||||||
from pyrogram.types import InlineKeyboardMarkup, Message
|
from pyrogram.types import InlineKeyboardMarkup, Message
|
||||||
|
|
||||||
from pytgcalls import idle
|
|
||||||
from pytgcalls import StreamType
|
from pytgcalls import StreamType
|
||||||
from pytgcalls.types.input_stream import AudioVideoPiped
|
from pytgcalls.types.input_stream import AudioVideoPiped
|
||||||
from pytgcalls.types.input_stream.quality import (
|
from pytgcalls.types.input_stream.quality import (
|
||||||
@ -45,6 +44,7 @@ from pytgcalls.types.input_stream.quality import (
|
|||||||
LowQualityVideo,
|
LowQualityVideo,
|
||||||
MediumQualityVideo,
|
MediumQualityVideo,
|
||||||
)
|
)
|
||||||
|
from pytgcalls.exceptions import NoVideoSourceFound, NoActiveGroupCall, GroupCallNotFound
|
||||||
|
|
||||||
from youtubesearchpython import VideosSearch
|
from youtubesearchpython import VideosSearch
|
||||||
|
|
||||||
@ -152,6 +152,7 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
|
|||||||
)
|
)
|
||||||
remove_if_exists(image)
|
remove_if_exists(image)
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
await loser.edit("🔄 Joining Group Call...")
|
await loser.edit("🔄 Joining Group Call...")
|
||||||
gcname = m.chat.title
|
gcname = m.chat.title
|
||||||
ctitle = await CHAT_TITLE(gcname)
|
ctitle = await CHAT_TITLE(gcname)
|
||||||
@ -187,8 +188,12 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
|
|||||||
f"⏱️ **Duration:** `{duration}`\n"
|
f"⏱️ **Duration:** `{duration}`\n"
|
||||||
f"🧸 **Request by:** {requester}",
|
f"🧸 **Request by:** {requester}",
|
||||||
)
|
)
|
||||||
await idle()
|
|
||||||
remove_if_exists(image)
|
remove_if_exists(image)
|
||||||
|
except (NoActiveGroupCall, GroupCallNotFound):
|
||||||
|
await suhu.delete()
|
||||||
|
await remove_active_chat(chat_id)
|
||||||
|
traceback.print_exc()
|
||||||
|
await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !")
|
||||||
else:
|
else:
|
||||||
await m.reply(
|
await m.reply(
|
||||||
"» reply to an **video file** or **give something to search.**"
|
"» reply to an **video file** or **give something to search.**"
|
||||||
@ -210,16 +215,17 @@ async def vplay(c: Client, m: Message):
|
|||||||
try:
|
try:
|
||||||
ubot = me_user.id
|
ubot = me_user.id
|
||||||
b = await c.get_chat_member(chat_id, ubot)
|
b = await c.get_chat_member(chat_id, ubot)
|
||||||
if b.status == "kicked":
|
if b.status == "banned":
|
||||||
await c.unban_chat_member(chat_id, ubot)
|
await m.reply_text("❌ The userbot is banned in this chat, unban the userbot first to be able to play music !")
|
||||||
|
return
|
||||||
|
invitelink = (await c.get_chat(chat_id)).invite_link
|
||||||
|
if not invitelink:
|
||||||
|
await c.export_chat_invite_link(chat_id)
|
||||||
invitelink = (await c.get_chat(chat_id)).invite_link
|
invitelink = (await c.get_chat(chat_id)).invite_link
|
||||||
if not invitelink:
|
if invitelink.startswith("https://t.me/+"):
|
||||||
await c.export_chat_invite_link(chat_id)
|
invitelink = invitelink.replace(
|
||||||
invitelink = (await c.get_chat(chat_id)).invite_link
|
"https://t.me/+", "https://t.me/joinchat/"
|
||||||
if invitelink.startswith("https://t.me/+"):
|
)
|
||||||
invitelink = invitelink.replace(
|
|
||||||
"https://t.me/+", "https://t.me/joinchat/"
|
|
||||||
)
|
|
||||||
await user.join_chat(invitelink)
|
await user.join_chat(invitelink)
|
||||||
await remove_active_chat(chat_id)
|
await remove_active_chat(chat_id)
|
||||||
except UserNotParticipant:
|
except UserNotParticipant:
|
||||||
@ -308,12 +314,19 @@ async def vplay(c: Client, m: Message):
|
|||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
reply_markup=InlineKeyboardMarkup(buttons),
|
||||||
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||||
)
|
)
|
||||||
await idle()
|
|
||||||
remove_if_exists(image)
|
remove_if_exists(image)
|
||||||
except Exception as ep:
|
except (NoActiveGroupCall, GroupCallNotFound):
|
||||||
await loser.delete()
|
await loser.delete()
|
||||||
await remove_active_chat(chat_id)
|
await remove_active_chat(chat_id)
|
||||||
await m.reply_text(f"🚫 error: `{ep}`")
|
await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !")
|
||||||
|
except NoVideoSourceFound:
|
||||||
|
await suhu.delete()
|
||||||
|
await remove_active_chat(chat_id)
|
||||||
|
await m.reply_text("❌ The content you provide to play has no video source")
|
||||||
|
except NoAudioSourceFound:
|
||||||
|
await suhu.delete()
|
||||||
|
await remove_active_chat(chat_id)
|
||||||
|
await m.reply_text("❌ The content you provide to play has no audio source")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if len(m.command) < 2:
|
if len(m.command) < 2:
|
||||||
@ -384,12 +397,19 @@ async def vplay(c: Client, m: Message):
|
|||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
reply_markup=InlineKeyboardMarkup(buttons),
|
||||||
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||||
)
|
)
|
||||||
await idle()
|
|
||||||
remove_if_exists(image)
|
remove_if_exists(image)
|
||||||
except Exception as ep:
|
except (NoActiveGroupCall, GroupCallNotFound):
|
||||||
await loser.delete()
|
await loser.delete()
|
||||||
await remove_active_chat(chat_id)
|
await remove_active_chat(chat_id)
|
||||||
await m.reply_text(f"🚫 error: `{ep}`")
|
await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !")
|
||||||
|
except NoVideoSourceFound:
|
||||||
|
await suhu.delete()
|
||||||
|
await remove_active_chat(chat_id)
|
||||||
|
await m.reply_text("❌ The content you provide to play has no video source")
|
||||||
|
except NoAudioSourceFound:
|
||||||
|
await suhu.delete()
|
||||||
|
await remove_active_chat(chat_id)
|
||||||
|
await m.reply_text("❌ The content you provide to play has no audio source")
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["vstream", f"vstream@{BOT_USERNAME}"]) & other_filters)
|
@Client.on_message(command(["vstream", f"vstream@{BOT_USERNAME}"]) & other_filters)
|
||||||
@ -406,16 +426,17 @@ async def vstream(c: Client, m: Message):
|
|||||||
try:
|
try:
|
||||||
ubot = me_user.id
|
ubot = me_user.id
|
||||||
b = await c.get_chat_member(chat_id, ubot)
|
b = await c.get_chat_member(chat_id, ubot)
|
||||||
if b.status == "kicked":
|
if b.status == "banned":
|
||||||
await c.unban_chat_member(chat_id, ubot)
|
await m.reply_text("❌ The userbot is banned in this chat, unban the userbot first to be able to play music !")
|
||||||
|
return
|
||||||
|
invitelink = (await c.get_chat(chat_id)).invite_link
|
||||||
|
if not invitelink:
|
||||||
|
await c.export_chat_invite_link(chat_id)
|
||||||
invitelink = (await c.get_chat(chat_id)).invite_link
|
invitelink = (await c.get_chat(chat_id)).invite_link
|
||||||
if not invitelink:
|
if invitelink.startswith("https://t.me/+"):
|
||||||
await c.export_chat_invite_link(chat_id)
|
invitelink = invitelink.replace(
|
||||||
invitelink = (await c.get_chat(chat_id)).invite_link
|
"https://t.me/+", "https://t.me/joinchat/"
|
||||||
if invitelink.startswith("https://t.me/+"):
|
)
|
||||||
invitelink = invitelink.replace(
|
|
||||||
"https://t.me/+", "https://t.me/joinchat/"
|
|
||||||
)
|
|
||||||
await user.join_chat(invitelink)
|
await user.join_chat(invitelink)
|
||||||
await remove_active_chat(chat_id)
|
await remove_active_chat(chat_id)
|
||||||
except UserNotParticipant:
|
except UserNotParticipant:
|
||||||
@ -517,8 +538,11 @@ async def vstream(c: Client, m: Message):
|
|||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
reply_markup=InlineKeyboardMarkup(buttons),
|
||||||
caption=f"🗂 **Name:** [{songname}]({url}) | `live`\n🧸 **Requested by:** {requester}",
|
caption=f"🗂 **Name:** [{songname}]({url}) | `live`\n🧸 **Requested by:** {requester}",
|
||||||
)
|
)
|
||||||
await idle()
|
except (NoActiveGroupCall, GroupCallNotFound):
|
||||||
except Exception as ep:
|
|
||||||
await loser.delete()
|
await loser.delete()
|
||||||
await remove_active_chat(chat_id)
|
await remove_active_chat(chat_id)
|
||||||
await m.reply_text(f"🚫 error: `{ep}`")
|
await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !")
|
||||||
|
except BaseException as err:
|
||||||
|
await loser.delete()
|
||||||
|
await remove_active_chat(chat_id)
|
||||||
|
await m.reply_text(f"🚫 error: `{err}`")
|
||||||
|
Loading…
Reference in New Issue
Block a user