#commands.py
from datetime import datetime
import time
import os
import string
import pytz
import logging
import random
import asyncio
from Script import script
from pyrogram import Client, filters, enums
from pyrogram.errors import ChatAdminRequired, FloodWait
from pyrogram.types import *
from database.ia_filterdb import *
from database.users_chats_db import db
from info import *
from utils import get_settings, get_size, is_subscribed, save_group_settings, temp, verify_user, check_token, check_verification, get_token, get_shortlink, get_tutorial, second_shortlink
from database.connections_mdb import active_connection
# from plugins.pm_filter import ENABLE_SHORTLINK
from plugins.fsub import ForceSub
import re, asyncio, os, sys
import json
import base64
import requests
from bs4 import BeautifulSoup
logger = logging.getLogger(__name__)
BATCH_FILES = {}
@Client.on_message(filters.command("start") & filters.incoming)
async def start(client, message):
if message.chat.type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
buttons = [[
InlineKeyboardButton('⤬ Aᴅᴅ Mᴇ Tᴏ Yᴏᴜʀ Gʀᴏᴜᴘ ⤬', url=f'http://t.me/{temp.U_NAME}?startgroup=true')
],[
InlineKeyboardButton('✪ Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url="https://t.me/+r9ArDaaCETE0OGU9"),
InlineKeyboardButton('⌬ Mᴏᴠɪᴇ Gʀᴏᴜᴘ', url=GRP_LNK)
],[
InlineKeyboardButton('✇ Jᴏɪɴ Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ ✇', url=CHNL_LNK)
]]
reply_markup = InlineKeyboardMarkup(buttons)
await message.reply(script.START_TXT.format(message.from_user.mention if message.from_user else message.chat.title, temp.U_NAME, temp.B_NAME), reply_markup=reply_markup, disable_web_page_preview=True)
await asyncio.sleep(2) # 😢 https://github.com/EvamariaTG/EvaMaria/blob/master/plugins/p_ttishow.py#L17 😬 wait a bit, before checking.
if not await db.get_chat(message.chat.id):
total=await client.get_chat_members_count(message.chat.id)
await client.send_message(LOG_CHANNEL, script.LOG_TEXT_G.format(message.chat.title, message.chat.id, total, "Unknown"))
await db.add_chat(message.chat.id, message.chat.title)
return
if not await db.is_user_exist(message.from_user.id):
await db.add_user(message.from_user.id, message.from_user.first_name)
await client.send_message(LOG_CHANNEL, script.LOG_TEXT_P.format(message.from_user.id, message.from_user.mention))
if len(message.command) != 2:
buttons = [[
InlineKeyboardButton('⤬ Aᴅᴅ Mᴇ Tᴏ Yᴏᴜʀ Gʀᴏᴜᴘ ⤬', url=f'http://t.me/{temp.U_NAME}?startgroup=true')
],[
InlineKeyboardButton('Eᴀʀɴ Mᴏɴᴇʏ 💸', callback_data="shortlink_info"),
InlineKeyboardButton('⌬ Mᴏᴠɪᴇ Gʀᴏᴜᴘ', url=GRP_LNK)
],[
InlineKeyboardButton('〄 Hᴇʟᴘ', callback_data='help'),
InlineKeyboardButton('⍟ Aʙᴏᴜᴛ', callback_data='about')
],[
InlineKeyboardButton('✇ Jᴏɪɴ Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ ✇', url=CHNL_LNK)
]]
reply_markup = InlineKeyboardMarkup(buttons)
m=await message.reply_sticker("CAACAgUAAxkBAAFFRb1kyf8cQI9ZIgIc36p3uBzmVG8zUwACbwoAAspbUVYbd56jBKfgAAEeBA")
await asyncio.sleep(1)
await m.delete()
await message.reply_photo(
photo=random.choice(PICS),
caption=script.START_TXT.format(message.from_user.mention, temp.U_NAME, temp.B_NAME),
reply_markup=reply_markup,
parse_mode=enums.ParseMode.HTML
)
return
if AUTH_CHANNEL and not await is_subscribed(client, message):
try:
invite_link = await client.create_chat_invite_link(int(AUTH_CHANNEL))
except ChatAdminRequired:
logger.error("Make sure Bot is admin in Forcesub channel")
return
btn = [
[
InlineKeyboardButton(
"❆ Jᴏɪɴ Oᴜʀ Cʜᴀɴɴᴇʟ ❆", url=invite_link.invite_link
)
]
]
if message.command[1] != "subscribe":
try:
kk, file_id = message.command[1].split("_", 1)
btn.append([InlineKeyboardButton("↻ Tʀʏ Aɢᴀɪɴ", callback_data=f"checkssub#{kk}#{file_id}")])
except (IndexError, ValueError):
btn.append([InlineKeyboardButton("↻ Tʀʏ Aɢᴀɪɴ", url=f"https://t.me/{temp.U_NAME}?start={message.command[1]}")])
await client.send_message(
chat_id=message.from_user.id,
text="**You are not in our channel given below so you don't get the movie file...\n\nIf you want the movie file, click on the '🍿ᴊᴏɪɴ ᴏᴜʀ ʙᴀᴄᴋ-ᴜᴘ ᴄʜᴀɴɴᴇʟ🍿' button below and join our back-up channel, then click on the '🔄 Try Again' button below...\n\nThen you will get the movie files...**",
reply_markup=InlineKeyboardMarkup(btn),
parse_mode=enums.ParseMode.MARKDOWN
)
return
if len(message.command) == 2 and message.command[1] in ["subscribe", "error", "okay", "help"]:
buttons = [[
InlineKeyboardButton('⤬ Aᴅᴅ Mᴇ Tᴏ Yᴏᴜʀ Gʀᴏᴜᴘ ⤬', url=f'http://t.me/{temp.U_NAME}?startgroup=true')
],[
InlineKeyboardButton('Eᴀʀɴ Mᴏɴᴇʏ 💸', callback_data="shortlink_info"),
InlineKeyboardButton('⌬ Mᴏᴠɪᴇ Gʀᴏᴜᴘ', url=GRP_LNK)
],[
InlineKeyboardButton('〄 Hᴇʟᴘ', callback_data='help'),
InlineKeyboardButton('⍟ Aʙᴏᴜᴛ', callback_data='about')
],[
InlineKeyboardButton('✇ Jᴏɪɴ Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ ✇', url=CHNL_LNK)
]]
reply_markup = InlineKeyboardMarkup(buttons)
await message.reply_photo(
photo=random.choice(PICS),
caption=script.START_TXT.format(message.from_user.mention, temp.U_NAME, temp.B_NAME),
reply_markup=reply_markup,
parse_mode=enums.ParseMode.HTML
)
return
kk, file_id = message.command[1].split("_", 1) if "_" in message.command[1] else (False, False)
pre = kk if kk else False
if REQ_CHANNEL:
status = await ForceSub(client, message, file_id=file_id, pre=pre)
if not status:
return
data = message.command[1]
if not file_id:
file_id = data
if data.split("-", 1)[0] == "BATCH":
sts = await message.reply("Please wait...")
file_id = data.split("-", 1)[1]
msgs = BATCH_FILES.get(file_id)
if not msgs:
file = await client.download_media(file_id)
try:
with open(file) as file_data:
msgs=json.loads(file_data.read())
except:
await sts.edit("FAILED")
return await client.send_message(LOG_CHANNEL, "UNABLE TO OPEN FILE.")
os.remove(file)
BATCH_FILES[file_id] = msgs
for msg in msgs:
title = msg.get("title")
size=get_size(int(msg.get("size", 0)))
f_caption=msg.get("caption", "")
if BATCH_FILE_CAPTION:
try:
f_caption=BATCH_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
except Exception as e:
logger.exception(e)
f_caption=f_caption
if f_caption is None:
f_caption = f"{title}"
try:
await client.send_cached_media(
chat_id=message.from_user.id,
file_id=msg.get("file_id"),
caption=f_caption,
protect_content=msg.get('protect', False),
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
],[
InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movie")
]
]
)
)
except FloodWait as e:
await asyncio.sleep(e.x)
logger.warning(f"Floodwait of {e.x} sec.")
await client.send_cached_media(
chat_id=message.from_user.id,
file_id=msg.get("file_id"),
caption=f_caption,
protect_content=msg.get('protect', False),
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
],[
InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movie")
]
]
)
)
except Exception as e:
logger.warning(e, exc_info=True)
continue
await asyncio.sleep(1)
await sts.delete()
return
elif data.split("-", 1)[0] == "DSTORE":
sts = await message.reply("Please wait...")
b_string = data.split("-", 1)[1]
decoded = (base64.urlsafe_b64decode(b_string + "=" * (-len(b_string) % 4))).decode("ascii")
try:
f_msg_id, l_msg_id, f_chat_id, protect = decoded.split("_", 3)
except:
f_msg_id, l_msg_id, f_chat_id = decoded.split("_", 2)
protect = "/pbatch" if PROTECT_CONTENT else "batch"
diff = int(l_msg_id) - int(f_msg_id)
async for msg in client.iter_messages(int(f_chat_id), int(l_msg_id), int(f_msg_id)):
if msg.media:
media = getattr(msg, msg.media.value)
if BATCH_FILE_CAPTION:
try:
f_caption=BATCH_FILE_CAPTION.format(file_name=getattr(media, 'file_name', ''), file_size=getattr(media, 'file_size', ''), file_caption=getattr(msg, 'caption', ''))
except Exception as e:
logger.exception(e)
f_caption = getattr(msg, 'caption', '')
else:
media = getattr(msg, msg.media.value)
file_name = getattr(media, 'file_name', '')
f_caption = getattr(msg, 'caption', file_name)
try:
await msg.copy(message.chat.id, caption=f_caption, protect_content=True if protect == "/pbatch" else False)
except FloodWait as e:
await asyncio.sleep(e.x)
await msg.copy(message.chat.id, caption=f_caption, protect_content=True if protect == "/pbatch" else False)
except Exception as e:
logger.exception(e)
continue
elif msg.empty:
continue
else:
try:
await msg.copy(message.chat.id, protect_content=True if protect == "/pbatch" else False)
except FloodWait as e:
await asyncio.sleep(e.x)
await msg.copy(message.chat.id, protect_content=True if protect == "/pbatch" else False)
except Exception as e:
logger.exception(e)
continue
await asyncio.sleep(1)
return await sts.delete()
elif data.split("-", 1)[0] == "verify":
userid = data.split("-", 2)[1]
token = data.split("-", 3)[2]
if str(message.from_user.id) != str(userid):
return await message.reply_text(
text="Invalid link or Expired link !",
protect_content=True
)
is_valid = await check_token(client, userid, token)
if is_valid == True:
await message.reply_text(
text=f"Hey {message.from_user.mention}, You are successfully verified !\nNow you have unlimited access for all movies till today midnight.",
protect_content=True
)
await verify_user(client, userid, token)
else:
return await message.reply_text(
text="Invalid link or Expired link !",
protect_content=True
)
if data.startswith("download"):
file_message = await client.get_messages(int(STREAM_BIN), int(file_id))
return await file_message.copy(chat_id=message.from_user.id)
if data.startswith("sendfiles"):
chat_id = int("-" + file_id.split("-")[1])
user_id = message.from_user.id if message.from_user else None
if not await db.is_user_verified(user_id):
m=await message.reply_text(f" Link Generating...⏳")
verify_id = ''.join(random.choices(string.ascii_uppercase + string.digits, k=7))
await db.create_verify_id(user_id, verify_id)
st = await client.get_chat_member(chat_id, user_id)
if (
st.status != enums.ChatMemberStatus.ADMINISTRATOR
and st.status != enums.ChatMemberStatus.OWNER
):
g = await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=allfiles_{file_id}_{verify_id}", True)
else:
g = await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=allfiles_{file_id}_{verify_id}", False)
tutorial = await get_tutorial(chat_id)
await m.edit_text("Please Wait Sending to You...⚡️")
h = await second_shortlink(g, f"https://telegram.me/{temp.U_NAME}?start=allfiles_{file_id}_{verify_id}")
await m.edit_text(text=f"Get All Files in a Single Link!!!\n\n📂 ʟɪɴᴋ ➠ : {g}\n\nNote: Open Link and Get Your File and also Get access for Unlimited files for next 2hrs without getting links in this bot",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('📂 Dᴏᴡɴʟᴏᴀᴅ Nᴏᴡ 📂', url=g)
], [
InlineKeyboardButton('Nᴏᴛ Oᴘᴇɴ ᴏʀ Sᴛʀᴜᴄᴋ? Tʀʏ ᴛʜɪs 🔗', url=h)
],[
InlineKeyboardButton('⁉️ Hᴏᴡ Tᴏ Dᴏᴡɴʟᴏᴀᴅ ⁉️', url=tutorial)
]
]
)
)
# await asyncio.sleep(300)
# await k.edit("Your message is successfully deleted!!!")
return
else:
files = temp.GETALL.get(file_id)
if not files:
return await message.reply('No such file exist.')
# filesarr = []
for file in files:
file_id = file.file_id
files_ = await get_file_details(file_id)
files1 = files_[0]
title = ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files1.file_name.split()))
size=get_size(files1.file_size)
f_caption=files1.caption
if CUSTOM_FILE_CAPTION:
try:
f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
except Exception as e:
logger.exception(e)
f_caption=f_caption
if f_caption is None:
f_caption = f"{' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files1.file_name.split()))}"
if not await check_verification(client, message.from_user.id) and VERIFY == True:
btn = [[
InlineKeyboardButton("Verify", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start="))
]]
await message.reply_text(
text="You are not verified !\nKindly verify to continue !",
protect_content=True,
reply_markup=InlineKeyboardMarkup(btn)
)
return
msg = await client.send_cached_media(
chat_id=message.from_user.id,
file_id=file_id,
caption=f_caption,
protect_content=True if pre == 'filep' else False,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Watch Online/ Fast Download', callback_data=f'gen_stream_link:{file_id}')
],[
InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
],[
InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movie")
]
]
)
)
# filesarr.append(msg)
# k = await client.send_message(chat_id = message.from_user.id, text=f"❗️❗️❗️IMPORTANT❗️️❗️❗️\n\nThis Movie Files/Videos will be deleted in 10 mins 🫥 (Due to Copyright Issues).\n\nPlease forward this ALL Files/Videos to your Saved Messages and Start Download there")
# await asyncio.sleep(600)
# for x in filesarr:
# await x.delete()
# await k.edit_text("Your All Files/Videos is successfully deleted!!!")
return
elif data.startswith("short"):
user_id = message.from_user.id
if temp.SHORT.get(user_id)==None:
await message.reply_text(text="Please Search Again in Group")
return
else:
chat_id = temp.SHORT.get(user_id)
if chat_id is None:
chat_id = '-1001714266146'
files_ = await get_file_details(file_id)
files = files_[0]
if not await db.is_user_verified(user_id):
m=await message.reply_text(f" Link Generating...⏳")
verify_id = ''.join(random.choices(string.ascii_uppercase + string.digits, k=7))
await db.create_verify_id(user_id, verify_id)
g = await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=file_{file_id}_{verify_id}")
if not g:
chat_id = '-1001714266146'
g = await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=file_{file_id}_{verify_id}")
tutorial = await get_tutorial(chat_id)
await m.edit_text("Please Wait Sending to You...⚡️")
h = await second_shortlink(g, f"https://telegram.me/{temp.U_NAME}?start=file_{file_id}_{verify_id}")
await m.edit_text(text=f"📕Nᴀᴍᴇ ➠ : {files.file_name}
\n\n🔗Sɪᴢᴇ ➠ : {get_size(files.file_size)}\n\n📂Fɪʟᴇ ʟɪɴᴋ ➠ : {g}\n\nNote: Open Link and Get Your File and also Get access for Unlimited files for next 2hrs without getting links in this bot",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('📂 Dᴏᴡɴʟᴏᴀᴅ Nᴏᴡ 📂', url=g)
], [
InlineKeyboardButton('Nᴏᴛ Oᴘᴇɴ ᴏʀ Sᴛʀᴜᴄᴋ? Tʀʏ ᴛʜɪs 🔗', url=h)
],[
InlineKeyboardButton('⁉️ Hᴏᴡ Tᴏ Dᴏᴡɴʟᴏᴀᴅ ⁉️', url=tutorial)
]
]
)
)
# await asyncio.sleep(1200)
# await k.edit("Your message is successfully deleted!!!")
return
else:
title = '@TeamHMT ' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))
size=get_size(files.file_size)
f_caption=files.caption
if CUSTOM_FILE_CAPTION:
try:
f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
except Exception as e:
logger.exception(e)
f_caption=f_caption
if f_caption is None:
f_caption = f"@TeamHMT {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))}"
if not await check_verification(client, message.from_user.id) and VERIFY == True:
btn = [[
InlineKeyboardButton("Verify", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start="))
]]
await message.reply_text(
text="You are not verified !\nKindly verify to continue !",
protect_content=True,
reply_markup=InlineKeyboardMarkup(btn)
)
return
msg = await client.send_cached_media(
chat_id=message.from_user.id,
file_id=file_id,
caption=f_caption,
protect_content=True if pre == 'filep' else False,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Watch Online/ Fast Download', callback_data=f'gen_stream_link:{file_id}')
],[
InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
],[
InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movie")
]
]
)
)
# btn = [[
# InlineKeyboardButton("Get File Again", callback_data=f'delfile#{file_id}')
# ]]
# k = await msg.reply("❗️❗️❗️IMPORTANT❗️️❗️❗️\n\nThis Movie File/Video will be deleted in 10 mins 🫥 (Due to Copyright Issues).\n\nPlease forward this File/Video to your Saved Messages and Start Download there",quote=True)
# await asyncio.sleep(600)
# await msg.delete()
# await k.edit_text("Your File/Video is successfully deleted!!!\n\nClick below button to get your deleted file 👇",reply_markup=InlineKeyboardMarkup(btn))
return
elif data.startswith("all"):
m = message
user = m.from_user.id
verify_id = m.command[1].rsplit("_",1)[-1]
verify_id_info = await db.get_verify_id_info(user, verify_id)
if not verify_id_info or verify_id_info["verified"]:
await message.reply("Invalid link.😎 Link has already opened.👻 Try Again 😂")
return
ist_timezone = pytz.timezone('Asia/Kolkata')
await db.update_notcopy_user(user, {"last_verified":datetime.now(tz=ist_timezone)})
await db.update_verify_id_info(user, verify_id, {"verified":True})
await message.reply_text(text="Hey You are Successfully verified!!!\n\nGet Unlimited Files for the Next 2Hours 😎\n\nSearch movies in group and get Direct Files without any Link")
file_id = file_id.rsplit('_', 1)[0]
files = temp.GETALL.get(file_id)
if not files:
return await message.reply("No such file exist or link expired. \n\nDon't worry search again in group and click send all to get all files directly without shortener link")
return
# filesarr = []
for file in files:
file_id = file.file_id
files_ = await get_file_details(file_id)
files1 = files_[0]
title = ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files1.file_name.split()))
size=get_size(files1.file_size)
f_caption=files1.caption
if CUSTOM_FILE_CAPTION:
try:
f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
except Exception as e:
logger.exception(e)
f_caption=f_caption
if f_caption is None:
f_caption = f"{' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files1.file_name.split()))}"
if not await check_verification(client, message.from_user.id) and VERIFY == True:
btn = [[
InlineKeyboardButton("Verify", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start="))
]]
await message.reply_text(
text="You are not verified !\nKindly verify to continue !",
protect_content=True,
reply_markup=InlineKeyboardMarkup(btn)
)
return
msg = await client.send_cached_media(
chat_id=message.from_user.id,
file_id=file_id,
caption=f_caption,
protect_content=True if pre == 'filep' else False,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Watch Online/ Fast Download', callback_data=f'gen_stream_link:{file_id}')
],[
InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
],[
InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movie")
]
]
)
)
# filesarr.append(msg)
# k = await client.send_message(chat_id = message.from_user.id, text=f"❗️❗️❗️IMPORTANT❗️️❗️❗️\n\nThis Movie Files/Videos will be deleted in 10 mins 🫥 (Due to Copyright Issues).\n\nPlease forward this ALL Files/Videos to your Saved Messages and Start Download there")
# await asyncio.sleep(600)
# for x in filesarr:
# await x.delete()
# await k.edit_text("Your All Files/Videos is successfully deleted!!!")
return
elif data.startswith("files"):
user_id = message.from_user.id
if temp.SHORT.get(user_id)==None:
await message.reply_text(text="Please Search Again in Group")
return
else:
chat_id = temp.SHORT.get(user_id)
if chat_id is None:
chat_id = '-1001714266146'
settings = await get_settings(chat_id)
if settings['is_shortlink'] and user_id not in PREMIUM_USER and not await db.is_user_verified(user_id):
m=await message.reply_text(f" Link Generating...⏳")
files_ = await get_file_details(file_id)
files = files_[0]
verify_id = ''.join(random.choices(string.ascii_uppercase + string.digits, k=7))
await db.create_verify_id(user_id, verify_id)
g = await get_shortlink(chat_id, f"https://telegram.me/{temp.U_NAME}?start=file_{file_id}_{verify_id}")
tutorial = await get_tutorial(chat_id)
await m.edit_text("Please Wait Sending to You...⚡️")
h = await second_shortlink(g, f"https://telegram.me/{temp.U_NAME}?start=file_{file_id}_{verify_id}")
await m.edit_text(text=f"📕Nᴀᴍᴇ ➠ : {files.file_name}
\n\n🔗Sɪᴢᴇ ➠ : {get_size(files.file_size)}\n\n📂Fɪʟᴇ ʟɪɴᴋ ➠ : {g}\n\nNote: Open Link and Get Your File and also Get access for Unlimited files for next 2hrs without getting links in this bot",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('📂 Dᴏᴡɴʟᴏᴀᴅ Nᴏᴡ 📂', url=g)
], [
InlineKeyboardButton('Nᴏᴛ Oᴘᴇɴ ᴏʀ Sᴛʀᴜᴄᴋ? Tʀʏ ᴛʜɪs 🔗', url=h)
],[
InlineKeyboardButton('⁉️ Hᴏᴡ Tᴏ Dᴏᴡɴʟᴏᴀᴅ ⁉️', url=tutorial)
]
]
)
)
# await asyncio.sleep(1200)
# await k.edit("Your message is successfully deleted!!!")
return
else:
files_ = await get_file_details(file_id)
files = files_[0]
title = '@TeamHMT ' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))
size=get_size(files.file_size)
f_caption=files.caption
if CUSTOM_FILE_CAPTION:
try:
f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
except Exception as e:
logger.exception(e)
f_caption=f_caption
if f_caption is None:
f_caption = f"@TeamHMT {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))}"
msg = await client.send_cached_media(
chat_id=message.from_user.id,
file_id=file_id,
caption=f_caption,
protect_content=True if pre == 'filep' else False,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Watch Online/ Fast Download', callback_data=f'gen_stream_link:{file_id}')
],[
InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
],[
InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movie")
]
]
)
)
return
# btn = [[
# InlineKeyboardButton("Get File Again", callback_data=f'del#{file_id}')
# ]]
# k = await msg.reply("❗️❗️❗️IMPORTANT❗️️❗️❗️\n\nThis Movie File/Video will be deleted in 10 mins 🫥 (Due to Copyright Issues).\n\nPlease forward this File/Video to your Saved Messages and Start Download there",quote=True)
# await asyncio.sleep(600)
# await msg.delete()
# await k.edit_text("Your File/Video is successfully deleted!!!\n\nClick below button to get your deleted file 👇",reply_markup=InlineKeyboardMarkup(btn))
elif data.startswith("file"):
m = message
user = m.from_user.id
verify_id = m.command[1].rsplit("_",1)[-1]
verify_id_info = await db.get_verify_id_info(user, verify_id)
if not verify_id_info or verify_id_info["verified"]:
await message.reply("Invalid link.😎 Link has already opened.👻 Try Again 😂")
return
ist_timezone = pytz.timezone('Asia/Kolkata')
await db.update_notcopy_user(user, {"last_verified":datetime.now(tz=ist_timezone)})
await db.update_verify_id_info(user, verify_id, {"verified":True})
await message.reply_text(text="Hey You are Successfully verified!!!\n\nGet Unlimited Files for the Next 2Hours 😎\n\nSearch movies in group and get Direct Files without any Link")
file_id = file_id.rsplit('_', 1)[0]
files_ = await get_file_details(file_id)
if not files_:
pre, file_id = ((base64.urlsafe_b64decode(data + "=" * (-len(data) % 4))).decode("ascii")).split("_", 1)
try:
msg = await client.send_cached_media(
chat_id=message.from_user.id,
file_id=file_id,
protect_content=True if pre == 'filep' else False,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Watch Online/ Fast Download', callback_data=f'gen_stream_link:{file_id}')
],[
InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
],[
InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movie")
]
]
)
)
filetype = msg.media
file = getattr(msg, filetype.value)
title = '@TeamHMT ' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), file.file_name.split()))
size=get_size(file.file_size)
f_caption = f"{title}
"
if CUSTOM_FILE_CAPTION:
try:
f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='')
except:
return
await msg.edit_caption(f_caption)
# btn = [[
# InlineKeyboardButton("Get File Again", callback_data=f'delfile#{file_id}')
# ]]
# k = await msg.reply("❗️❗️❗️IMPORTANT❗️️❗️❗️\n\nThis Movie File/Video will be deleted in 10 mins 🫥 (Due to Copyright Issues).\n\nPlease forward this File/Video to your Saved Messages and Start Download there",quote=True)
# await asyncio.sleep(600)
# await msg.delete()
# await k.edit_text("Your File/Video is successfully deleted!!!\n\nClick below button to get your deleted file 👇",reply_markup=InlineKeyboardMarkup(btn))
return
except:
pass
return await message.reply('No such file exist.')
files = files_[0]
title = '@TeamHMT ' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))
size=get_size(files.file_size)
f_caption=files.caption
if CUSTOM_FILE_CAPTION:
try:
f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
except Exception as e:
logger.exception(e)
f_caption=f_caption
if f_caption is None:
f_caption = f"@TeamHMT {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))}"
if not await check_verification(client, message.from_user.id) and VERIFY == True:
btn = [[
InlineKeyboardButton("Verify", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start="))
]]
await message.reply_text(
text="You are not verified !\nKindly verify to continue !",
protect_content=True,
reply_markup=InlineKeyboardMarkup(btn)
)
return
msg = await client.send_cached_media(
chat_id=message.from_user.id,
file_id=file_id,
caption=f_caption,
protect_content=True if pre == 'filep' else False,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Watch Online/ Fast Download', callback_data=f'gen_stream_link:{file_id}')
],[
InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
],[
InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movie")
]
]
)
)
# btn = [[
# InlineKeyboardButton("Get File Again", callback_data=f'delfile#{file_id}')
# ]]
# k = await msg.reply("❗️❗️❗️IMPORTANT❗️️❗️❗️\n\nThis Movie File/Video will be deleted in 10 mins 🫥 (Due to Copyright Issues).\n\nPlease forward this File/Video to your Saved Messages and Start Download there",quote=True)
# await asyncio.sleep(600)
# await msg.delete()
# await k.edit_text("Your File/Video is successfully deleted!!!\n\nClick below button to get your deleted file 👇",reply_markup=InlineKeyboardMarkup(btn))
return
files_ = await get_file_details(file_id)
if not files_:
pre, file_id = ((base64.urlsafe_b64decode(data + "=" * (-len(data) % 4))).decode("ascii")).split("_", 1)
try:
msg = await client.send_cached_media(
chat_id=message.from_user.id,
file_id=file_id,
protect_content=True if pre == 'filep' else False,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Watch Online/ Fast Download', callback_data=f'gen_stream_link:{file_id}')
],[
InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
],[
InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movie")
]
]
)
)
filetype = msg.media
file = getattr(msg, filetype.value)
title = '@TeamHMT ' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), file.file_name.split()))
size=get_size(file.file_size)
f_caption = f"{title}
"
if CUSTOM_FILE_CAPTION:
try:
f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='')
except:
return
await msg.edit_caption(f_caption)
# btn = [[
# InlineKeyboardButton("Get File Again", callback_data=f'delfile#{file_id}')
# ]]
# k = await msg.reply("❗️❗️❗️IMPORTANT❗️️❗️❗️\n\nThis Movie File/Video will be deleted in 10 mins 🫥 (Due to Copyright Issues).\n\nPlease forward this File/Video to your Saved Messages and Start Download there",quote=True)
# await asyncio.sleep(600)
# await msg.delete()
# await k.edit_text("Your File/Video is successfully deleted!!!\n\nClick below button to get your deleted file 👇",reply_markup=InlineKeyboardMarkup(btn))
return
except:
pass
return await message.reply('No such file exist.')
files = files_[0]
title = '@TeamHMT ' + ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))
size=get_size(files.file_size)
f_caption=files.caption
if CUSTOM_FILE_CAPTION:
try:
f_caption=CUSTOM_FILE_CAPTION.format(file_name= '' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)
except Exception as e:
logger.exception(e)
f_caption=f_caption
if f_caption is None:
f_caption = f"@TeamHMT {' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files.file_name.split()))}"
if not await check_verification(client, message.from_user.id) and VERIFY == True:
btn = [[
InlineKeyboardButton("Verify", url=await get_token(client, message.from_user.id, f"https://telegram.me/{temp.U_NAME}?start="))
]]
await message.reply_text(
text="You are not verified !\nKindly verify to continue !",
protect_content=True,
reply_markup=InlineKeyboardMarkup(btn)
)
return
msg = await client.send_cached_media(
chat_id=message.from_user.id,
file_id=file_id,
caption=f_caption,
protect_content=True if pre == 'filep' else False,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Watch Online/ Fast Download', callback_data=f'gen_stream_link:{file_id}')
],[
InlineKeyboardButton('Sᴜᴘᴘᴏʀᴛ Gʀᴏᴜᴘ', url=f'https://t.me/{SUPPORT_CHAT}'),
InlineKeyboardButton('Uᴘᴅᴀᴛᴇs Cʜᴀɴɴᴇʟ', url=CHNL_LNK)
],[
InlineKeyboardButton("Mᴏᴠɪᴇ Rᴇᴏ̨ᴜᴇsᴛ Gʀᴏᴜᴘ", url="t.me/TeamHMT_Movie")
]
]
)
)
# btn = [[
# InlineKeyboardButton("Get File Again", callback_data=f'delfile#{file_id}')
# ]]
# k = await msg.reply("❗️❗️❗️IMPORTANT❗️️❗️❗️\n\nThis Movie File/Video will be deleted in 10 mins 🫥 (Due to Copyright Issues).\n\nPlease forward this File/Video to your Saved Messages and Start Download there",quote=True)
# await asyncio.sleep(600)
# await msg.delete()
# await k.edit_text("Your File/Video is successfully deleted!!!\n\nClick below button to get your deleted file 👇",reply_markup=InlineKeyboardMarkup(btn))
return
@Client.on_message(filters.command('channel') & filters.user(ADMINS))
async def channel_info(bot, message):
"""Send basic information of channel"""
if isinstance(CHANNELS, (int, str)):
channels = [CHANNELS]
elif isinstance(CHANNELS, list):
channels = CHANNELS
else:
raise ValueError("Unexpected type of CHANNELS")
text = '📑 **Indexed channels/groups**\n'
for channel in channels:
chat = await bot.get_chat(channel)
if chat.username:
text += '\n@' + chat.username
else:
text += '\n' + chat.title or chat.first_name
text += f'\n\n**Total:** {len(CHANNELS)}'
if len(text) < 4096:
await message.reply(text)
else:
file = 'Indexed channels.txt'
with open(file, 'w') as f:
f.write(text)
await message.reply_document(file)
os.remove(file)
@Client.on_message(filters.command('logs') & filters.user(ADMINS))
async def log_file(bot, message):
"""Send log file"""
try:
await message.reply_document('Logs.txt')
except Exception as e:
await message.reply(str(e))
@Client.on_message(filters.command('delete') & filters.user(ADMINS))
async def delete(bot, message):
"""Delete file from database"""
reply = message.reply_to_message
if reply and reply.media:
msg = await message.reply("Processing...⏳", quote=True)
else:
await message.reply('Reply to file with /delete which you want to delete', quote=True)
return
for file_type in ("document", "video", "audio"):
media = getattr(reply, file_type, None)
if media is not None:
break
else:
await msg.edit('This is not supported file format')
return
file_id, file_ref = unpack_new_file_id(media.file_id)
result = await Media.collection.delete_one({
'_id': file_id,
})
if result.deleted_count:
await msg.edit('File is successfully deleted from database')
else:
file_name = re.sub(r"(_|\-|\.|\+)", " ", str(media.file_name))
result = await Media.collection.delete_many({
'file_name': file_name,
'file_size': media.file_size,
'mime_type': media.mime_type
})
if result.deleted_count:
await msg.edit('File is successfully deleted from database')
else:
# files indexed before https://github.com/EvamariaTG/EvaMaria/commit/f3d2a1bcb155faf44178e5d7a685a1b533e714bf#diff-86b613edf1748372103e94cacff3b578b36b698ef9c16817bb98fe9ef22fb669R39
# have original file name.
result = await Media.collection.delete_many({
'file_name': media.file_name,
'file_size': media.file_size,
'mime_type': media.mime_type
})
if result.deleted_count:
await msg.edit('File is successfully deleted from database')
else:
await msg.edit('File not found in database')
@Client.on_message(filters.command('deleteall') & filters.user(ADMINS))
async def delete_all_index(bot, message):
await message.reply_text(
'This will delete all indexed files.\nDo you want to continue??',
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="YES", callback_data="autofilter_delete"
)
],
[
InlineKeyboardButton(
text="CANCEL", callback_data="close_data"
)
],
]
),
quote=True,
)
@Client.on_callback_query(filters.regex(r'^autofilter_delete'))
async def delete_all_index_confirm(bot, message):
await Media.collection.drop()
await message.answer('Piracy Is Crime')
await message.message.edit('Succesfully Deleted All The Indexed Files.')
@Client.on_message(filters.command('settings'))
async def settings(client, message):
userid = message.from_user.id if message.from_user else None
if not userid:
return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
chat_type = message.chat.type
if chat_type == enums.ChatType.PRIVATE:
grpid = await active_connection(str(userid))
if grpid is not None:
grp_id = grpid
try:
chat = await client.get_chat(grpid)
title = chat.title
except:
await message.reply_text("Make sure I'm present in your group!!", quote=True)
return
else:
await message.reply_text("I'm not connected to any groups!", quote=True)
return
elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
grp_id = message.chat.id
title = message.chat.title
else:
return
st = await client.get_chat_member(grp_id, userid)
if (
st.status != enums.ChatMemberStatus.ADMINISTRATOR
and st.status != enums.ChatMemberStatus.OWNER
and str(userid) not in ADMINS
):
return
settings = await get_settings(grp_id)
try:
if settings['max_btn']:
settings = await get_settings(grp_id)
except KeyError:
await save_group_settings(grp_id, 'max_btn', False)
settings = await get_settings(grp_id)
if 'is_shortlink' not in settings.keys():
await save_group_settings(grp_id, 'is_shortlink', False)
else:
pass
if settings is not None:
buttons = [
[
InlineKeyboardButton(
'Rᴇsᴜʟᴛ Pᴀɢᴇ',
callback_data=f'setgs#button#{settings["button"]}#{grp_id}',
),
InlineKeyboardButton(
'Bᴜᴛᴛᴏɴ' if settings["button"] else 'Tᴇxᴛ',
callback_data=f'setgs#button#{settings["button"]}#{grp_id}',
),
],
[
InlineKeyboardButton(
'Fɪʟᴇ Sᴇɴᴅ Mᴏᴅᴇ',
callback_data=f'setgs#botpm#{settings["botpm"]}#{grp_id}',
),
InlineKeyboardButton(
'Mᴀɴᴜᴀʟ Sᴛᴀʀᴛ' if settings["botpm"] else 'Aᴜᴛᴏ Sᴇɴᴅ',
callback_data=f'setgs#botpm#{settings["botpm"]}#{grp_id}',
),
],
[
InlineKeyboardButton(
'Pʀᴏᴛᴇᴄᴛ Cᴏɴᴛᴇɴᴛ',
callback_data=f'setgs#file_secure#{settings["file_secure"]}#{grp_id}',
),
InlineKeyboardButton(
'✔ Oɴ' if settings["file_secure"] else '✘ Oғғ',
callback_data=f'setgs#file_secure#{settings["file_secure"]}#{grp_id}',
),
],
[
InlineKeyboardButton(
'Iᴍᴅʙ',
callback_data=f'setgs#imdb#{settings["imdb"]}#{grp_id}',
),
InlineKeyboardButton(
'✔ Oɴ' if settings["imdb"] else '✘ Oғғ',
callback_data=f'setgs#imdb#{settings["imdb"]}#{grp_id}',
),
],
[
InlineKeyboardButton(
'Sᴘᴇʟʟ Cʜᴇᴄᴋ',
callback_data=f'setgs#spell_check#{settings["spell_check"]}#{grp_id}',
),
InlineKeyboardButton(
'✔ Oɴ' if settings["spell_check"] else '✘ Oғғ',
callback_data=f'setgs#spell_check#{settings["spell_check"]}#{grp_id}',
),
],
[
InlineKeyboardButton(
'Wᴇʟᴄᴏᴍᴇ Msɢ',
callback_data=f'setgs#welcome#{settings["welcome"]}#{grp_id}',
),
InlineKeyboardButton(
'✔ Oɴ' if settings["welcome"] else '✘ Oғғ',
callback_data=f'setgs#welcome#{settings["welcome"]}#{grp_id}',
),
],
[
InlineKeyboardButton(
'Aᴜᴛᴏ-Dᴇʟᴇᴛᴇ',
callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{grp_id}',
),
InlineKeyboardButton(
'5 Mɪɴs' if settings["auto_delete"] else '✘ Oғғ',
callback_data=f'setgs#auto_delete#{settings["auto_delete"]}#{grp_id}',
),
],
[
InlineKeyboardButton(
'Aᴜᴛᴏ-Fɪʟᴛᴇʀ',
callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{grp_id}',
),
InlineKeyboardButton(
'✔ Oɴ' if settings["auto_ffilter"] else '✘ Oғғ',
callback_data=f'setgs#auto_ffilter#{settings["auto_ffilter"]}#{grp_id}',
),
],
[
InlineKeyboardButton(
'Mᴀx Bᴜᴛᴛᴏɴs',
callback_data=f'setgs#max_btn#{settings["max_btn"]}#{grp_id}',
),
InlineKeyboardButton(
'10' if settings["max_btn"] else f'{MAX_B_TN}',
callback_data=f'setgs#max_btn#{settings["max_btn"]}#{grp_id}',
),
],
[
InlineKeyboardButton(
'ShortLink',
callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{grp_id}',
),
InlineKeyboardButton(
'✔ Oɴ' if settings["is_shortlink"] else '✘ Oғғ',
callback_data=f'setgs#is_shortlink#{settings["is_shortlink"]}#{grp_id}',
),
],
]
btn = [[
InlineKeyboardButton("Oᴘᴇɴ Hᴇʀᴇ ↓", callback_data=f"opnsetgrp#{grp_id}"),
InlineKeyboardButton("Oᴘᴇɴ Iɴ PM ⇲", callback_data=f"opnsetpm#{grp_id}")
]]
reply_markup = InlineKeyboardMarkup(buttons)
if chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
await message.reply_text(
text="Dᴏ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴏᴘᴇɴ sᴇᴛᴛɪɴɢs ʜᴇʀᴇ ?",
reply_markup=InlineKeyboardMarkup(btn),
disable_web_page_preview=True,
parse_mode=enums.ParseMode.HTML,
reply_to_message_id=message.id
)
else:
await message.reply_text(
text=f"Cʜᴀɴɢᴇ Yᴏᴜʀ Sᴇᴛᴛɪɴɢs Fᴏʀ {title} As Yᴏᴜʀ Wɪsʜ ⚙",
reply_markup=reply_markup,
disable_web_page_preview=True,
parse_mode=enums.ParseMode.HTML,
reply_to_message_id=message.id
)
@Client.on_message(filters.command('set_template'))
async def save_template(client, message):
sts = await message.reply("Checking template")
userid = message.from_user.id if message.from_user else None
if not userid:
return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM")
chat_type = message.chat.type
if chat_type == enums.ChatType.PRIVATE:
grpid = await active_connection(str(userid))
if grpid is not None:
grp_id = grpid
try:
chat = await client.get_chat(grpid)
title = chat.title
except:
await message.reply_text("Make sure I'm present in your group!!", quote=True)
return
else:
await message.reply_text("I'm not connected to any groups!", quote=True)
return
elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
grp_id = message.chat.id
title = message.chat.title
else:
return
st = await client.get_chat_member(grp_id, userid)
if (
st.status != enums.ChatMemberStatus.ADMINISTRATOR
and st.status != enums.ChatMemberStatus.OWNER
and str(userid) not in ADMINS
):
return
if len(message.command) < 2:
return await sts.edit("No Input!!")
template = message.text.split(" ", 1)[1]
await save_group_settings(grp_id, 'template', template)
await sts.edit(f"Successfully changed template for {title} to\n\n{template}")
@Client.on_message((filters.command(["request", "Request"]) | filters.regex("#request") | filters.regex("#Request")) & filters.group)
async def requestss(bot, message):
if REQST_CHANNEL is None or SUPPORT_CHAT_ID is None: return # Must add REQST_CHANNEL and SUPPORT_CHAT_ID to use this feature
if message.reply_to_message and SUPPORT_CHAT_ID == message.chat.id:
chat_id = message.chat.id
reporter = str(message.from_user.id)
mention = message.from_user.mention
success = True
content = message.reply_to_message.text
try:
if REQST_CHANNEL is not None:
btn = [[
InlineKeyboardButton('View Request', url=f"{message.reply_to_message.link}"),
InlineKeyboardButton('Show Options', callback_data=f'show_option#{reporter}')
]]
reported_post = await bot.send_message(chat_id=REQST_CHANNEL, text=f"𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\n\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}", reply_markup=InlineKeyboardMarkup(btn))
success = True
elif len(content) >= 3:
for admin in ADMINS:
btn = [[
InlineKeyboardButton('View Request', url=f"{message.reply_to_message.link}"),
InlineKeyboardButton('Show Options', callback_data=f'show_option#{reporter}')
]]
reported_post = await bot.send_message(chat_id=admin, text=f"𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\n\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}", reply_markup=InlineKeyboardMarkup(btn))
success = True
else:
if len(content) < 3:
await message.reply_text("You must type about your request [Minimum 3 Characters]. Requests can't be empty.")
if len(content) < 3:
success = False
except Exception as e:
await message.reply_text(f"Error: {e}")
pass
elif SUPPORT_CHAT_ID == message.chat.id:
chat_id = message.chat.id
reporter = str(message.from_user.id)
mention = message.from_user.mention
success = True
content = message.text
keywords = ["#request", "/request", "#Request", "/Request"]
for keyword in keywords:
if keyword in content:
content = content.replace(keyword, "")
try:
if REQST_CHANNEL is not None and len(content) >= 3:
btn = [[
InlineKeyboardButton('View Request', url=f"{message.link}"),
InlineKeyboardButton('Show Options', callback_data=f'show_option#{reporter}')
]]
reported_post = await bot.send_message(chat_id=REQST_CHANNEL, text=f"𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\n\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}", reply_markup=InlineKeyboardMarkup(btn))
success = True
elif len(content) >= 3:
for admin in ADMINS:
btn = [[
InlineKeyboardButton('View Request', url=f"{message.link}"),
InlineKeyboardButton('Show Options', callback_data=f'show_option#{reporter}')
]]
reported_post = await bot.send_message(chat_id=admin, text=f"𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})\n\n𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {content}", reply_markup=InlineKeyboardMarkup(btn))
success = True
else:
if len(content) < 3:
await message.reply_text("You must type about your request [Minimum 3 Characters]. Requests can't be empty.")
if len(content) < 3:
success = False
except Exception as e:
await message.reply_text(f"Error: {e}")
pass
else:
success = False
if success:
'''if isinstance(REQST_CHANNEL, (int, str)):
channels = [REQST_CHANNEL]
elif isinstance(REQST_CHANNEL, list):
channels = REQST_CHANNEL
for channel in channels:
chat = await bot.get_chat(channel)
#chat = int(chat)'''
link = await bot.create_chat_invite_link(int(REQST_CHANNEL))
btn = [[
InlineKeyboardButton('Join Channel', url=link.invite_link),
InlineKeyboardButton('View Request', url=f"{reported_post.link}")
]]
await message.reply_text("Your request has been added! Please wait for some time.\n\nJoin Channel First & View Request", reply_markup=InlineKeyboardMarkup(btn))
@Client.on_message(filters.command("send") & filters.user(ADMINS))
async def send_msg(bot, message):
if message.reply_to_message:
target_id = message.text.split(" ", 1)[1]
out = "Users Saved In DB Are:\n\n"
success = False
try:
user = await bot.get_users(target_id)
users = await db.get_all_users()
async for usr in users:
out += f"{usr['id']}"
out += '\n'
if str(user.id) in str(out):
await message.reply_to_message.copy(int(user.id))
success = True
else:
success = False
if success:
await message.reply_text(f"Your message has been successfully send to {user.mention}.")
else:
await message.reply_text("This user didn't started this bot yet !")
except Exception as e:
await message.reply_text(f"Error: {e}")
else:
await message.reply_text("Use this command as a reply to any message using the target chat id. For eg: /send userid")
@Client.on_message(filters.command("deletefiles") & filters.user(ADMINS))
async def deletemultiplefiles(bot, message):
chat_type = message.chat.type
if chat_type != enums.ChatType.PRIVATE:
return await message.reply_text(f"Hey {message.from_user.mention}, This command won't work in groups. It only works on my PM !")
else:
pass
try:
keyword = message.text.split(" ", 1)[1]
except:
return await message.reply_text(f"Hey {message.from_user.mention}, Give me a keyword along with the command to delete files.")
k = await bot.send_message(chat_id=message.chat.id, text=f"Fetching Files for your query {keyword} on DB... Please wait...")
files, total = await get_bad_files(keyword)
await k.delete()
#await k.edit_text(f"Found {total} files for your query {keyword} !\n\nFile deletion process will start in 5 seconds !")
#await asyncio.sleep(5)
btn = [[
InlineKeyboardButton("Yes, Continue !", callback_data=f"killfilesdq#{keyword}")
],[
InlineKeyboardButton("No, Abort operation !", callback_data="close_data")
]]
await message.reply_text(
text=f"Found {total} files for your query {keyword} !\n\nDo you want to delete?",
reply_markup=InlineKeyboardMarkup(btn),
parse_mode=enums.ParseMode.HTML
)
@Client.on_message(filters.command("shortlink"))
async def shortlink(bot, message):
userid = message.from_user.id if message.from_user else None
if not userid:
return await message.reply(f"You are anonymous admin. Turn off anonymous admin and try again this command")
chat_type = message.chat.type
if chat_type == enums.ChatType.PRIVATE:
return await message.reply_text(f"Hey {message.from_user.mention}, This command only works on groups !\n\nFollow These Steps to Connect Shortener:\n\n1. Add Me in Your Group with Full Admin Rights\n\n2. After Adding in Grp, Set your Shortener\n\nSend this command in your group\n\n—> /shortlink ""{your_shortener_website_name} {your_shortener_api}\n\n#Sample:-\n/shortlink api.shareus.io 4c1YTBacB6PTuwogBiEIFvZN5TI3\n\nThat's it!!! Enjoy Earning Money 💲\n\n[[[ Trusted Earning Site - https://bit.ly/44m25uG ]]]\n\nIf you have any Doubts, Feel Free to Ask me - @TeamHMT_Bot\n\n(Puriyala na intha bot la message pannunga - @TeamHMT_bot)")
elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
grpid = message.chat.id
title = message.chat.title
else:
return
data = message.text
userid = message.from_user.id
user = await bot.get_chat_member(grpid, userid)
if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS:
return await message.reply_text("You don't have access to use this command!\n\nAdd Me to Your Own Group as Admin and Try This Command\n\nFor More PM Me With This Command")
else:
pass
try:
command, shortlink_url, api = data.split(" ")
except:
return await message.reply_text("Command Incomplete :(\n\nGive me a shortener website link and api along with the command !\n\nFormat: /shortlink mplaylink.com 1f1da5c9df9a58058672ac8d8134e203b03426a1
")
reply = await message.reply_text("Please Wait...")
shortlink_url = re.sub(r"https?://?", "", shortlink_url)
shortlink_url = re.sub(r"[:/]", "", shortlink_url)
await save_group_settings(grpid, 'shortlink', shortlink_url)
await save_group_settings(grpid, 'shortlink_api', api)
await save_group_settings(grpid, 'is_shortlink', True)
await reply.edit_text(f"Successfully added shortlink API for {title}.\n\nCurrent Shortlink Website: {shortlink_url}
\nCurrent API: {api}
")
@Client.on_message(filters.command("setshortlinkoff") & filters.user(ADMINS))
async def offshortlink(bot, message):
chat_type = message.chat.type
if chat_type == enums.ChatType.PRIVATE:
return await message.reply_text("I will Work Only in group")
elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
grpid = message.chat.id
title = message.chat.title
else:
return
await save_group_settings(grpid, 'is_shortlink', False)
# ENABLE_SHORTLINK = False
return await message.reply_text("Successfully disabled shortlink")
@Client.on_message(filters.command("setshortlinkon") & filters.user(ADMINS))
async def onshortlink(bot, message):
chat_type = message.chat.type
if chat_type == enums.ChatType.PRIVATE:
return await message.reply_text("I will Work Only in group")
elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
grpid = message.chat.id
title = message.chat.title
else:
return
await save_group_settings(grpid, 'is_shortlink', True)
# ENABLE_SHORTLINK = True
return await message.reply_text("Successfully enabled shortlink")
@Client.on_message(filters.command("shortlink_info"))
async def showshortlink(bot, message):
userid = message.from_user.id if message.from_user else None
if not userid:
return await message.reply(f"You are anonymous admin. Turn off anonymous admin and try again this command")
chat_type = message.chat.type
if chat_type == enums.ChatType.PRIVATE:
return await message.reply_text(f"Hey {message.from_user.mention}, This Command Only Works in Group\n\nTry this command in your own group, if you are using me in your group")
elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
grpid = message.chat.id
title = message.chat.title
else:
return
chat_id=message.chat.id
userid = message.from_user.id
user = await bot.get_chat_member(grpid, userid)
# if 'shortlink' in settings.keys():
# su = settings['shortlink']
# sa = settings['shortlink_api']
# else:
# return await message.reply_text("Shortener Url Not Connected\n\nYou can Connect Using /shortlink command")
# if 'tutorial' in settings.keys():
# st = settings['tutorial']
# else:
# return await message.reply_text("Tutorial Link Not Connected\n\nYou can Connect Using /set_tutorial command")
if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS:
return await message.reply_text("Tʜɪs ᴄᴏᴍᴍᴀɴᴅ Wᴏʀᴋs Oɴʟʏ Fᴏʀ ᴛʜɪs Gʀᴏᴜᴘ Oᴡɴᴇʀ/Aᴅᴍɪɴ\n\nTʀʏ ᴛʜɪs ᴄᴏᴍᴍᴀɴᴅ ɪɴ ʏᴏᴜʀ Oᴡɴ Gʀᴏᴜᴘ, Iғ Yᴏᴜ Aʀᴇ Usɪɴɢ Mᴇ Iɴ Yᴏᴜʀ Gʀᴏᴜᴘ")
else:
settings = await get_settings(chat_id) #fetching settings for group
if 'shortlink' in settings.keys() and 'tutorial' in settings.keys():
su = settings['shortlink']
sa = settings['shortlink_api']
st = settings['tutorial']
return await message.reply_text(f"Shortlink Website: {su}
\n\nApi: {sa}
\n\nTutorial: {st}
")
elif 'shortlink' in settings.keys() and 'tutorial' not in settings.keys():
su = settings['shortlink']
sa = settings['shortlink_api']
return await message.reply_text(f"Shortener Website: {su}
\n\nApi: {sa}
\n\nTutorial Link Not Connected\n\nYou can Connect Using /set_tutorial command")
elif 'shortlink' not in settings.keys() and 'tutorial' in settings.keys():
st = settings['tutorial']
return await message.reply_text(f"Tutorial: {st}
\n\nShortener Url Not Connected\n\nYou can Connect Using /shortlink command")
else:
return await message.reply_text("Shortener url and Tutorial Link Not Connected. Check this commands, /shortlink and /set_tutorial")
@Client.on_message(filters.command("set_tutorial"))
async def settutorial(bot, message):
userid = message.from_user.id if message.from_user else None
if not userid:
return await message.reply(f"You are anonymous admin. Turn off anonymous admin and try again this command")
chat_type = message.chat.type
if chat_type == enums.ChatType.PRIVATE:
return await message.reply_text("This Command Work Only in group\n\nTry it in your own group")
elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
grpid = message.chat.id
title = message.chat.title
else:
return
userid = message.from_user.id
user = await bot.get_chat_member(grpid, userid)
if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS:
return
else:
pass
if len(message.command) == 1:
return await message.reply("Give me a tutorial link along with this command\n\nCommand Usage: /set_tutorial your tutorial link")
elif len(message.command) == 2:
reply = await message.reply_text("Please Wait...")
tutorial = message.command[1]
await save_group_settings(grpid, 'tutorial', tutorial)
await save_group_settings(grpid, 'is_tutorial', True)
await reply.edit_text(f"Successfully Added Tutorial\n\nHere is your tutorial link for your group {title} - {tutorial}
")
else:
return await message.reply("You entered Incorrect Format\n\nFormat: /set_tutorial your tutorial link")
@Client.on_message(filters.command("remove_tutorial"))
async def removetutorial(bot, message):
userid = message.from_user.id if message.from_user else None
if not userid:
return await message.reply(f"You are anonymous admin. Turn off anonymous admin and try again this command")
chat_type = message.chat.type
if chat_type == enums.ChatType.PRIVATE:
return await message.reply_text("This Command Work Only in group\n\nTry it in your own group")
elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
grpid = message.chat.id
title = message.chat.title
else:
return
userid = message.from_user.id
user = await bot.get_chat_member(grpid, userid)
if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS:
return
else:
pass
reply = await message.reply_text("Please Wait...")
await save_group_settings(grpid, 'is_tutorial', False)
await reply.edit_text(f"Successfully Removed Your Tutorial Link!!!")
@Client.on_message(filters.command("restart") & filters.user(ADMINS))
async def stop_button(bot, message):
msg = await bot.send_message(text="**🔄 𝙿𝚁𝙾𝙲𝙴𝚂𝚂𝙴𝚂 𝚂𝚃𝙾𝙿𝙴𝙳. 𝙱𝙾𝚃 𝙸𝚂 𝚁𝙴𝚂𝚃𝙰𝚁𝚃𝙸𝙽𝙶...**", chat_id=message.chat.id)
await asyncio.sleep(3)
await msg.edit("**✅️ 𝙱𝙾𝚃 𝙸𝚂 𝚁𝙴𝚂𝚃𝙰𝚁𝚃𝙴𝙳. 𝙽𝙾𝚆 𝚈𝙾𝚄 𝙲𝙰𝙽 𝚄𝚂𝙴 𝙼𝙴**")
os.execl(sys.executable, sys.executable, *sys.argv)
@Client.on_message(filters.group & filters.command("fsub"))
async def f_sub_cmd(bot, message):
userid = message.from_user.id if message.from_user else None
if not userid:
return await message.reply(f"You are anonymous admin. Turn off anonymous admin and try again this command")
chat_type = message.chat.type
if chat_type == enums.ChatType.PRIVATE:
return await message.reply_text("This Command Work Only in group\n\nTry it in your own group")
elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
grpid = message.chat.id
title = message.chat.title
else:
return
userid = message.from_user.id
user = await bot.get_chat_member(grpid, userid)
if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS:
return
else:
pass
m=await message.reply("Please wait...")
try:
group = await get_group(message.chat.id)
user_id = group["user_id"]
user_name = group["user_name"]
verified = group["verified"]
except:
await add_group(group_id=grpid, group_name=title, user_name=message.from_user.first_name, user_id=userid, channels=[], f_sub=False, verified=False)
# return await bot.leave_chat(message.chat.id)
group = await get_group(message.chat.id)
user_id = group["user_id"]
user_name = group["user_name"]
verified = group["verified"]
if message.from_user.id!=user_id:
return await m.edit(f"Only {user_name} can use this command 😁")
if bool(verified)==False:
return await m.edit(f"Hey {message.from_user.mention}, This chat is not verified!\n\nUse /verify to verify your group")
try:
f_sub = int(message.command[-1])
except:
return await m.edit("❌ Incorrect format!\nUse `/fsub ChannelID`")
try:
chat = await bot.get_chat(f_sub)
group = await bot.get_chat(message.chat.id)
c_link = chat.invite_link
g_link = group.invite_link
except Exception as e:
text = f"❌ Error: `{str(e)}`\n\nMake sure I'm admin in that channel & this group with all permissions"
return await m.edit(text)
await update_group(message.chat.id, {"f_sub":f_sub})
await m.edit(f"✅ Successfully Attached ForceSub to [{chat.title}]({c_link})!", disable_web_page_preview=True)
text = f"#NewFsub\n\nUser: {message.from_user.mention}\nGroup: [{group.title}]({g_link})\nChannel: [{chat.title}]({c_link})"
await bot.send_message(chat_id=LOG_CHANNEL, text=text)
@Client.on_message(filters.group & filters.command("nofsub"))
async def nf_sub_cmd(bot, message):
userid = message.from_user.id if message.from_user else None
if not userid:
return await message.reply(f"You are anonymous admin. Turn off anonymous admin and try again this command")
chat_type = message.chat.type
if chat_type == enums.ChatType.PRIVATE:
return await message.reply_text("This Command Work Only in group\n\nTry it in your own group")
elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
grpid = message.chat.id
title = message.chat.title
else:
return
userid = message.from_user.id
user = await bot.get_chat_member(grpid, userid)
if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS:
return
else:
pass
m=await message.reply("Trying to Remove Fsub..")
try:
group = await get_group(message.chat.id)
user_id = group["user_id"]
user_name = group["user_name"]
verified = group["verified"]
f_sub = group["f_sub"]
except:
await add_group(group_id=grpid, group_name=title, user_name=message.from_user.first_name, user_id=userid, channels=[], f_sub=False, verified=False)
# return await bot.leave_chat(message.chat.id)
group = await get_group(message.chat.id)
user_id = group["user_id"]
user_name = group["user_name"]
verified = group["verified"]
f_sub = group["f_sub"]
# return await bot.leave_chat(message.chat.id)
if message.from_user.id!=user_id:
return await m.edit(f"Only {user_name} can use this command 😁")
if bool(verified)==False:
return await m.edit(f"Hey {message.from_user.mention}, This chat is not verified!\n\nUse /verify to verify your group")
if bool(f_sub)==False:
return await m.edit("This chat is currently don't have any FSub\nuse /fsub")
try:
chat = await bot.get_chat(f_sub)
group = await bot.get_chat(message.chat.id)
c_link = chat.invite_link
g_link = group.invite_link
except Exception as e:
text = f"❌ Error: `{str(e)}`\n\nMake sure I'm admin in that channel & this group with all permissions"
return await m.edit(text)
await update_group(message.chat.id, {"f_sub":False})
await m.edit(f"✅ Successfully removed FSub from [{chat.title}]({c_link})!", disable_web_page_preview=True)
text = f"#RemoveFsub\n\nUser: {message.from_user.mention}\nGroup: [{group.title}]({g_link})\nChannel: [{chat.title}]({c_link})"
await bot.send_message(chat_id=LOG_CHANNEL, text=text)
@Client.on_callback_query(filters.regex(r"^checksub"))
async def f_sub_callback(bot, update):
user_id = int(update.data.split("_")[-1])
group = await get_group(update.message.chat.id)
f_sub = group["f_sub"]
admin = group["user_id"]
if update.from_user.id!=user_id:
return await update.answer("That's not for you 😂", show_alert=True)
try:
await bot.get_chat_member(f_sub, user_id)
except UserNotParticipant:
await update.answer("I like your smartness..\nBut don't be over smart 🤭", show_alert=True) # @subinps 😁
except:
await update.answer("Great! You can Request Movies Now")
await bot.restrict_chat_member(chat_id=update.message.chat.id,
user_id=user_id,
permissions=ChatPermissions(can_send_messages=True,
can_send_media_messages=True,
can_send_other_messages=True,
can_invite_users=True))
await update.message.delete()
else:
await update.answer("Great! You can Request Movies Now")
await bot.restrict_chat_member(chat_id=update.message.chat.id,
user_id=user_id,
permissions=ChatPermissions(can_send_messages=True,
can_send_media_messages=True,
can_send_other_messages=True,
can_invite_users=True))
await update.message.delete()
@Client.on_message(filters.group & filters.command("verify"))
async def _verify(bot, message):
userid = message.from_user.id if message.from_user else None
if not userid:
return await message.reply(f"You are anonymous admin. Turn off anonymous admin and try again this command")
chat_type = message.chat.type
if chat_type == enums.ChatType.PRIVATE:
return await message.reply_text("This Command Work Only in group\n\nTry it in your own group")
elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
grpid = message.chat.id
title = message.chat.title
else:
return
userid = message.from_user.id
user = await bot.get_chat_member(grpid, userid)
if user.status != enums.ChatMemberStatus.ADMINISTRATOR and user.status != enums.ChatMemberStatus.OWNER and str(userid) not in ADMINS:
return
else:
pass
try:
group = await get_group(message.chat.id)
user_id = group["user_id"]
user_name = group["user_name"]
verified = group["verified"]
except:
await add_group(group_id=grpid, group_name=title, user_name=message.from_user.first_name, user_id=userid, channels=[], f_sub=False, verified=False)
group = await get_group(message.chat.id)
user_id = group["user_id"]
user_name = group["user_name"]
verified = group["verified"]
try:
user = await bot.get_users(user_id)
except:
return await message.reply(f"❌ {user_name} Need to start me in PM!")
if message.from_user.id != user_id:
return await message.reply(f"Only {user.mention} can use this command 😁")
if verified==True:
return await message.reply("This Group is already verified!")
try:
link = (await bot.get_chat(message.chat.id)).invite_link
except:
return message.reply("❌ Make me admin here with all permissions!")
text = f"#NewRequest\n\n"
text += f"User: {message.from_user.mention}\n"
text += f"User ID: `{message.from_user.id}`\n"
text += f"Group: [{message.chat.title}]({link})\n"
text += f"Group ID: `{message.chat.id}`\n"
await bot.send_message(chat_id=LOG_CHANNEL,
text=text,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[[InlineKeyboardButton("✅ Approve", callback_data=f"verify_approve_{message.chat.id}"),
InlineKeyboardButton("❌ Decline", callback_data=f"verify_decline_{message.chat.id}")]]))
await message.reply_text(text="Verification Request sent ✅\nWe will notify You Personally when it is approved\n\nFor instant Verification, Contact our Support group",disable_web_page_preview=True)
@Client.on_callback_query(filters.regex(r"^verify"))
async def verify_(bot, update):
id = int(update.data.split("_")[-1])
group = await get_group(id)
name = group["name"]
user = group["user_id"]
if update.data.split("_")[1]=="approve":
await update_group(id, {"verified":True})
await bot.send_message(chat_id=user, text=f"Your verification request for {name} has been approved ✅\n\nYou can add Force sub in your group now")
await update.message.edit(update.message.text.html.replace("#NewRequest", "#Approved"))
else:
await delete_group(id)
await bot.send_message(chat_id=user, text=f"Your verification request for {name} has been declined 😐\n\nFor Approving Your Group,\n\n1. Your group must be a movie group\n\n2. Your group should have 200+ members\n\n3. Do not promote any adult contents\n\nIf You Followed Rules, But Verification Declined? Please Contact My Owner", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Contact", url="https://t.me/Kgashok04")]]))
await update.message.edit(update.message.text.html.replace("#NewRequest", "#Declined"))
@Client.on_message(filters.user(ADMINS) & filters.command("ping"))
async def ping(_, message):
start_t = time.time()
rm = await message.reply_text("...........")
end_t = time.time()
time_taken_s = (end_t - start_t) * 1000
await rm.edit(f"𝖯𝗂𝗇𝗀!\n{time_taken_s:.3f} ms")
@Client.on_message(filters.command("scrap") & filters.user(ADMINS))
async def scrap_cmd(bot, message):
user = message.from_user.id if message.from_user else None
if len(message.command) == 1:
return await message.reply("❌ Incorrect format!")
elif len(message.command) == 2:
url = message.command[1]
else:
return await message.reply("❌ Incorrect format!")
try:
if "1tamilmv" in url:
response = requests.get(url)
if response.status_code == 200:
soup = BeautifulSoup(response.content, "html.parser")
magnet_links_with_text = []
# Find all elements with text and magnet links using regular expression
for element in soup.find_all("span", style="color:#0000ff;"):
text = element.text.strip()
magnet_link = element.find_next(
"a", href=re.compile(r"magnet:\?xt=urn:btih:"))["href"]
magnet_links_with_text.append((text, magnet_link))
if magnet_links_with_text:
for title, link in magnet_links_with_text:
await bot.send_message(
chat_id=user,
text=f"Name: {title}\n\nMagnet Link: {link}
"
)
else:
await bot.send_message(chat_id=user, text="No magnet links found.")
else:
await bot.send_message(chat_id=user, text="Error: Failed to fetch the website.")
else:
response = requests.get(url)
if response.status_code == 200:
soup = BeautifulSoup(response.content, "html.parser")
magnet_links = []
# Find all anchor tags with magnet links using regular expression
for anchor in soup.find_all("a", href=re.compile(r"magnet:\?xt=urn:btih:")):
magnet_links.append(anchor["href"])
if magnet_links:
# print("Magnet Links:")
for link in magnet_links:
await bot.send_message(chat_id=user, text=link)
else:
await bot.send_message(chat_id=user, text="No magnet links found.")
else:
await bot.send_message(chat_id=user, text="Error: Failed to fetch the website.")
except Exception as e:
await bot.send_message(chat_id=user, text=f"Error:{e}")