video-stream/program/callback.py
2022-02-08 09:45:36 +07:00

251 lines
10 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Copyright (C) 2021 By VeezMusicProject
from driver.queues import QUEUE
from driver.database.dbpunish import is_gbanned_user
from pyrogram import Client, filters
from program.utils.inline import menu_markup
from pyrogram.types import CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup
from config import (
ASSISTANT_NAME,
BOT_NAME,
BOT_USERNAME,
GROUP_SUPPORT,
OWNER_NAME,
UPDATES_CHANNEL,
)
@Client.on_callback_query(filters.regex("home_start"))
async def cbstart(_, 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
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
💭 **[{BOT_NAME}](https://t.me/{BOT_USERNAME}) allows you to play music and video on groups through the new Telegram's video chats!**
💡 **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",
)
],
[InlineKeyboardButton("❓ Basic Guide", callback_data="user_guide")],
[
InlineKeyboardButton("📚 Commands", callback_data="command_list"),
InlineKeyboardButton("❤ Donate", url=f"https://t.me/{OWNER_NAME}"),
],
[
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,
)
@Client.on_callback_query(filters.regex("user_guide"))
async def cbguides(_, 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
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.
3.) Invite @{ASSISTANT_NAME} 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)`).
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(
[[InlineKeyboardButton("🔙 Go Back", callback_data="home_start")]]
),
)
@Client.on_callback_query(filters.regex("command_list"))
async def cbcmds(_, 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
await query.answer("commands menu")
await query.edit_message_text(
f"""✨ **Hello [{query.message.chat.first_name}](tg://user?id={query.message.chat.id}) !**
» Check out the menu below to read the module information & see the list of available Commands !
⚡ __Powered by {BOT_NAME} A.I__""",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("Admin Commands", callback_data="admin_command"),
InlineKeyboardButton("Sudo Commands", callback_data="sudo_command"),
],[
InlineKeyboardButton("Users Commands", callback_data="user_command")
],[
InlineKeyboardButton("🔙 Go Back", callback_data="home_start")
],
]
),
)
@Client.on_callback_query(filters.regex("user_command"))
async def cbbasic(_, 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
await query.answer("basic commands")
await query.edit_message_text(
f"""✏️ Command list for all user.
» /play (song name/link) - play music on video chat
» /vplay (video name/link) - play video on video chat
» /vstream - play live video from yt live/m3u8
» /playlist - show you the playlist
» /lyric (query) - scrap the song lyric
» /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(
[[InlineKeyboardButton("🔙 Go Back", callback_data="command_list")]]
),
)
@Client.on_callback_query(filters.regex("admin_command"))
async def cbadmin(_, 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
await query.answer("admin commands")
await query.edit_message_text(
f"""✏️ Command list for group admin.
» /pause - pause the stream
» /resume - resume the stream
» /skip - switch to next stream
» /stop - stop the streaming
» /vmute - mute the userbot on voice chat
» /vunmute - unmute the userbot on voice chat
» /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(
[[InlineKeyboardButton("🔙 Go Back", callback_data="command_list")]]
),
)
@Client.on_callback_query(filters.regex("sudo_command"))
async def cbsudo(_, 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
await query.answer("sudo commands")
await query.edit_message_text(
f"""✏️ Command list for sudo user.
» /stats - get the bot current statistic
» /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
» /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
» /speedtest - run the bot server speedtest
» /sysinfo - show the system information
» /update - update your bot to latest version
» /restart - restart your bot directly
» /leaveall - order userbot to leave from all group
» /leavebot (`chat id`) - order bot to leave from the group you specify
» /broadcast (`message`) - send a broadcast message to all groups entered by bot
» /broadcast_pin (`message`) - send a broadcast message to all groups entered by bot with the chat pin
» /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("stream_menu_panel"))
async def cbmenu(_, 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)
chat_id = query.message.chat.id
user_id = query.message.from_user.id
buttons = menu_markup(user_id)
chat = query.message.chat.title
if chat_id in QUEUE:
await query.edit_message_text(
f"⚙️ **Settings of** {chat}\n\n⏸ : pause stream\n▶️ : resume stream\n🔇 : mute userbot\n🔊 : unmute userbot\n⏹ : stop stream",
reply_markup=InlineKeyboardMarkup(buttons),
)
else:
await query.answer("❌ nothing is currently streaming", show_alert=True)
@Client.on_callback_query(filters.regex("set_close"))
async def close_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.message.delete()
@Client.on_callback_query(filters.regex("close_panel"))
async def close_panel(_, 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
await query.message.delete()