video-stream/program/callback.py

294 lines
12 KiB
Python
Raw Normal View History

2022-01-31 12:41:47 +00:00
# Copyright (C) 2021 By VeezMusicProject
2022-02-11 16:10:25 +00:00
from driver.core import user, bot
2022-01-31 12:41:47 +00:00
from driver.queues import QUEUE
2022-02-06 05:35:32 +00:00
from driver.database.dbpunish import is_gbanned_user
2022-01-31 12:41:47 +00:00
from pyrogram import Client, filters
2022-02-10 02:26:16 +00:00
from program.utils.inline import menu_markup, stream_markup
2022-01-31 12:41:47 +00:00
from pyrogram.types import CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup
2022-02-10 03:12:00 +00:00
2022-01-31 12:41:47 +00:00
from config import (
BOT_USERNAME,
GROUP_SUPPORT,
2022-02-11 06:02:56 +00:00
OWNER_USERNAME,
2022-01-31 12:41:47 +00:00
UPDATES_CHANNEL,
2022-02-08 22:50:24 +00:00
SUDO_USERS,
OWNER_ID,
2022-01-31 12:41:47 +00:00
)
2022-02-07 15:03:17 +00:00
@Client.on_callback_query(filters.regex("home_start"))
2022-02-08 22:50:24 +00:00
async def set_start(_, query: CallbackQuery):
2022-02-06 06:49:45 +00:00
user_id = query.from_user.id
2022-02-11 16:10:25 +00:00
BOT_NAME = (await bot.get_me()).first_name
2022-02-06 05:35:32 +00:00
if await is_gbanned_user(user_id):
2022-02-06 06:49:45 +00:00
await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
2022-02-06 05:35:32 +00:00
return
2022-01-31 12:41:47 +00:00
await query.answer("home start")
await query.edit_message_text(
f"""✨ **Welcome [{query.message.chat.first_name}](tg://user?id={query.message.chat.id}) !**\n
2022-02-11 11:42:37 +00:00
💭 [{BOT_NAME}](https://t.me/{BOT_USERNAME}) **Is a bot to play music and video in groups, through the Telegram Group video chat!**
2022-01-31 12:41:47 +00:00
💡 **Find out all the Bot's commands and how they work by clicking on the » 📚 Commands button!**
🔖 **To know how to use this bot, please click on the » Basic Guide button!**""",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
" Add me to your Group ",
url=f"https://t.me/{BOT_USERNAME}?startgroup=true",
)
],
2022-02-07 23:53:59 +00:00
[InlineKeyboardButton("❓ Basic Guide", callback_data="user_guide")],
2022-01-31 12:41:47 +00:00
[
2022-02-07 23:53:59 +00:00
InlineKeyboardButton("📚 Commands", callback_data="command_list"),
2022-02-11 06:02:56 +00:00
InlineKeyboardButton("❤ Donate", url=f"https://t.me/{OWNER_USERNAME}"),
2022-01-31 12:41:47 +00:00
],
[
InlineKeyboardButton(
"👥 Official Group", url=f"https://t.me/{GROUP_SUPPORT}"
),
InlineKeyboardButton(
"📣 Official Channel", url=f"https://t.me/{UPDATES_CHANNEL}"
),
],
[
InlineKeyboardButton(
"🌐 Source Code", url="https://github.com/levina-lab/video-stream"
)
],
]
),
disable_web_page_preview=True,
)
2022-02-07 15:03:17 +00:00
@Client.on_callback_query(filters.regex("user_guide"))
2022-02-08 22:50:24 +00:00
async def set_guide(_, query: CallbackQuery):
2022-02-06 06:49:45 +00:00
user_id = query.from_user.id
2022-02-11 15:09:03 +00:00
ass_uname = (await user.get_me()).username
2022-02-06 05:35:32 +00:00
if await is_gbanned_user(user_id):
2022-02-06 06:49:45 +00:00
await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
2022-02-06 05:35:32 +00:00
return
2022-01-31 12:41:47 +00:00
await query.answer("user guide")
await query.edit_message_text(
f"""❓ How to use this Bot ?, read the Guide below !
1.) First, add this bot to your Group.
2.) Then, promote this bot as administrator on the Group also give all permissions except Anonymous admin.
3.) After promoting this bot, type /reload in Group to update the admin data.
2022-02-11 15:09:03 +00:00
3.) Invite @{ass_uname} to your group or type /userbotjoin to invite her, unfortunately the userbot will joined by itself when you type `/play (song name)` or `/vplay (song name)`.
2022-01-31 12:41:47 +00:00
4.) Turn on/Start the video chat first before start to play video/music.
`- END, EVERYTHING HAS BEEN SETUP -`
📌 If the userbot not joined to video chat, make sure if the video chat already turned on and the userbot in the chat.
💡 If you have a follow-up questions about this bot, you can tell it on my support chat here: @{GROUP_SUPPORT}.""",
reply_markup=InlineKeyboardMarkup(
2022-02-07 15:03:17 +00:00
[[InlineKeyboardButton("🔙 Go Back", callback_data="home_start")]]
2022-01-31 12:41:47 +00:00
),
)
2022-02-07 15:03:17 +00:00
@Client.on_callback_query(filters.regex("command_list"))
2022-02-08 22:50:24 +00:00
async def set_commands(_, query: CallbackQuery):
2022-02-06 06:49:45 +00:00
user_id = query.from_user.id
2022-02-06 05:35:32 +00:00
if await is_gbanned_user(user_id):
2022-02-06 06:49:45 +00:00
await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
2022-02-06 05:35:32 +00:00
return
2022-01-31 12:41:47 +00:00
await query.answer("commands menu")
await query.edit_message_text(
f"""✨ **Hello [{query.message.chat.first_name}](tg://user?id={query.message.chat.id}) !**
2022-02-07 15:03:17 +00:00
» Check out the menu below to read the module information & see the list of available Commands !
2022-01-31 12:41:47 +00:00
2022-02-11 11:19:22 +00:00
All commands can be used with (`! / .`) handler""",
2022-01-31 12:41:47 +00:00
reply_markup=InlineKeyboardMarkup(
[
[
2022-02-11 11:19:22 +00:00
InlineKeyboardButton("👮🏻‍♀️ Admins Commands", callback_data="admin_command"),
2022-02-10 14:08:10 +00:00
],[
2022-02-11 11:19:22 +00:00
InlineKeyboardButton("👩🏻‍💼 Users Commands", callback_data="user_command"),
2022-01-31 12:41:47 +00:00
],[
2022-02-08 22:50:24 +00:00
InlineKeyboardButton("Sudo Commands", callback_data="sudo_command"),
InlineKeyboardButton("Owner Commands", callback_data="owner_command"),
2022-01-31 12:41:47 +00:00
],[
2022-02-07 15:03:17 +00:00
InlineKeyboardButton("🔙 Go Back", callback_data="home_start")
2022-01-31 12:41:47 +00:00
],
]
),
)
2022-02-07 15:03:17 +00:00
@Client.on_callback_query(filters.regex("user_command"))
2022-02-08 22:50:24 +00:00
async def set_user(_, query: CallbackQuery):
2022-02-06 06:49:45 +00:00
user_id = query.from_user.id
2022-02-06 05:35:32 +00:00
if await is_gbanned_user(user_id):
2022-02-06 06:49:45 +00:00
await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
2022-02-06 05:35:32 +00:00
return
2022-01-31 12:41:47 +00:00
await query.answer("basic commands")
await query.edit_message_text(
2022-02-07 15:03:17 +00:00
f"""✏️ Command list for all user.
2022-01-31 12:41:47 +00:00
» /play (song name/link) - play music on video chat
» /vplay (video name/link) - play video on video chat
2022-02-11 11:19:22 +00:00
» /vstream (m3u8/yt live link) - play live stream video
» /playlist - see the current playing song
2022-02-07 15:03:17 +00:00
» /lyric (query) - scrap the song lyric
2022-01-31 12:41:47 +00:00
» /video (query) - download video from youtube
» /song (query) - download song from youtube
» /search (query) - search a youtube video link
» /ping - show the bot ping status
» /uptime - show the bot uptime status
» /alive - show the bot alive info (in Group only)
__Powered by {BOT_NAME} AI__""",
reply_markup=InlineKeyboardMarkup(
2022-02-07 15:03:17 +00:00
[[InlineKeyboardButton("🔙 Go Back", callback_data="command_list")]]
2022-01-31 12:41:47 +00:00
),
)
2022-02-07 15:03:17 +00:00
@Client.on_callback_query(filters.regex("admin_command"))
2022-02-08 22:50:24 +00:00
async def set_admin(_, query: CallbackQuery):
2022-02-06 06:49:45 +00:00
user_id = query.from_user.id
2022-02-06 05:35:32 +00:00
if await is_gbanned_user(user_id):
2022-02-06 06:49:45 +00:00
await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
2022-02-06 05:35:32 +00:00
return
2022-01-31 12:41:47 +00:00
await query.answer("admin commands")
await query.edit_message_text(
2022-02-07 15:03:17 +00:00
f"""✏️ Command list for group admin.
2022-01-31 12:41:47 +00:00
2022-02-11 11:19:22 +00:00
» /pause - pause the current track being played
» /resume - play the previously paused track
» /skip - goes to the next track
» /stop - stop playback of the track and clears the queue
» /vmute - mute the streamer userbot on group call
» /vunmute - unmute the streamer userbot on group call
2022-01-31 12:41:47 +00:00
» /volume `1-200` - adjust the volume of music (userbot must be admin)
» /reload - reload bot and refresh the admin data
» /userbotjoin - invite the userbot to join group
» /userbotleave - order userbot to leave from group
__Powered by {BOT_NAME} AI__""",
reply_markup=InlineKeyboardMarkup(
2022-02-07 15:03:17 +00:00
[[InlineKeyboardButton("🔙 Go Back", callback_data="command_list")]]
2022-01-31 12:41:47 +00:00
),
)
2022-02-10 14:08:10 +00:00
2022-02-07 15:03:17 +00:00
@Client.on_callback_query(filters.regex("sudo_command"))
2022-02-08 22:50:24 +00:00
async def set_sudo(_, query: CallbackQuery):
2022-02-06 06:49:45 +00:00
user_id = query.from_user.id
2022-02-06 05:35:32 +00:00
if await is_gbanned_user(user_id):
2022-02-06 06:49:45 +00:00
await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
2022-02-06 05:35:32 +00:00
return
2022-02-08 22:50:24 +00:00
if user_id not in SUDO_USERS:
2022-02-10 02:26:16 +00:00
await query.answer("⚠️ You don't have permissions to click this button\n\n» This button is reserved for sudo members of this bot.", show_alert=True)
2022-02-08 22:50:24 +00:00
return
2022-01-31 12:41:47 +00:00
await query.answer("sudo commands")
await query.edit_message_text(
2022-02-07 15:03:17 +00:00
f"""✏️ Command list for sudo user.
2022-01-31 12:41:47 +00:00
2022-02-05 05:41:23 +00:00
» /stats - get the bot current statistic
2022-02-11 11:19:22 +00:00
» /calls - show you the list of all active group call in database
2022-02-07 15:03:17 +00:00
» /block (`chat_id`) - use this to blacklist any group from using your bot
» /unblock (`chat_id`) - use this to whitelist any group from using your bot
» /blocklist - show you the list of all blacklisted chat
2022-01-31 12:41:47 +00:00
» /speedtest - run the bot server speedtest
» /sysinfo - show the system information
2022-02-08 22:50:24 +00:00
» /eval - execute any code (`developer stuff`)
» /sh - run any command (`developer stuff`)
__Powered by {BOT_NAME} AI__""",
reply_markup=InlineKeyboardMarkup(
[[InlineKeyboardButton("🔙 Go Back", callback_data="command_list")]]
),
)
@Client.on_callback_query(filters.regex("owner_command"))
async def set_owner(_, query: CallbackQuery):
user_id = query.from_user.id
if await is_gbanned_user(user_id):
await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
return
if user_id not in OWNER_ID:
2022-02-10 02:26:16 +00:00
await query.answer("⚠️ You don't have permissions to click this button\n\n» This button is reserved for owner of this bot.", show_alert=True)
2022-02-08 22:50:24 +00:00
return
await query.answer("owner commands")
await query.edit_message_text(
f"""✏️ Command list for bot owner.
» /gban (`username` or `user_id`) - for global banned people, can be used only in group
» /ungban (`username` or `user_id`) - for un-global banned people, can be used only in group
2022-01-31 12:41:47 +00:00
» /update - update your bot to latest version
2022-02-07 15:03:17 +00:00
» /restart - restart your bot directly
2022-01-31 12:41:47 +00:00
» /leaveall - order userbot to leave from all group
2022-01-31 13:57:14 +00:00
» /leavebot (`chat id`) - order bot to leave from the group you specify
2022-02-11 11:19:22 +00:00
» /broadcast (`message`) - send a broadcast message to all groups in bot database
» /broadcast_pin (`message`) - send a broadcast message to all groups in bot database with the chat pin
2022-01-31 12:41:47 +00:00
__Powered by {BOT_NAME} AI__""",
reply_markup=InlineKeyboardMarkup(
2022-02-07 15:03:17 +00:00
[[InlineKeyboardButton("🔙 Go Back", callback_data="command_list")]]
2022-01-31 12:41:47 +00:00
),
)
2022-02-07 15:03:17 +00:00
@Client.on_callback_query(filters.regex("stream_menu_panel"))
2022-02-08 22:50:24 +00:00
async def set_markup_menu(_, query: CallbackQuery):
2022-02-06 06:49:45 +00:00
user_id = query.from_user.id
2022-02-06 05:35:32 +00:00
if await is_gbanned_user(user_id):
2022-02-06 06:49:45 +00:00
await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
2022-02-06 05:35:32 +00:00
return
2022-01-31 12:41:47 +00:00
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
if not a.can_manage_voice_chats:
return await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True)
chat_id = query.message.chat.id
user_id = query.message.from_user.id
buttons = menu_markup(user_id)
if chat_id in QUEUE:
2022-02-10 13:54:02 +00:00
await query.answer("control panel opened")
2022-02-10 02:26:16 +00:00
await query.edit_message_reply_markup(reply_markup=InlineKeyboardMarkup(buttons))
2022-01-31 12:41:47 +00:00
else:
await query.answer("❌ nothing is currently streaming", show_alert=True)
2022-02-10 02:26:16 +00:00
@Client.on_callback_query(filters.regex("stream_home_panel"))
async def set_home_menu(_, query: CallbackQuery):
user_id = query.from_user.id
if await is_gbanned_user(user_id):
await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
return
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
if not a.can_manage_voice_chats:
return await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True)
await query.answer("control panel closed")
user_id = query.message.from_user.id
buttons = stream_markup(user_id)
await query.edit_message_reply_markup(reply_markup=InlineKeyboardMarkup(buttons))
2022-02-08 00:00:29 +00:00
@Client.on_callback_query(filters.regex("set_close"))
async def close_menu(_, query: CallbackQuery):
2022-02-06 06:49:45 +00:00
user_id = query.from_user.id
2022-02-06 05:35:32 +00:00
if await is_gbanned_user(user_id):
2022-02-06 06:49:45 +00:00
await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
2022-02-06 05:35:32 +00:00
return
2022-01-31 12:41:47 +00:00
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
if not a.can_manage_voice_chats:
return await query.answer("💡 Only admin with manage video chat permission that can tap this button !", show_alert=True)
await query.message.delete()
2022-02-07 15:37:44 +00:00
@Client.on_callback_query(filters.regex("close_panel"))
2022-02-08 00:00:29 +00:00
async def close_panel(_, query: CallbackQuery):
2022-02-07 15:37:44 +00:00
user_id = query.from_user.id
if await is_gbanned_user(user_id):
await query.answer("❗️ You've blocked from using this bot!", show_alert=True)
return
await query.message.delete()