File size: 6,797 Bytes
5d668bd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | from helper.database import codeflixbots as db
from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
from config import Txt
@Client.on_message(filters.command("metadata"))
async def metadata(client, message):
user_id = message.from_user.id
# Fetch user metadata from the database
current = await db.get_metadata(user_id)
title = await db.get_title(user_id)
author = await db.get_author(user_id)
artist = await db.get_artist(user_id)
video = await db.get_video(user_id)
audio = await db.get_audio(user_id)
subtitle = await db.get_subtitle(user_id)
# Display the current metadata
text = f"""
**㊋ Yᴏᴜʀ Mᴇᴛᴀᴅᴀᴛᴀ ɪꜱ ᴄᴜʀʀᴇɴᴛʟʏ: {current}**
**◈ Tɪᴛʟᴇ ▹** `{title if title else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}`
**◈ Aᴜᴛʜᴏʀ ▹** `{author if author else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}`
**◈ Aʀᴛɪꜱᴛ ▹** `{artist if artist else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}`
**◈ Aᴜᴅɪᴏ ▹** `{audio if audio else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}`
**◈ Sᴜʙᴛɪᴛʟᴇ ▹** `{subtitle if subtitle else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}`
**◈ Vɪᴅᴇᴏ ▹** `{video if video else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}`
"""
# Inline buttons to toggle metadata
buttons = [
[
InlineKeyboardButton(f"On{' ✅' if current == 'On' else ''}", callback_data='on_metadata'),
InlineKeyboardButton(f"Off{' ✅' if current == 'Off' else ''}", callback_data='off_metadata')
],
[
InlineKeyboardButton("How to Set Metadata", callback_data="metainfo")
]
]
keyboard = InlineKeyboardMarkup(buttons)
await message.reply_text(text=text, reply_markup=keyboard, disable_web_page_preview=True)
@Client.on_callback_query(filters.regex(r"on_metadata|off_metadata|metainfo"))
async def metadata_callback(client, query: CallbackQuery):
user_id = query.from_user.id
data = query.data
if data == "on_metadata":
await db.set_metadata(user_id, "On")
elif data == "off_metadata":
await db.set_metadata(user_id, "Off")
elif data == "metainfo":
await query.message.edit_text(
text=Txt.META_TXT,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup([
[
InlineKeyboardButton("Hᴏᴍᴇ", callback_data="home"),
InlineKeyboardButton("close", callback_data="close")
]
])
)
return
# Fetch updated metadata after toggling
current = await db.get_metadata(user_id)
title = await db.get_title(user_id)
author = await db.get_author(user_id)
artist = await db.get_artist(user_id)
video = await db.get_video(user_id)
audio = await db.get_audio(user_id)
subtitle = await db.get_subtitle(user_id)
# Updated metadata message after toggle
text = f"""
**㊋ Yᴏᴜʀ Mᴇᴛᴀᴅᴀᴛᴀ ɪꜱ ᴄᴜʀʀᴇɴᴛʟʏ: {current}**
**◈ Tɪᴛʟᴇ ▹** `{title if title else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}`
**◈ Aᴜᴛʜᴏʀ ▹** `{author if author else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}`
**◈ Aʀᴛɪꜱᴛ ▹** `{artist if artist else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}`
**◈ Aᴜᴅɪᴏ ▹** `{audio if audio else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}`
**◈ Sᴜʙᴛɪᴛʟᴇ ▹** `{subtitle if subtitle else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}`
**◈ Vɪᴅᴇᴏ ▹** `{video if video else 'Nᴏᴛ ꜰᴏᴜɴᴅ'}`
"""
# Update inline buttons
buttons = [
[
InlineKeyboardButton(f"On{' ✅' if current == 'On' else ''}", callback_data='on_metadata'),
InlineKeyboardButton(f"Off{' ✅' if current == 'Off' else ''}", callback_data='off_metadata')
],
[
InlineKeyboardButton("How to Set Metadata", callback_data="metainfo")
]
]
await query.message.edit_text(text=text, reply_markup=InlineKeyboardMarkup(buttons), disable_web_page_preview=True)
@Client.on_message(filters.private & filters.command('settitle'))
async def title(client, message):
if len(message.command) == 1:
return await message.reply_text(
"**Gɪᴠᴇ Tʜᴇ Tɪᴛʟᴇ\n\nExᴀᴍᴩʟᴇ:- /settitle Encoded By @Animes_Cruise**")
title = message.text.split(" ", 1)[1]
await db.set_title(message.from_user.id, title=title)
await message.reply_text("**✅ Tɪᴛʟᴇ Sᴀᴠᴇᴅ**")
@Client.on_message(filters.private & filters.command('setauthor'))
async def author(client, message):
if len(message.command) == 1:
return await message.reply_text(
"**Gɪᴠᴇ Tʜᴇ Aᴜᴛʜᴏʀ\n\nExᴀᴍᴩʟᴇ:- /setauthor @Animes_Cruise**")
author = message.text.split(" ", 1)[1]
await db.set_author(message.from_user.id, author=author)
await message.reply_text("**✅ Aᴜᴛʜᴏʀ Sᴀᴠᴇᴅ**")
@Client.on_message(filters.private & filters.command('setartist'))
async def artist(client, message):
if len(message.command) == 1:
return await message.reply_text(
"**Gɪᴠᴇ Tʜᴇ Aʀᴛɪꜱᴛ\n\nExᴀᴍᴩʟᴇ:- /setartist @Animes_Cruise**")
artist = message.text.split(" ", 1)[1]
await db.set_artist(message.from_user.id, artist=artist)
await message.reply_text("**✅ Aʀᴛɪꜱᴛ Sᴀᴠᴇᴅ**")
@Client.on_message(filters.private & filters.command('setaudio'))
async def audio(client, message):
if len(message.command) == 1:
return await message.reply_text(
"**Gɪᴠᴇ Tʜᴇ Aᴜᴅɪᴏ Tɪᴛʟᴇ\n\nExᴀᴍᴩʟᴇ:- /setaudio @Animes_Cruise**")
audio = message.text.split(" ", 1)[1]
await db.set_audio(message.from_user.id, audio=audio)
await message.reply_text("**✅ Aᴜᴅɪᴏ Sᴀᴠᴇᴅ**")
@Client.on_message(filters.private & filters.command('setsubtitle'))
async def subtitle(client, message):
if len(message.command) == 1:
return await message.reply_text(
"**Gɪᴠᴇ Tʜᴇ Sᴜʙᴛɪᴛʟᴇ Tɪᴛʟᴇ\n\nExᴀᴍᴩʟᴇ:- /setsubtitle @Animes_Cruise**")
subtitle = message.text.split(" ", 1)[1]
await db.set_subtitle(message.from_user.id, subtitle=subtitle)
await message.reply_text("**✅ Sᴜʙᴛɪᴛʟᴇ Sᴀᴠᴇᴅ**")
@Client.on_message(filters.private & filters.command('setvideo'))
async def video(client, message):
if len(message.command) == 1:
return await message.reply_text(
"**Gɪᴠᴇ Tʜᴇ Vɪᴅᴇᴏ Tɪᴛʟᴇ\n\nExᴀᴍᴩʟᴇ:- /setvideo Encoded by @Animes_Cruise**")
video = message.text.split(" ", 1)[1]
await db.set_video(message.from_user.id, video=video)
await message.reply_text("**✅ Vɪᴅᴇᴏ Sᴀᴠᴇᴅ**")
|