|
|
|
|
|
|
|
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.") |
|
|
|
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) |