randydev's picture
fix revert back and update
21bc372
raw
history blame
53.2 kB
# All credits to @xpushz
# lu mau kanger kah pasti noob aja
import time
import requests
import os
import re
import httpx
import aiofiles
import hashlib
import urllib.parse
import asyncio
from pyrogram import *
from pyrogram.enums import *
from pyrogram import Client, filters
from pyrogram.types import *
from pyrogram.errors import *
from akn.utils.logger import LOGS
from akn.utils.scripts import progress
from youtube_search import YoutubeSearch
from yt_dlp import YoutubeDL
from akn.utils.database import db
from akn.utils.driver import YoutubeDriver
from akn.utils.formatter import secs_to_mins
import akenoai as js
link_storage = {}
storage = {}
custom_loading = "<emoji id=5974235702701853774>πŸ—Ώ</emoji>"
TIKTOK_WEB = "https://www.tikwm.com"
OWNER_BOT_ID = 8109052455
COMMAND = """
**πŸ“₯ Social Media Downloader Commands**
**πŸ”— Direct Link Downloaders**
- `/fbdl` – Download Facebook videos.
- `/igdl` – Download Instagram videos/reels.
- `/twdl` – Download Twitter/X videos.
- `/ttdl` – Download TikTok videos.
- `/alldl` – Download Facebook, Instagram, Tiktok, Twitter(required cookies) etc videos.
- `/teraboxdl` – Download Terabox files (v1).
- `/terabox2dl` – Download Terabox files (v2).
**🎡 YouTube Tools**
- `/ytv` – Download YouTube videos in **MP4** format.
- `/yta` – Extract audio from YouTube videos in **MP3** format.
- `/ytva` – Search & download YouTube videos as **MP4**.
- `/ytsa` – Search & download YouTube audio as **MP3**.
- `/ytlink` – Search for YouTube videos.
"""
@Client.on_callback_query(filters.regex("^cclose"))
async def cb_cclose(client, query):
await query.message.delete()
@Client.on_callback_query(filters.regex("^author_cmd"))
async def cb_author_command(client, query):
is_sudo = await db.get_alldlbot_sudouser(client.me.id, query.from_user.id)
protect_own = await db.get_alldlbot_by_user_id(query.from_user.id)
if not protect_own and not is_sudo:
return await query.answer("You are not allowed here.", True)
author_commands = """
**πŸ” Owner-Only Commands**
**πŸ“Œ Channel & User Management:**
- `/addjoin` – Enable auto **force-subscribe** to a channel.
- `/addblacklist` – Ban a user from using bot commands.
- `/addsudo` – Add a user to the sudo list.
- `/delsudo` – Remove a user from the sudo list.
- `/listsudo` – View the list of sudo users.
- `/rmblacklist` – Unban a blacklisted user.
- `/blacklistchat` – Block a chat from using the bot.
- `/viewblacklistuser` – View the list of blacklisted users.
- `/whitelistchat` – Unblock a chat.
- `/blacklistedchat` – View blacklisted chats.
**πŸ“Š Stats & Maintenance:**
- `/stats` – View user statistics.
- `/rmdup` – Remove duplicate user entries.
- `/broadcast` – Send a message to all users.
**βš™οΈ Bot Settings:**
- `/nobutton` – Toggle **ON/OFF** the `/start` button.
- `/setpic` – Change the bot's display picture (resend if needed).
- `/delpic` – Remove bot display picture (resend if needed).
"""
keyboard_back = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="Close",
callback_data="cclose"
)
]
]
)
await query.edit_message_text(
text=author_commands,
reply_markup=keyboard_back
)
@Client.on_message(
~filters.scheduled
& filters.command(["start"])
& filters.private
& ~filters.forwarded
)
async def startbot(c, m):
if await db.get_alldlbot_is_blacklist_user(c.me.id, m.from_user.id):
return
buttons = [
[
InlineKeyboardButton(
text="Developer",
url=f"https://t.me/xtdevs"
),
InlineKeyboardButton(
text="Channel",
url='https://t.me/RendyProjects'
),
],
[
InlineKeyboardButton(
text="Author Commands",
callback_data='author_cmd'
)
]
]
buttons_start_in_group = [
[
InlineKeyboardButton(
text="Add to your group",
url=f"https://t.me/{c.me.username}?startgroup=true&admin=manage_chat+change_info+post_messages+edit_messages+delete_messages+invite_users+restrict_members+pin_messages+promote_members+manage_video_chats+anonymous=false"
)
],
[
InlineKeyboardButton(
text="Author Commands",
callback_data='author_cmd'
)
]
]
user_now = await db.get_alldlbot_by_no_button(c.me.id)
reply_markup = InlineKeyboardMarkup(buttons_start_in_group) if user_now else InlineKeyboardMarkup(buttons)
try:
await db.update_alldlbot_broadcast(c.me.id, m.from_user.id, "add")
is_pic, catbox_link = await db.get_pic_in_allbot(c.me.id)
if is_pic and catbox_link:
return await m.reply_photo(
photo=catbox_link,
caption=COMMAND,
reply_markup=reply_markup
)
return await m.reply_text(
text=COMMAND,
disable_web_page_preview=True,
reply_markup=reply_markup
)
except Exception as e:
await m.reply_text(f"Error: {e}")
class Tiktok:
@staticmethod
async def download(api_name, url):
response = requests.get("{}/api/?url={}".format(api_name, url))
if response.status_code != 200:
return "Error Response limits"
data_json = response.json()
author_tiktok = data_json["data"]["author"].get("nickname") or "Unknown"
play_tiktok = data_json["data"].get("play")
music_tiktok = data_json["data"]["music_info"].get("play")
return [
play_tiktok,
music_tiktok,
author_tiktok
]
def is_tiktok_url(url):
pattern = r"(https?)://(vt|www)\.tiktok\.com/(\w+)"
match = re.search(pattern, url)
return bool(match)
def generate_callback_data(user_id, query):
identifier = hashlib.md5(query.encode()).hexdigest()
callback_data = f"audiodownload_{user_id}_{identifier}"
link_storage[callback_data] = query
return callback_data
@Client.on_callback_query(filters.regex("^audiodownload_"))
async def callback_button(client: Client, cb: CallbackQuery):
try:
data = cb.data
query = link_storage.get(data)
if query:
response = await Tiktok.download(TIKTOK_WEB, query)
await client.send_audio(cb.message.chat.id, response[1])
await cb.answer("Audio sent successfully!")
else:
await cb.answer("Invalid or expired link.", show_alert=True)
except Exception as e:
await cb.answer(f"Error: {str(e)}", show_alert=True)
@Client.on_message(
~filters.scheduled
& filters.command(["stats"])
& ~filters.forwarded
)
async def statscmd(c, m):
is_sudo = await db.get_alldlbot_sudouser(c.me.id, m.from_user.id)
protect_own = await db.get_alldlbot_by_user_id(m.from_user.id)
if not protect_own and not is_sudo:
return await m.reply_text("You are not allowed here.")
try:
if m.chat.type.value != "supergroup":
return await m.reply_text("You can only group public not private")
await db.update_alldlbot_broadcast_in_group(c.me.id, m.chat.id, "add")
total_bl_users = await db.alldlbot_blacklist_stats(c.me.id)
total_users = await db.alldlbot_broadcast_stats(c.me.id)
await m.reply_text(f"**Total Users:** `{total_users}`\n**Total Blacklist Users:** `{total_bl_users}`")
except Exception as e:
await m.reply_text(f"Error: {e.MESSAGE}")
@Client.on_message(
~filters.scheduled
& filters.command(["delpic"])
& ~filters.forwarded
)
async def delpicincatbox(c, m):
is_sudo = await db.get_alldlbot_sudouser(c.me.id, m.from_user.id)
protect_own = await db.get_alldlbot_by_user_id(m.from_user.id)
if not protect_own and not is_sudo:
return await m.reply_text("You are not allowed here.")
mode = m.text.split(" ", 1)[1] if len(m.command) > 1 else None
if not mode:
return await m.reply_text("Example: `/delpic yes`")
try:
if mode == "yes":
_, catbox_link = await db.get_pic_in_allbot(c.me.id)
if not catbox_link:
return await m.reply_text("Not found pic")
await db.set_pic_in_allbot(c.me.id, catbox_link, False)
await m.reply_text(f"Successfully removed pic `{catbox_link}`.")
else:
await m.reply_text(f"Invalid command: /delpic yes")
except Exception as e:
await m.reply_text(f"Error: {e.MESSAGE}")
@Client.on_message(
~filters.scheduled
& filters.command(["setpic"])
& ~filters.forwarded
)
async def setpicincatbox(c, m):
is_sudo = await db.get_alldlbot_sudouser(c.me.id, m.from_user.id)
protect_own = await db.get_alldlbot_by_user_id(m.from_user.id)
if not protect_own and not is_sudo:
return await m.reply_text("You are not allowed here.")
link = m.text.split(" ", 1)[1] if len(m.command) > 1 else None
if not link:
return await m.reply_text("Example: `/setpic https://files.catbox.moe/y93h4b.jpg`")
if not link.startswith("https://files.catbox.moe/"):
return await m.reply_text("Invalid Link")
try:
await db.set_pic_in_allbot(c.me.id, link, True)
await m.reply_text(f"Successfully added pic set `{link}`.")
except Exception as e:
await m.reply_text(f"Error: {e.MESSAGE}")
@Client.on_message(
~filters.scheduled
& filters.command(["rmdup"])
& ~filters.forwarded
)
async def duplicate_remove(c, m):
is_sudo = await db.get_alldlbot_sudouser(c.me.id, m.from_user.id)
protect_own = await db.get_alldlbot_by_user_id(m.from_user.id)
if not protect_own and not is_sudo:
return await m.reply_text("You are not allowed here.")
if m.chat.type.value != "supergroup":
return await m.reply_text("You can only group public not private")
await db.update_alldlbot_broadcast_in_group(c.me.id, m.chat.id, "add")
user_id = None
if not m.reply_to_message:
if len(m.command) < 2:
return await m.reply_text(
"Reply to a user or pass a user_id to remvoe duplicate"
)
try:
getuser = m.command[1]
except Exception as e:
return await m.reply_text(f"`{str(e)}`")
else:
getuser = m.reply_to_message.from_user.id
try:
user_id = (await c.get_users(getuser)).id
await db.update_alldlbot_broadcast(c.me.id, user_id, "remove")
await m.reply_text(f"Successfully remove duplicate `{user_id}` from bots.")
except Exception as e:
await m.reply_text(f"Error: {e.MESSAGE}")
@Client.on_message(
~filters.scheduled
& filters.command(["addjoin"])
& ~filters.forwarded
)
async def auto_force_sub(client: Client, message: Message):
protect_own = await db.get_alldlbot_by_user_id(message.from_user.id)
if not protect_own:
return await message.reply_text("You are not allowed to add a force sub.")
if len(message.command) < 2:
return await message.reply_text("Please provide a channel username or ID.")
channel = message.command[1]
await db.add_forcesub_only_bot(client.me.id, channel)
await message.reply_text("Successfully added to force sub.")
@Client.on_message(
~filters.scheduled
& filters.command(["nobutton"])
& ~filters.forwarded
)
async def mode_button(client, message: Message):
is_sudo = await db.get_alldlbot_sudouser(client.me.id, message.from_user.id)
protect_own = await db.get_alldlbot_by_user_id(message.from_user.id)
if not protect_own and not is_sudo:
return await m.reply_text("You are not allowed here.") # type: ignore
if len(message.command) < 2:
return await message.reply_text(f"**Please provide a cmd /nobutton on/off to start button disabled or enabled")
cmd = message.command[1].lower().strip()
if cmd in ["on", "yes"]:
await db.add_alldlbot_by_no_button(client.me.id, True)
await message.reply_text(f"**Button disabled now!**")
elif cmd in ["off", "no"]:
await db.add_alldlbot_by_no_button(client.me.id, False)
await message.reply_text(f"**Button enabled now!**")
@Client.on_message(
~filters.scheduled
& filters.command(["ttdl"])
& ~filters.forwarded
)
async def tiktok_downloader(client: Client, message: Message):
user_id = message.from_user.id
if await db.get_alldlbot_is_blacklist_user(client.me.id, user_id):
return
if message.chat.type.value != "supergroup":
return await message.reply_text("You can only group public not private")
await db.update_alldlbot_broadcast_in_group(client.me.id, message.chat.id, "add")
user_name = message.from_user.first_name
nn = "[" + user_name + "](tg://user?id=" + str(user_id) + ")"
if not await db.get_forcesub_only_bot(client.me.id):
return await message.reply_text("This is the command /addjoin username channel and becomes admin on the channel")
update_channel = await db.get_forcesub_only_bot(client.me.id)
if update_channel:
try:
user = await client.get_chat_member(update_channel, user_id)
if user.status == ChatMemberStatus.BANNED:
await client.send_message(
message.chat.id,
text=f"**❌ {nn} anda telah di blokir dari grup dukungan**",
disable_web_page_preview=True,
)
return
except UserNotParticipant:
await client.send_message(
message.chat.id,
text=f"**πŸ‘‹πŸ» Halo {nn}\nα΄œΙ΄α΄›α΄œα΄‹ α΄α΄‡Ι΄Ι’ΚœΙͺΙ΄α΄…α΄€Κ€Ιͺ α΄˜α΄‡Ι΄Ι’Ι’α΄œΙ΄α΄€α΄€Ι΄ ʏᴀɴɒ Κ™α΄‡Κ€ΚŸα΄‡Κ™ΙͺΚœα΄€Ι΄ ʙᴏᴛ ΙͺΙ΄Ιͺ α΄…Ιͺ α΄‹Κœα΄œsᴜsα΄‹α΄€Ι΄ α΄œΙ΄α΄›α΄œα΄‹ ʏᴀɴɒ sα΄œα΄…α΄€Κœ ᴊᴏΙͺΙ΄ α΄…Ιͺ α΄„Κœα΄€Ι΄Ι΄α΄‡ΚŸ ᴋᴀᴍΙͺ​!**",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"JᴏΙͺΙ΄ CΚœα΄€Ι΄Ι΄α΄‡ΚŸ Dᴜʟᴜ",
url=f"https://t.me/{update_channel}",
)
]
]
),
)
except ChatAdminRequired:
return await message.reply_text("Chat admins Required: before /addjoin username without @ and add bot to your channel as admin")
return
query_url = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
if not query_url:
return await message.reply_text("?")
if not is_tiktok_url(query_url):
return await message.reply_text("Invalid link")
callback_data = generate_callback_data(message.from_user.id, query_url)
keyboard = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="Audio Download",
callback_data=callback_data
)
]
]
)
try:
dll = await message.reply_text("Processing....")
response = await Tiktok.download(TIKTOK_WEB, query_url)
await message.reply_video(
response[0],
reply_markup=keyboard,
disable_notification=True
)
await dll.delete()
except Exception as e:
LOGS.info(str(e))
await dll.delete()
await message.reply_text(f"Error: {str(e)}")
async def TeraboxDL(url):
try:
headers = {"x-api-key": os.environ.get("AKENOX_KEY")}
async with httpx.AsyncClient() as clientv:
response = await clientv.get(
f"https://randydev-ryu-js.hf.space/api/v1/dl/terabox-v4?url={url}",
headers=headers
)
response_json = response.json()
data = response_json.get("message", {}).get("resuls", "")
pattern = r"#EXTINF:\d+,\s*(https[^\s]+)"
matches = re.findall(pattern, data)
return {
"video_url": matches[0].split("?ulink=")[1] if matches else None,
"video_url_2": matches[1].split("?ulink=")[1] if len(matches) > 1 else None
}
except Exception as e:
return {"error": str(e)}
async def download_m3u8(url, save_path="terabox.mp4"):
api_url = f"https://teraboxdownloaderonline.com/api/download-m3u8?terabox_link={url}"
async with httpx.AsyncClient() as clientv:
response = await clientv.get(api_url)
if response.status_code != 200:
return None
with open(save_path, "wb") as file:
file.write(response.content)
return save_path
@Client.on_message(
~filters.scheduled
& filters.command(["terabox2dl"])
& ~filters.forwarded
)
async def terabox2_cmd(client: Client, message: Message):
user_id = message.from_user.id
user_name = message.from_user.first_name
nn = f"[{user_name}](tg://user?id={user_id})"
update_channel = await db.get_forcesub_only_bot(client.me.id)
if update_channel:
try:
user = await client.get_chat_member(update_channel, user_id)
if user.status == ChatMemberStatus.BANNED:
return await message.reply_text(f"❌ {nn} Anda telah diblokir dari grup dukungan.")
except UserNotParticipant:
return await message.reply_text(
f"πŸ‘‹πŸ» Halo {nn}, Anda perlu join channel kami untuk menggunakan bot ini.",
reply_markup=InlineKeyboardMarkup([
[InlineKeyboardButton("Join Channel", url=f"https://t.me/{update_channel}")]
])
)
link = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
if not link:
return await message.reply_text("Silakan masukkan link Terabox v2.")
pro = await message.reply_text("πŸš€ **Processing...**")
mp4_file = await download_m3u8(link)
if not mp4_file:
return await pro.edit_text("❌ Gagal mendapatkan file mp4.")
upload_text = "**⬆️ Uploading video...**"
thumb_path = "terabox.jpg"
async with httpx.AsyncClient() as clientv:
async with clientv.stream("GET", "https://images3.memedroid.com/images/UPLOADED822/63c5a9ca185df.jpeg") as thumb_response:
async with aiofiles.open(thumb_path, "wb") as file:
await file.write(await thumb_response.aread())
await pro.edit_text(upload_text)
await message.reply_video(
mp4_file,
caption=f"β€’ Powered by {client.me.mention}",
thumb=thumb_path,
progress=progress,
progress_args=(
pro,
time.time(),
"⬆️ Uploading video...."
)
)
os.remove(thumb_path)
os.remove(mp4_file)
await pro.delete()
@Client.on_message(
~filters.scheduled & filters.command(["teraboxdl"]) & ~filters.forwarded
)
async def terabox_cmd(client: Client, message):
user_id = message.from_user.id
if await db.get_alldlbot_is_blacklist_user(client.me.id, user_id):
return
user_name = message.from_user.first_name
nn = f"[{user_name}](tg://user?id={user_id})"
update_channel = await db.get_forcesub_only_bot(client.me.id)
if update_channel:
try:
user = await client.get_chat_member(update_channel, user_id)
if user.status == ChatMemberStatus.BANNED:
return await message.reply_text(f"❌ {nn}, Anda telah diblokir dari grup dukungan.")
except UserNotParticipant:
return await message.reply_text(
f"πŸ‘‹πŸ» Halo {nn}, untuk menggunakan bot ini, silakan join channel kami!",
reply_markup=InlineKeyboardMarkup(
[[InlineKeyboardButton("Join Channel", url=f"https://t.me/{update_channel}")]]
),
)
except ChatAdminRequired:
return await message.reply_text("Chat admin diperlukan: /addjoin username tanpa @ dan tambahkan bot ke channel sebagai admin.")
if len(message.command) < 2:
return await message.reply_text("❌ Harap masukkan link untuk Terabox Downloader.")
link = message.text.split(" ", 1)[1]
pro = await message.reply_text("⏳ Processing...")
try:
response = await TeraboxDL(link)
if "error" in response or not response["video_url_2"]:
return await pro.edit_text("❌ Error: Gagal mendapatkan URL video.")
video_url = urllib.parse.unquote(response["video_url_2"])
video_path = "terabox.mp4"
thumb_path = "terabox.jpg"
async with httpx.AsyncClient() as clientv:
async with clientv.stream("GET", video_url) as vid_response:
if vid_response.status_code != 200:
return await pro.edit_text("❌ Error saat mengunduh video.")
async with aiofiles.open(video_path, "wb") as file:
async for chunk in vid_response.aiter_bytes():
await file.write(chunk)
async with clientv.stream("GET", "https://images3.memedroid.com/images/UPLOADED822/63c5a9ca185df.jpeg") as thumb_response:
async with aiofiles.open(thumb_path, "wb") as file:
await file.write(await thumb_response.aread())
await pro.edit_text("⬆️ Uploading video...")
await message.reply_video(
video_path,
caption=f"β€’ Powered by {client.me.mention}",
thumb=thumb_path,
progress=progress,
progress_args=(
pro,
time.time(),
"⬆️ Uploading video...."
)
)
await pro.delete()
os.remove(video_path)
os.remove(thumb_path)
except Exception as e:
await pro.edit_text(f"❌ Error: {str(e)}")
@Client.on_message(
~filters.scheduled
& filters.command(["twdl"])
& ~filters.forwarded
)
async def twdl_cmd(client: Client, message: Message):
user_id = message.from_user.id
if await db.get_alldlbot_is_blacklist_user(client.me.id, user_id):
return
if message.chat.type.value != "supergroup":
return await message.reply_text("You can only group public not private")
await db.update_alldlbot_broadcast_in_group(client.me.id, message.chat.id, "add")
user_name = message.from_user.first_name
nn = "[" + user_name + "](tg://user?id=" + str(user_id) + ")"
if not await db.get_forcesub_only_bot(client.me.id):
return await message.reply_text("This is the command /addjoin username channel and becomes admin on the channel")
update_channel = await db.get_forcesub_only_bot(client.me.id)
if update_channel:
try:
user = await client.get_chat_member(update_channel, user_id)
if user.status == ChatMemberStatus.BANNED:
await client.send_message(
message.chat.id,
text=f"**❌ {nn} anda telah di blokir dari grup dukungan**",
disable_web_page_preview=True,
)
return
except UserNotParticipant:
await client.send_message(
message.chat.id,
text=f"**πŸ‘‹πŸ» Halo {nn}\nα΄œΙ΄α΄›α΄œα΄‹ α΄α΄‡Ι΄Ι’ΚœΙͺΙ΄α΄…α΄€Κ€Ιͺ α΄˜α΄‡Ι΄Ι’Ι’α΄œΙ΄α΄€α΄€Ι΄ ʏᴀɴɒ Κ™α΄‡Κ€ΚŸα΄‡Κ™ΙͺΚœα΄€Ι΄ ʙᴏᴛ ΙͺΙ΄Ιͺ α΄…Ιͺ α΄‹Κœα΄œsᴜsα΄‹α΄€Ι΄ α΄œΙ΄α΄›α΄œα΄‹ ʏᴀɴɒ sα΄œα΄…α΄€Κœ ᴊᴏΙͺΙ΄ α΄…Ιͺ α΄„Κœα΄€Ι΄Ι΄α΄‡ΚŸ ᴋᴀᴍΙͺ​!**",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"JᴏΙͺΙ΄ CΚœα΄€Ι΄Ι΄α΄‡ΚŸ Dᴜʟᴜ",
url=f"https://t.me/{update_channel}",
)
]
]
),
)
return
except ChatAdminRequired:
return await message.reply_text("Chat admins Required: before /addjoin username without @ and add bot to your channel as admin")
link = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
pro = await message.reply_text("Processing.....")
if not link:
return await pro.edit_text("Please link for Twitter.")
urls = re.sub(r"(https?:\/\/)(?:www\.)?x\.com", r"\1twitter.com", link)
if not urls:
return await pro.edit_text("invalid link.")
try:
response = await js.fetch_and_extract_urls(
f"https://snapdownloader.com/tools/twitter-video-downloader/download?url={urls}",
href_url=r"https://video",
return_unsafe_href=True
)
upload_text = f"**⬆️ π–΄π—‰π—…π—ˆπ–Ίπ–½π—‚π—‡π—€ video ...**"
await pro.edit_text(upload_text)
await message.reply_video(
response[0],
caption=f"β€’ Powered by {client.me.mention}",
progress=progress,
progress_args=(
pro,
time.time(),
upload_text
)
)
await pro.delete()
except Exception as e:
LOGS.error(str(e))
await pro.edit_text("Error: Try invalid")
@Client.on_message(
~filters.scheduled
& filters.command(["fbdl"])
& ~filters.forwarded
)
async def fbdl_cmd(client: Client, message: Message):
user_id = message.from_user.id
if await db.get_maintance():
return await message.reply_text("Bot is in maintance mode. By @xpushz")
if await db.get_alldlbot_is_blacklist_user(client.me.id, user_id):
return
if message.chat.type.value != "supergroup":
return await message.reply_text("You can only group public not private")
await db.update_alldlbot_broadcast_in_group(client.me.id, message.chat.id, "add")
user_name = message.from_user.first_name
nn = "[" + user_name + "](tg://user?id=" + str(user_id) + ")"
if not await db.get_forcesub_only_bot(client.me.id):
return await message.reply_text("This is the command /addjoin username channel and becomes admin on the channel")
update_channel = await db.get_forcesub_only_bot(client.me.id)
if update_channel:
try:
user = await client.get_chat_member(update_channel, user_id)
if user.status == ChatMemberStatus.BANNED:
await client.send_message(
message.chat.id,
text=f"**❌ {nn} anda telah di blokir dari grup dukungan**",
disable_web_page_preview=True,
)
return
except UserNotParticipant:
await client.send_message(
message.chat.id,
text=f"**πŸ‘‹πŸ» Halo {nn}\nα΄œΙ΄α΄›α΄œα΄‹ α΄α΄‡Ι΄Ι’ΚœΙͺΙ΄α΄…α΄€Κ€Ιͺ α΄˜α΄‡Ι΄Ι’Ι’α΄œΙ΄α΄€α΄€Ι΄ ʏᴀɴɒ Κ™α΄‡Κ€ΚŸα΄‡Κ™ΙͺΚœα΄€Ι΄ ʙᴏᴛ ΙͺΙ΄Ιͺ α΄…Ιͺ α΄‹Κœα΄œsᴜsα΄‹α΄€Ι΄ α΄œΙ΄α΄›α΄œα΄‹ ʏᴀɴɒ sα΄œα΄…α΄€Κœ ᴊᴏΙͺΙ΄ α΄…Ιͺ α΄„Κœα΄€Ι΄Ι΄α΄‡ΚŸ ᴋᴀᴍΙͺ​!**",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"JᴏΙͺΙ΄ CΚœα΄€Ι΄Ι΄α΄‡ΚŸ Dᴜʟᴜ",
url=f"https://t.me/{update_channel}",
)
]
]
),
)
return
except ChatAdminRequired:
return await message.reply_text("Chat admins Required: before /addjoin username without @ and add bot to your channel as admin")
link = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
pro = await message.reply_text("Processing.....")
if not link:
return await pro.edit_text("Please link for facebook.")
if not link.startswith("https://www.facebook.com/"):
return await pro.edit_text("invalid link.")
try:
response = await js.AkenoXJs(
js.types.DifferentAPIDefault()
).connect().downloader.create(
"fb",
params_data={"url": link},
is_obj=True
)
upload_text = f"**⬆️ π–΄π—‰π—…π—ˆπ–Ίπ–½π—‚π—‡π—€ video ...**"
await pro.edit_text(upload_text)
await message.reply_video(
response.results.video[0].url,
caption=f"β€’ Powered by {client.me.mention}",
progress=progress,
progress_args=(
pro,
time.time(),
upload_text
)
)
await pro.delete()
except Exception as e:
LOGS.error(str(e))
await pro.edit_text("Error: Try invalid")
@Client.on_message(
~filters.scheduled
& filters.command(["igdl"])
& ~filters.forwarded
)
async def igdl_cmd(client: Client, message: Message):
user_id = message.from_user.id
if await db.get_maintance():
return await message.reply_text("Bot is in maintance mode. By @xpushz")
if await db.get_alldlbot_is_blacklist_user(client.me.id, user_id):
return
if message.chat.type.value != "supergroup":
return await message.reply_text("You can only group public not private")
await db.update_alldlbot_broadcast_in_group(client.me.id, message.chat.id, "add")
user_name = message.from_user.first_name
nn = "[" + user_name + "](tg://user?id=" + str(user_id) + ")"
if not await db.get_forcesub_only_bot(client.me.id):
return await message.reply_text("This is the command /addjoin username channel and becomes admin on the channel")
update_channel = await db.get_forcesub_only_bot(client.me.id)
if update_channel:
try:
user = await client.get_chat_member(update_channel, user_id)
if user.status == ChatMemberStatus.BANNED:
await client.send_message(
message.chat.id,
text=f"**❌ {nn} anda telah di blokir dari grup dukungan**",
disable_web_page_preview=True,
)
return
except UserNotParticipant:
await client.send_message(
message.chat.id,
text=f"**πŸ‘‹πŸ» Halo {nn}\nα΄œΙ΄α΄›α΄œα΄‹ α΄α΄‡Ι΄Ι’ΚœΙͺΙ΄α΄…α΄€Κ€Ιͺ α΄˜α΄‡Ι΄Ι’Ι’α΄œΙ΄α΄€α΄€Ι΄ ʏᴀɴɒ Κ™α΄‡Κ€ΚŸα΄‡Κ™ΙͺΚœα΄€Ι΄ ʙᴏᴛ ΙͺΙ΄Ιͺ α΄…Ιͺ α΄‹Κœα΄œsᴜsα΄‹α΄€Ι΄ α΄œΙ΄α΄›α΄œα΄‹ ʏᴀɴɒ sα΄œα΄…α΄€Κœ ᴊᴏΙͺΙ΄ α΄…Ιͺ α΄„Κœα΄€Ι΄Ι΄α΄‡ΚŸ ᴋᴀᴍΙͺ!**",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"JᴏΙͺΙ΄ CΚœα΄€Ι΄Ι΄α΄‡ΚŸ Dᴜʟᴜ",
url=f"https://t.me/{update_channel}",
)
]
]
),
)
return
except ChatAdminRequired:
return await message.reply_text("Chat admins Required: before /addjoin username without @ and add bot to your channel as admin")
link = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
pro = await message.reply_text("Processing.....")
if not link:
return await pro.edit_text("Please link for Instagram.")
if not link.startswith("https://www.instagram.com/"):
return await pro.edit_text("invalid link.")
try:
params = {"link": link, "version": "v4"}
response = requests.get(f"https://learn.maiysacollection.com/api/v1/dl/ig/custom", params=params).json()
if response["response"]["results"] is None:
return await pro.edit_text("Not Found.")
upload_text = f"**⬆️ π–΄π—‰π—…π—ˆπ–Ίπ–½π—‚π—‡π—€ video ...**"
await pro.edit_text(upload_text)
await message.reply_video(
response["response"]["results"]["results"][0]["variants"][0]["url"],
caption=f"β€’ Powered by {client.me.mention}",
progress=progress,
progress_args=(
pro,
time.time(),
upload_text
)
)
await pro.delete()
except Exception as e:
LOGS.error(str(e))
await pro.edit_text("Error: Try invalid")
async def input_user(message: Message) -> str:
"""Get the input from the user"""
if len(message.command) < 2:
output = ""
else:
try:
output = message.text.split(" ", 1)[1].strip() or ""
except IndexError:
output = ""
return output
@Client.on_message(
~filters.scheduled
& filters.command(["ytsa"])
& ~filters.forwarded
)
async def youtube_search_audio(client: Client, message: Message):
user_id = message.from_user.id
if await db.get_alldlbot_is_blacklist_user(client.me.id, user_id):
return
user_name = message.from_user.first_name
nn = "[" + user_name + "](tg://user?id=" + str(user_id) + ")"
if not await db.get_forcesub_only_bot(client.me.id):
return await message.reply_text("This is the command /addjoin username channel and becomes admin on the channel")
update_channel = await db.get_forcesub_only_bot(client.me.id)
if update_channel:
try:
user = await client.get_chat_member(update_channel, user_id)
if user.status == ChatMemberStatus.BANNED:
await client.send_message(
message.chat.id,
text=f"**❌ {nn} anda telah di blokir dari grup dukungan**",
disable_web_page_preview=True,
)
return
except UserNotParticipant:
await client.send_message(
message.chat.id,
text=f"**πŸ‘‹πŸ» Halo {nn}\nα΄œΙ΄α΄›α΄œα΄‹ α΄α΄‡Ι΄Ι’ΚœΙͺΙ΄α΄…α΄€Κ€Ιͺ α΄˜α΄‡Ι΄Ι’Ι’α΄œΙ΄α΄€α΄€Ι΄ ʏᴀɴɒ Κ™α΄‡Κ€ΚŸα΄‡Κ™ΙͺΚœα΄€Ι΄ ʙᴏᴛ ΙͺΙ΄Ιͺ α΄…Ιͺ α΄‹Κœα΄œsᴜsα΄‹α΄€Ι΄ α΄œΙ΄α΄›α΄œα΄‹ ʏᴀɴɒ sα΄œα΄…α΄€Κœ ᴊᴏΙͺΙ΄ α΄…Ιͺ α΄„Κœα΄€Ι΄Ι΄α΄‡ΚŸ ᴋᴀᴍΙͺ​!**",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"JᴏΙͺΙ΄ CΚœα΄€Ι΄Ι΄α΄‡ΚŸ Dᴜʟᴜ",
url=f"https://t.me/{update_channel}",
)
]
]
),
)
return
except ChatAdminRequired:
return await message.reply_text(f"Chat admins Required: before /addjoin username without @ and add bot to your channel as admin")
if len(message.command) < 2:
return await message.reply_text(
"Give a valid youtube search to download audio."
)
query = await input_user(message)
results = YoutubeSearch(query, max_results=5).to_dict()
watch = results[0]["url_suffix"]
url_suffix = watch.split("/")[1]
okk = f"https://youtube.com/{url_suffix}"
pro = await message.reply_text("Checking ...")
status, url = YoutubeDriver.check_url(okk)
if not status:
return await pro.edit_text(url)
if client.me.is_premium:
await pro.edit_text(f"{custom_loading}__Downloading audio ...__")
else:
await pro.edit_text(f"__Downloading audio ...__")
try:
with YoutubeDL(YoutubeDriver.song_options()) as ytdl:
yt_data = ytdl.extract_info(url, False)
yt_file = ytdl.prepare_filename(yt_data)
ytdl.process_info(yt_data)
if client.me.is_premium:
upload_text = f"**{custom_loading}π–΄π—‰π—…π—ˆπ–Ίπ–½π—‚π—‡π—€ π–²π—ˆπ—‡π—€ ...** \n\n**𝖳𝗂𝗍𝗅𝖾:** `{yt_data['title'][:50]}`\n**𝖒𝗁𝖺𝗇𝗇𝖾𝗅:** `{yt_data['channel']}`"
else:
upload_text = f"**π–΄π—‰π—…π—ˆπ–Ίπ–½π—‚π—‡π—€ π–²π—ˆπ—‡π—€ ...** \n\n**𝖳𝗂𝗍𝗅𝖾:** `{yt_data['title'][:50]}`\n**𝖒𝗁𝖺𝗇𝗇𝖾𝗅:** `{yt_data['channel']}`"
await pro.edit_text(upload_text)
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
with open(f"{yt_file}.jpg", "wb") as f:
f.write(response.content)
await message.reply_audio(
f"{yt_file}.mp3",
caption=f"**🎧 𝖳𝗂𝗍𝗅𝖾:** {yt_data['title']} \n\n**πŸ‘€ π–΅π—‚π–Ύπ—π—Œ:** `{yt_data['view_count']}` \n**βŒ› π–£π—Žπ—‹π–Ίπ—π—‚π—ˆπ—‡:** `{secs_to_mins(int(yt_data['duration']))}`",
duration=int(yt_data["duration"]),
performer="[Akeno UB]",
title=yt_data["title"],
thumb=f"{yt_file}.jpg",
progress=progress,
progress_args=(
pro,
time.time(),
upload_text,
),
)
await pro.delete()
except Exception as e:
return await pro.edit_text(f"**πŸ€ Audio not Downloaded:** `{e}`")
try:
os.remove(f"{yt_file}.jpg")
os.remove(f"{yt_file}.mp3")
except:
pass
@Client.on_message(
~filters.scheduled
& filters.command(["yta"])
& ~filters.forwarded
)
async def youtube_audio(client: Client, message: Message):
user_id = message.from_user.id
if await db.get_alldlbot_is_blacklist_user(client.me.id, user_id):
return
user_name = message.from_user.first_name
nn = "[" + user_name + "](tg://user?id=" + str(user_id) + ")"
if not await db.get_forcesub_only_bot(client.me.id):
return await message.reply_text("This is the command /addjoin username channel and becomes admin on the channel")
update_channel = await db.get_forcesub_only_bot(client.me.id)
if update_channel:
try:
user = await client.get_chat_member(update_channel, user_id)
if user.status == ChatMemberStatus.BANNED:
await client.send_message(
message.chat.id,
text=f"**❌ {nn} anda telah di blokir dari grup dukungan**",
disable_web_page_preview=True,
)
return
except UserNotParticipant:
await client.send_message(
message.chat.id,
text=f"**πŸ‘‹πŸ» Halo {nn}\nα΄œΙ΄α΄›α΄œα΄‹ α΄α΄‡Ι΄Ι’ΚœΙͺΙ΄α΄…α΄€Κ€Ιͺ α΄˜α΄‡Ι΄Ι’Ι’α΄œΙ΄α΄€α΄€Ι΄ ʏᴀɴɒ Κ™α΄‡Κ€ΚŸα΄‡Κ™ΙͺΚœα΄€Ι΄ ʙᴏᴛ ΙͺΙ΄Ιͺ α΄…Ιͺ α΄‹Κœα΄œsᴜsα΄‹α΄€Ι΄ α΄œΙ΄α΄›α΄œα΄‹ ʏᴀɴɒ sα΄œα΄…α΄€Κœ ᴊᴏΙͺΙ΄ α΄…Ιͺ α΄„Κœα΄€Ι΄Ι΄α΄‡ΚŸ ᴋᴀᴍΙͺ​!**",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"JᴏΙͺΙ΄ CΚœα΄€Ι΄Ι΄α΄‡ΚŸ Dᴜʟᴜ",
url=f"https://t.me/{update_channel}",
)
]
]
),
)
return
except ChatAdminRequired:
return await message.reply_text("Chat admins Required: before /addjoin username without @ and add bot to your channel as admin")
if len(message.command) < 2:
return await message.reply_text(
"Give a valid youtube link to download audio."
)
query = await input_user(message)
pro = await message.reply_text("Checking ...")
status, url = YoutubeDriver.check_url(query)
if not status:
return await pro.edit_text(url)
if client.me.is_premium:
await pro.edit_text(f"{custom_loading}__Downloading audio ...__")
else:
await pro.edit_text(f"__Downloading audio ...__")
try:
with YoutubeDL(YoutubeDriver.song_options()) as ytdl:
yt_data = ytdl.extract_info(url, False)
yt_file = ytdl.prepare_filename(yt_data)
ytdl.process_info(yt_data)
if client.me.is_premium:
upload_text = f"**{custom_loading}π–΄π—‰π—…π—ˆπ–Ίπ–½π—‚π—‡π—€ π–²π—ˆπ—‡π—€ ...** \n\n**𝖳𝗂𝗍𝗅𝖾:** `{yt_data['title'][:50]}`\n**𝖒𝗁𝖺𝗇𝗇𝖾𝗅:** `{yt_data['channel']}`"
else:
upload_text = f"**π–΄π—‰π—…π—ˆπ–Ίπ–½π—‚π—‡π—€ π–²π—ˆπ—‡π—€ ...** \n\n**𝖳𝗂𝗍𝗅𝖾:** `{yt_data['title'][:50]}`\n**𝖒𝗁𝖺𝗇𝗇𝖾𝗅:** `{yt_data['channel']}`"
await pro.edit_text(upload_text)
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
with open(f"{yt_file}.jpg", "wb") as f:
f.write(response.content)
await message.reply_audio(
f"{yt_file}.mp3",
caption=f"**🎧 𝖳𝗂𝗍𝗅𝖾:** {yt_data['title']} \n\n**πŸ‘€ π–΅π—‚π–Ύπ—π—Œ:** `{yt_data['view_count']}` \n**βŒ› π–£π—Žπ—‹π–Ίπ—π—‚π—ˆπ—‡:** `{secs_to_mins(int(yt_data['duration']))}`",
duration=int(yt_data["duration"]),
performer="[Akeno UB]",
title=yt_data["title"],
thumb=f"{yt_file}.jpg",
progress=progress,
progress_args=(
pro,
time.time(),
upload_text,
),
)
await pro.delete()
except Exception as e:
return await pro.edit_text(f"**πŸ€ Audio not Downloaded:** `{e}`")
try:
os.remove(f"{yt_file}.jpg")
os.remove(f"{yt_file}.mp3")
except:
pass
@Client.on_message(
~filters.scheduled
& filters.command(["ytva"])
& ~filters.forwarded
)
async def ytvideo_search(client: Client, message: Message):
user_id = message.from_user.id
if await db.get_alldlbot_is_blacklist_user(client.me.id, user_id):
return
user_name = message.from_user.first_name
nn = "[" + user_name + "](tg://user?id=" + str(user_id) + ")"
if not await db.get_forcesub_only_bot(client.me.id):
return await message.reply_text("This is the command /addjoin username channel and becomes admin on the channel")
update_channel = await db.get_forcesub_only_bot(client.me.id)
if update_channel:
try:
user = await client.get_chat_member(update_channel, user_id)
if user.status == ChatMemberStatus.BANNED:
await client.send_message(
message.chat.id,
text=f"**❌ {nn} anda telah di blokir dari grup dukungan**",
disable_web_page_preview=True,
)
return
except UserNotParticipant:
await client.send_message(
message.chat.id,
text=f"**πŸ‘‹πŸ» Halo {nn}\nα΄œΙ΄α΄›α΄œα΄‹ α΄α΄‡Ι΄Ι’ΚœΙͺΙ΄α΄…α΄€Κ€Ιͺ α΄˜α΄‡Ι΄Ι’Ι’α΄œΙ΄α΄€α΄€Ι΄ ʏᴀɴɒ Κ™α΄‡Κ€ΚŸα΄‡Κ™ΙͺΚœα΄€Ι΄ ʙᴏᴛ ΙͺΙ΄Ιͺ α΄…Ιͺ α΄‹Κœα΄œsᴜsα΄‹α΄€Ι΄ α΄œΙ΄α΄›α΄œα΄‹ ʏᴀɴɒ sα΄œα΄…α΄€Κœ ᴊᴏΙͺΙ΄ α΄…Ιͺ α΄„Κœα΄€Ι΄Ι΄α΄‡ΚŸ ᴋᴀᴍΙͺ​!**",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"JᴏΙͺΙ΄ CΚœα΄€Ι΄Ι΄α΄‡ΚŸ Dᴜʟᴜ",
url=f"https://t.me/{update_channel}",
)
]
]
),
)
return
except ChatAdminRequired:
return await message.reply_text(f"Chat admins Required: before /addjoin username without @ and add bot to your channel as admin")
if len(message.command) < 2:
return await message.reply_text(
"Give a valid youtube search to download video."
)
query = await input_user(message)
results = YoutubeSearch(query, max_results=5).to_dict()
watch = results[0]["url_suffix"]
url_suffix = watch.split("/")[1]
okk = f"https://youtube.com/{url_suffix}"
pro = await message.reply_text("Checking ...")
status, url = YoutubeDriver.check_url(okk)
if not status:
return await pro.edit_text(url)
if client.me.is_premium:
await pro.edit_text(f"{custom_loading}__Downloading audio ...__")
else:
await pro.edit_text(f"__Downloading audio ...__")
try:
with YoutubeDL(YoutubeDriver.video_options()) as ytdl:
yt_data = ytdl.extract_info(url, True)
yt_file = yt_data["id"]
if client.me.is_premium:
upload_text = f"**{custom_loading}π–΄π—‰π—…π—ˆπ–Ίπ–½π—‚π—‡π—€ π–²π—ˆπ—‡π—€ ...** \n\n**𝖳𝗂𝗍𝗅𝖾:** `{yt_data['title'][:50]}`\n**𝖒𝗁𝖺𝗇𝗇𝖾𝗅:** `{yt_data['channel']}`"
else:
upload_text = f"**π–΄π—‰π—…π—ˆπ–Ίπ–½π—‚π—‡π—€ π–²π—ˆπ—‡π—€ ...** \n\n**𝖳𝗂𝗍𝗅𝖾:** `{yt_data['title'][:50]}`\n**𝖒𝗁𝖺𝗇𝗇𝖾𝗅:** `{yt_data['channel']}`"
await pro.edit_text(upload_text)
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
with open(f"{yt_file}.jpg", "wb") as f:
f.write(response.content)
await message.reply_video(
f"{yt_file}.mp4",
caption=f"**🎧 𝖳𝗂𝗍𝗅𝖾:** {yt_data['title']} \n\n**πŸ‘€ π–΅π—‚π–Ύπ—π—Œ:** `{yt_data['view_count']}` \n**βŒ› π–£π—Žπ—‹π–Ίπ—π—‚π—ˆπ—‡:** `{secs_to_mins(int(yt_data['duration']))}`",
duration=int(yt_data["duration"]),
thumb=f"{yt_file}.jpg",
progress=progress,
progress_args=(
pro,
time.time(),
upload_text,
),
)
await pro.delete()
except Exception as e:
return await pro.edit_text(f"**πŸ€ Video not Downloaded:** `{e}`")
try:
os.remove(f"{yt_file}.jpg")
os.remove(f"{yt_file}.mp4")
except:
pass
@Client.on_message(
~filters.scheduled
& filters.command(["ytv"])
& ~filters.forwarded
)
async def ytvideo(client: Client, message: Message):
user_id = message.from_user.id
if await db.get_alldlbot_is_blacklist_user(client.me.id, user_id):
return
user_name = message.from_user.first_name
nn = "[" + user_name + "](tg://user?id=" + str(user_id) + ")"
if not await db.get_forcesub_only_bot(client.me.id):
return await message.reply_text("This is the command /addjoin username channel and becomes admin on the channel")
update_channel = await db.get_forcesub_only_bot(client.me.id)
if update_channel:
try:
user = await client.get_chat_member(update_channel, user_id)
if user.status == ChatMemberStatus.BANNED:
await client.send_message(
message.chat.id,
text=f"**❌ {nn} anda telah di blokir dari grup dukungan**",
disable_web_page_preview=True,
)
return
except UserNotParticipant:
await client.send_message(
message.chat.id,
text=f"**πŸ‘‹πŸ» Halo {nn}\nα΄œΙ΄α΄›α΄œα΄‹ α΄α΄‡Ι΄Ι’ΚœΙͺΙ΄α΄…α΄€Κ€Ιͺ α΄˜α΄‡Ι΄Ι’Ι’α΄œΙ΄α΄€α΄€Ι΄ ʏᴀɴɒ Κ™α΄‡Κ€ΚŸα΄‡Κ™ΙͺΚœα΄€Ι΄ ʙᴏᴛ ΙͺΙ΄Ιͺ α΄…Ιͺ α΄‹Κœα΄œsᴜsα΄‹α΄€Ι΄ α΄œΙ΄α΄›α΄œα΄‹ ʏᴀɴɒ sα΄œα΄…α΄€Κœ ᴊᴏΙͺΙ΄ α΄…Ιͺ α΄„Κœα΄€Ι΄Ι΄α΄‡ΚŸ ᴋᴀᴍΙͺ​!**",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"JᴏΙͺΙ΄ CΚœα΄€Ι΄Ι΄α΄‡ΚŸ Dᴜʟᴜ",
url=f"https://t.me/{update_channel}",
)
]
]
),
)
return
except ChatAdminRequired:
return await message.reply_text("Chat admins Required: before /addjoin username without @ and add bot to your channel as admin")
if len(message.command) < 2:
return await message.reply_text(
"Give a valid youtube link to download video."
)
query = await input_user(message)
pro = await message.reply_text("Checking ...")
status, url = YoutubeDriver.check_url(query)
if not status:
return await pro.edit_text(url)
if client.me.is_premium:
await pro.edit_text(f"{custom_loading}__Downloading audio ...__")
else:
await pro.edit_text(f"__Downloading audio ...__")
try:
with YoutubeDL(YoutubeDriver.video_options()) as ytdl:
yt_data = ytdl.extract_info(url, True)
yt_file = yt_data["id"]
if client.me.is_premium:
upload_text = f"**{custom_loading}π–΄π—‰π—…π—ˆπ–Ίπ–½π—‚π—‡π—€ π–²π—ˆπ—‡π—€ ...** \n\n**𝖳𝗂𝗍𝗅𝖾:** `{yt_data['title'][:50]}`\n**𝖒𝗁𝖺𝗇𝗇𝖾𝗅:** `{yt_data['channel']}`"
else:
upload_text = f"**π–΄π—‰π—…π—ˆπ–Ίπ–½π—‚π—‡π—€ π–²π—ˆπ—‡π—€ ...** \n\n**𝖳𝗂𝗍𝗅𝖾:** `{yt_data['title'][:50]}`\n**𝖒𝗁𝖺𝗇𝗇𝖾𝗅:** `{yt_data['channel']}`"
await pro.edit_text(upload_text)
response = requests.get(f"https://i.ytimg.com/vi/{yt_data['id']}/hqdefault.jpg")
with open(f"{yt_file}.jpg", "wb") as f:
f.write(response.content)
await message.reply_video(
f"{yt_file}.mp4",
caption=f"**🎧 𝖳𝗂𝗍𝗅𝖾:** {yt_data['title']} \n\n**πŸ‘€ π–΅π—‚π–Ύπ—π—Œ:** `{yt_data['view_count']}` \n**βŒ› π–£π—Žπ—‹π–Ίπ—π—‚π—ˆπ—‡:** `{secs_to_mins(int(yt_data['duration']))}`",
duration=int(yt_data["duration"]),
thumb=f"{yt_file}.jpg",
progress=progress,
progress_args=(
pro,
time.time(),
upload_text,
),
)
await pro.delete()
except Exception as e:
return await pro.edit_text(f"**πŸ€ Video not Downloaded:** `{e}`")
try:
os.remove(f"{yt_file}.jpg")
os.remove(f"{yt_file}.mp4")
except:
pass
@Client.on_message(
~filters.scheduled
& filters.command(["ytlink"])
& ~filters.forwarded
)
async def ytlink(client: Client, message: Message):
user_id = message.from_user.id
if await db.get_alldlbot_is_blacklist_user(client.me.id, user_id):
return
user_name = message.from_user.first_name
nn = "[" + user_name + "](tg://user?id=" + str(user_id) + ")"
if not await db.get_forcesub_only_bot(client.me.id):
return await message.reply_text("This is the command /addjoin username channel and becomes admin on the channel")
update_channel = await db.get_forcesub_only_bot(client.me.id)
if update_channel:
try:
user = await client.get_chat_member(update_channel, user_id)
if user.status == ChatMemberStatus.BANNED:
await client.send_message(
message.chat.id,
text=f"**❌ {nn} anda telah di blokir dari grup dukungan**",
disable_web_page_preview=True,
)
return
except UserNotParticipant:
await client.send_message(
message.chat.id,
text=f"**πŸ‘‹πŸ» Halo {nn}\nα΄œΙ΄α΄›α΄œα΄‹ α΄α΄‡Ι΄Ι’ΚœΙͺΙ΄α΄…α΄€Κ€Ιͺ α΄˜α΄‡Ι΄Ι’Ι’α΄œΙ΄α΄€α΄€Ι΄ ʏᴀɴɒ Κ™α΄‡Κ€ΚŸα΄‡Κ™ΙͺΚœα΄€Ι΄ ʙᴏᴛ ΙͺΙ΄Ιͺ α΄…Ιͺ α΄‹Κœα΄œsᴜsα΄‹α΄€Ι΄ α΄œΙ΄α΄›α΄œα΄‹ ʏᴀɴɒ sα΄œα΄…α΄€Κœ ᴊᴏΙͺΙ΄ α΄…Ιͺ α΄„Κœα΄€Ι΄Ι΄α΄‡ΚŸ ᴋᴀᴍΙͺ​!**",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"JᴏΙͺΙ΄ CΚœα΄€Ι΄Ι΄α΄‡ΚŸ Dᴜʟᴜ",
url=f"https://t.me/{update_channel}",
)
]
]
),
)
return
except ChatAdminRequired:
return await message.reply_text("Chat admins Required: before /addjoin username without @ and add bot to your channel as admin")
if len(message.command) < 2:
return await message.reply_text("Give something to search on youtube.")
query = await input_user(message)
pro = await message.reply_text("Searching ...")
try:
results = YoutubeDriver(query, 7).to_dict()
except Exception as e:
return await pro.edit_text(f"**πŸ€ Error:** `{e}`")
if not results:
return await pro.edit_text("No results found.")
text = f"**πŸ”Ž π–³π—ˆπ—π–Ίπ—… π–±π–Ύπ—Œπ—Žπ—…π—π—Œ π–₯π—ˆπ—Žπ—‡π–½:** `{len(results)}`\n\n"
for result in results:
text += f"**𝖳𝗂𝗍𝗅𝖾:** `{result['title'][:50]}`\n**𝖒𝗁𝖺𝗇𝗇𝖾𝗅:** `{result['channel']}`\n**π–΅π—‚π–Ύπ—π—Œ:** `{result['views']}`\n**π–£π—Žπ—‹π–Ίπ—π—‚π—ˆπ—‡:** `{result['duration']}`\n**𝖫𝗂𝗇𝗄:** `https://youtube.com{result['url_suffix']}`\n\n"
await pro.edit_text(text, disable_web_page_preview=True)