forked from Learningbots79/movies
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
3,437 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from aiohttp import web | ||
from .route import routes | ||
from asyncio import sleep | ||
from datetime import datetime | ||
from database.users_chats_db import db | ||
from info import LOG_CHANNEL | ||
|
||
async def web_server(): | ||
web_app = web.Application(client_max_size=30000000) | ||
web_app.add_routes(routes) | ||
return web_app | ||
|
||
async def check_expired_premium(client): | ||
while 1: | ||
data = await db.get_expired(datetime.now()) | ||
for user in data: | ||
user_id = user["id"] | ||
await db.remove_premium_access(user_id) | ||
try: | ||
user = await client.get_users(user_id) | ||
await client.send_message( | ||
chat_id=user_id, | ||
text=f"<b>ʜᴇʏ {user.mention},\n\nʏᴏᴜʀ ᴘʀᴇᴍɪᴜᴍ ᴀᴄᴄᴇss ʜᴀs ᴇxᴘɪʀᴇᴅ, ᴛʜᴀɴᴋ ʏᴏᴜ ꜰᴏʀ ᴜsɪɴɢ ᴏᴜʀ sᴇʀᴠɪᴄᴇ 😊\n\nɪꜰ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴛᴀᴋᴇ ᴛʜᴇ ᴘʀᴇᴍɪᴜᴍ ᴀɢᴀɪɴ, ᴛʜᴇɴ ᴄʟɪᴄᴋ ᴏɴ ᴛʜᴇ /plan ꜰᴏʀ ᴛʜᴇ ᴅᴇᴛᴀɪʟs ᴏꜰ ᴛʜᴇ ᴘʟᴀɴs...</b>" | ||
) | ||
await client.send_message(LOG_CHANNEL, text=f"<b>#Premium_Expire\n\nUser name: {user.mention}\nUser id: <code>{user_id}</code>") | ||
except Exception as e: | ||
print(e) | ||
await sleep(0.5) | ||
await sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from pyrogram.raw.types import UpdateBotStopped | ||
from pyrogram.types import Update | ||
from database.users_chats_db import db | ||
import logging | ||
from pyrogram import Client, ContinuePropagation | ||
|
||
@Client.on_raw_update(group=-15) | ||
async def blocked_user(_: Client, u: Update, __: dict, ___: dict): | ||
if not isinstance(u, UpdateBotStopped): | ||
raise ContinuePropagation | ||
if not u.stopped: | ||
return | ||
await db.delete_user(u.user_id) | ||
logging.info(f"{u.user_id} - Removed from Database, since blocked account.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from pyrogram import Client, filters | ||
from utils import temp | ||
from pyrogram.types import Message | ||
from database.users_chats_db import db | ||
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup | ||
from info import SUPPORT_CHAT, LOG_CHANNEL | ||
|
||
async def banned_users(_, client, message: Message): | ||
return ( | ||
message.from_user is not None or not message.sender_chat | ||
) and message.from_user.id in temp.BANNED_USERS | ||
|
||
banned_user = filters.create(banned_users) | ||
|
||
async def disabled_chat(_, client, message: Message): | ||
return message.chat.id in temp.BANNED_CHATS | ||
|
||
disabled_group=filters.create(disabled_chat) | ||
|
||
|
||
#@Client.on_message(filters.private & banned_user & filters.incoming) | ||
#async def ban_reply(bot, message): | ||
# ban = await db.get_ban_status(message.from_user.id) | ||
# await message.reply(f'Sorry Dude, You are Banned to use Me. \nBan Reason : {ban["ban_reason"]}') | ||
|
||
@Client.on_message(filters.private & banned_user & filters.incoming) | ||
async def ban_reply(bot, message): | ||
ban = await db.get_ban_status(message.from_user.id) | ||
username = message.from_user.username or 'No Username' | ||
# Send reply to the user | ||
await message.reply(f'Telegram says: [400 PEER_ID_INVALID] - The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it') | ||
|
||
# Send message to the log channel | ||
await bot.send_message( | ||
LOG_CHANNEL, | ||
f"User ID: {message.from_user.id}\nUsername: @{username} tried to message, but they are banned.\nBan Reason: {ban['ban_reason']}" | ||
) | ||
|
||
@Client.on_message(filters.group & disabled_group & filters.incoming) | ||
async def grp_bd(bot, message): | ||
buttons = [[ | ||
InlineKeyboardButton('Support', url=f'https://t.me/JISSHU_SUPPORT') | ||
]] | ||
reply_markup=InlineKeyboardMarkup(buttons) | ||
vazha = await db.get_chat(message.chat.id) | ||
k = await message.reply( | ||
text=f"CHAT NOT ALLOWED 🐞\n\nMy admins has restricted me from working here ! If you want to know more about it contact support..\nReason : <code>{vazha['reason']}</code>.", | ||
reply_markup=reply_markup) | ||
try: | ||
await k.pin() | ||
except: | ||
pass | ||
await bot.leave_chat(message.chat.id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
from pyrogram import Client, filters | ||
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup | ||
from pyrogram.errors.exceptions.bad_request_400 import MessageTooLong | ||
from info import ADMINS, LOG_CHANNEL, USERNAME | ||
from database.users_chats_db import db | ||
from database.ia_filterdb import Media, get_files_db_size | ||
from utils import get_size, temp | ||
from Script import script | ||
from datetime import datetime | ||
import psutil | ||
import time | ||
|
||
@Client.on_message(filters.new_chat_members & filters.group) | ||
async def save_group(bot, message): | ||
check = [u.id for u in message.new_chat_members] | ||
if temp.ME in check: | ||
if (str(message.chat.id)).startswith("-100") and not await db.get_chat(message.chat.id): | ||
total=await bot.get_chat_members_count(message.chat.id) | ||
user = message.from_user.mention if message.from_user else "Dear" | ||
group_link = await message.chat.export_invite_link() | ||
await bot.send_message(LOG_CHANNEL, script.NEW_GROUP_TXT.format(temp.B_LINK, message.chat.title, message.chat.id, message.chat.username, group_link, total, user), disable_web_page_preview=True) | ||
await db.add_chat(message.chat.id, message.chat.title) | ||
btn = [[ | ||
InlineKeyboardButton('⚡️ sᴜᴘᴘᴏʀᴛ ⚡️', url=USERNAME) | ||
]] | ||
reply_markup=InlineKeyboardMarkup(btn) | ||
await bot.send_message( | ||
chat_id=message.chat.id, | ||
text=f"<b>☤ ᴛʜᴀɴᴋ ʏᴏᴜ ꜰᴏʀ ᴀᴅᴅɪɴɢ ᴍᴇ ɪɴ {message.chat.title}\n\n🤖 ᴅᴏɴ’ᴛ ꜰᴏʀɢᴇᴛ ᴛᴏ ᴍᴀᴋᴇ ᴍᴇ ᴀᴅᴍɪɴ 🤖\n\n㊝ ɪꜰ ʏᴏᴜ ʜᴀᴠᴇ ᴀɴʏ ᴅᴏᴜʙᴛ ʏᴏᴜ ᴄʟᴇᴀʀ ɪᴛ ᴜsɪɴɢ ʙᴇʟᴏᴡ ʙᴜᴛᴛᴏɴs ㊜</b>", | ||
reply_markup=reply_markup | ||
) | ||
|
||
@Client.on_message(filters.command('leave') & filters.user(ADMINS)) | ||
async def leave_a_chat(bot, message): | ||
r = message.text.split(None) | ||
if len(message.command) == 1: | ||
return await message.reply('<b>ᴜꜱᴇ ᴛʜɪꜱ ᴄᴏᴍᴍᴀɴᴅ ʟɪᴋᴇ ᴛʜɪꜱ `/leave -100******`</b>') | ||
if len(r) > 2: | ||
reason = message.text.split(None, 2)[2] | ||
chat = message.text.split(None, 2)[1] | ||
else: | ||
chat = message.command[1] | ||
reason = "ɴᴏ ʀᴇᴀꜱᴏɴ ᴘʀᴏᴠɪᴅᴇᴅ..." | ||
try: | ||
chat = int(chat) | ||
except: | ||
chat = chat | ||
try: | ||
btn = [[ | ||
InlineKeyboardButton('⚡️ ᴏᴡɴᴇʀ ⚡️', url=USERNAME) | ||
]] | ||
reply_markup=InlineKeyboardMarkup(btn) | ||
await bot.send_message( | ||
chat_id=chat, | ||
text=f'😞 ʜᴇʟʟᴏ ᴅᴇᴀʀ,\nᴍʏ ᴏᴡɴᴇʀ ʜᴀꜱ ᴛᴏʟᴅ ᴍᴇ ᴛᴏ ʟᴇᴀᴠᴇ ꜰʀᴏᴍ ɢʀᴏᴜᴘ ꜱᴏ ɪ ɢᴏ 😔\n\n🚫 ʀᴇᴀꜱᴏɴ ɪꜱ - <code>{reason}</code>\n\nɪꜰ ʏᴏᴜ ɴᴇᴇᴅ ᴛᴏ ᴀᴅᴅ ᴍᴇ ᴀɢᴀɪɴ ᴛʜᴇɴ ᴄᴏɴᴛᴀᴄᴛ ᴍʏ ᴏᴡɴᴇʀ 👇', | ||
reply_markup=reply_markup, | ||
) | ||
await bot.leave_chat(chat) | ||
await db.delete_chat(chat) | ||
await message.reply(f"<b>ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ ʟᴇꜰᴛ ꜰʀᴏᴍ ɢʀᴏᴜᴘ - `{chat}`</b>") | ||
except Exception as e: | ||
await message.reply(f'<b>🚫 ᴇʀʀᴏʀ - `{e}`</b>') | ||
|
||
@Client.on_message(filters.command('groups') & filters.user(ADMINS)) | ||
async def groups_list(bot, message): | ||
msg = await message.reply('<b>Searching...</b>') | ||
chats = await db.get_all_chats() | ||
out = "Groups saved in the database:\n\n" | ||
count = 1 | ||
async for chat in chats: | ||
chat_info = await bot.get_chat(chat['id']) | ||
members_count = chat_info.members_count if chat_info.members_count else "Unknown" | ||
out += f"<b>{count}. Title - `{chat['title']}`\nID - `{chat['id']}`\nMembers - `{members_count}`</b>" | ||
out += '\n\n' | ||
count += 1 | ||
try: | ||
if count > 1: | ||
await msg.edit_text(out) | ||
else: | ||
await msg.edit_text("<b>No groups found</b>") | ||
except MessageTooLong: | ||
with open('chats.txt', 'w+') as outfile: | ||
outfile.write(out) | ||
await message.reply_document('chats.txt', caption="<b>List of all groups</b>") | ||
|
||
@Client.on_message(filters.command('stats') & filters.user(ADMINS) & filters.incoming) | ||
async def get_ststs(bot, message): | ||
users = await db.total_users_count() | ||
groups = await db.total_chat_count() | ||
size = get_size(await db.get_db_size()) | ||
free = get_size(536870912) | ||
files = await Media.count_documents() | ||
db2_size = get_size(await get_files_db_size()) | ||
db2_free = get_size(536870912) | ||
uptime = time.strftime("%Hh %Mm %Ss", time.gmtime(time.time() - time.time())) | ||
ram = psutil.virtual_memory().percent | ||
cpu = psutil.cpu_percent() | ||
await message.reply_text(script.STATUS_TXT.format(users, groups, size, free, files, db2_size, db2_free, uptime, ram, cpu)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
from pyrogram import Client, filters | ||
import datetime | ||
import time | ||
from database.users_chats_db import db | ||
from info import ADMINS | ||
from utils import users_broadcast, groups_broadcast, temp, get_readable_time | ||
import asyncio | ||
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, ReplyKeyboardMarkup | ||
|
||
lock = asyncio.Lock() | ||
|
||
@Client.on_callback_query(filters.regex(r'^broadcast_cancel')) | ||
async def broadcast_cancel(bot, query): | ||
_, ident = query.data.split("#") | ||
if ident == 'users': | ||
await query.message.edit("ᴛʀʏɪɴɢ ᴛᴏ ᴄᴀɴᴄᴇʟ ᴜsᴇʀs ʙʀᴏᴀᴅᴄᴀsᴛɪɴɢ...") | ||
temp.USERS_CANCEL = True | ||
elif ident == 'groups': | ||
temp.GROUPS_CANCEL = True | ||
await query.message.edit("ᴛʀʏɪɴɢ ᴛᴏ ᴄᴀɴᴄᴇʟ ɢʀᴏᴜᴘs ʙʀᴏᴀᴅᴄᴀsᴛɪɴɢ...") | ||
|
||
@Client.on_message(filters.command("broadcast") & filters.user(ADMINS) & filters.reply) | ||
async def broadcast_users(bot, message): | ||
if lock.locked(): | ||
return await message.reply('Currently broadcast processing, Wait for complete.') | ||
|
||
p = await message.reply('<b>Do you want pin this message in users?</b>', reply_markup=ReplyKeyboardMarkup([['Yes', 'No']], one_time_keyboard=True, resize_keyboard=True)) | ||
msg = await bot.listen(chat_id=message.chat.id, user_id=message.from_user.id) | ||
if msg.text == 'Yes': | ||
is_pin = True | ||
elif msg.text == 'No': | ||
is_pin = False | ||
else: | ||
await p.delete() | ||
return await message.reply_text('Wrong Response!') | ||
await p.delete() | ||
users = await db.get_all_users() | ||
b_msg = message.reply_to_message | ||
b_sts = await message.reply_text(text='<b>ʙʀᴏᴀᴅᴄᴀsᴛɪɴɢ ʏᴏᴜʀ ᴍᴇssᴀɢᴇs ᴛᴏ ᴜsᴇʀs ⌛️</b>') | ||
start_time = time.time() | ||
total_users = await db.total_users_count() | ||
done = 0 | ||
blocked = 0 | ||
deleted = 0 | ||
failed = 0 | ||
success = 0 | ||
|
||
async with lock: | ||
async for user in users: | ||
time_taken = get_readable_time(time.time()-start_time) | ||
if temp.USERS_CANCEL: | ||
temp.USERS_CANCEL = False | ||
await b_sts.edit(f"Users broadcast Cancelled!\nCompleted in {time_taken}\n\nTotal Users: <code>{total_users}</code>\nCompleted: <code>{done} / {total_users}</code>\nSuccess: <code>{success}</code>") | ||
return | ||
sts = await users_broadcast(int(user['id']), b_msg, is_pin) | ||
if sts == 'Success': | ||
success += 1 | ||
elif sts == 'Error': | ||
failed += 1 | ||
done += 1 | ||
if not done % 20: | ||
btn = [[ | ||
InlineKeyboardButton('CANCEL', callback_data=f'broadcast_cancel#users') | ||
]] | ||
await b_sts.edit(f"Users broadcast in progress...\n\nTotal Users: <code>{total_users}</code>\nCompleted: <code>{done} / {total_users}</code>\nSuccess: <code>{success}</code>", reply_markup=InlineKeyboardMarkup(btn)) | ||
await b_sts.edit(f"Users broadcast completed.\nCompleted in {time_taken}\n\nTotal Users: <code>{total_users}</code>\nCompleted: <code>{done} / {total_users}</code>\nSuccess: <code>{success}</code>") | ||
|
||
@Client.on_message(filters.command("grp_broadcast") & filters.user(ADMINS) & filters.reply) | ||
async def broadcast_group(bot, message): | ||
p = await message.reply('<b>Do you want pin this message in groups?</b>', reply_markup=ReplyKeyboardMarkup([['Yes', 'No']], one_time_keyboard=True, resize_keyboard=True)) | ||
msg = await bot.listen(chat_id=message.chat.id, user_id=message.from_user.id) | ||
if msg.text == 'Yes': | ||
is_pin = True | ||
elif msg.text == 'No': | ||
is_pin = False | ||
else: | ||
await p.delete() | ||
return await message.reply_text('Wrong Response!') | ||
await p.delete() | ||
chats = await db.get_all_chats() | ||
b_msg = message.reply_to_message | ||
b_sts = await message.reply_text(text='<b>ʙʀᴏᴀᴅᴄᴀsᴛɪɴɢ ʏᴏᴜʀ ᴍᴇssᴀɢᴇs ᴛᴏ ɢʀᴏᴜᴘs ⏳</b>') | ||
start_time = time.time() | ||
total_chats = await db.total_chat_count() | ||
done = 0 | ||
failed = 0 | ||
success = 0 | ||
|
||
async with lock: | ||
async for chat in chats: | ||
time_taken = get_readable_time(time.time()-start_time) | ||
if temp.GROUPS_CANCEL: | ||
temp.GROUPS_CANCEL = False | ||
await b_sts.edit(f"Groups broadcast Cancelled!\nCompleted in {time_taken}\n\nTotal Groups: <code>{total_chats}</code>\nCompleted: <code>{done} / {total_chats}</code>\nSuccess: <code>{success}</code>\nFailed: <code>{failed}</code>") | ||
return | ||
sts = await groups_broadcast(int(chat['id']), b_msg, is_pin) | ||
if sts == 'Success': | ||
success += 1 | ||
elif sts == 'Error': | ||
failed += 1 | ||
done += 1 | ||
if not done % 20: | ||
btn = [[ | ||
InlineKeyboardButton('CANCEL', callback_data=f'broadcast_cancel#groups') | ||
]] | ||
await b_sts.edit(f"Groups groadcast in progress...\n\nTotal Groups: <code>{total_chats}</code>\nCompleted: <code>{done} / {total_chats}</code>\nSuccess: <code>{success}</code>\nFailed: <code>{failed}</code>", reply_markup=InlineKeyboardMarkup(btn)) | ||
await b_sts.edit(f"Groups broadcast completed.\nCompleted in {time_taken}\n\nTotal Groups: <code>{total_chats}</code>\nCompleted: <code>{done} / {total_chats}</code>\nSuccess: <code>{success}</code>\nFailed: <code>{failed}</code>") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from pyrogram import Client, filters | ||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton | ||
from info import CHANNELS, MOVIE_UPDATE_CHANNEL, ADMINS , LOG_CHANNEL | ||
from database.ia_filterdb import save_file, unpack_new_file_id | ||
from utils import get_poster, temp | ||
import re | ||
from Script import script | ||
from database.users_chats_db import db | ||
|
||
|
||
processed_movies = set() | ||
media_filter = filters.document | filters.video | ||
|
||
media_filter = filters.document | filters.video | ||
|
||
@Client.on_message(filters.chat(CHANNELS) & media_filter) | ||
async def media(bot, message): | ||
media = getattr(message, message.media.value, None) | ||
if media.mime_type in ['video/mp4', 'video/x-matroska']: | ||
media.file_type = message.media.value | ||
media.caption = message.caption | ||
success_sts = await save_file(media) | ||
if success_sts == 'suc': | ||
file_id, file_ref = unpack_new_file_id(media.file_id) | ||
await send_movie_updates(bot, file_name=media.file_name, file_id=file_id) | ||
|
||
def name_format(file_name: str): | ||
file_name = file_name.lower() | ||
file_name = re.sub(r'http\S+', '', re.sub(r'@\w+|#\w+', '', file_name).replace('_', ' ').replace('[', '').replace(']', '')).strip() | ||
file_name = re.split(r's\d+|season\s*\d+|chapter\s*\d+', file_name, flags=re.IGNORECASE)[0] | ||
file_name = file_name.strip() | ||
words = file_name.split()[:4] | ||
imdb_file_name = ' '.join(words) | ||
return imdb_file_name | ||
|
||
async def get_imdb(file_name): | ||
imdb_file_name = name_format(file_name) | ||
imdb = await get_poster(imdb_file_name) | ||
if imdb: | ||
caption = script.MOVIES_UPDATE_TXT.format( | ||
title=imdb.get('title'), | ||
rating=imdb.get('rating'), | ||
genres=imdb.get('genres'), | ||
year=imdb.get('year') | ||
) | ||
return imdb.get('title'), imdb.get('poster'), caption | ||
return None, None, None | ||
|
||
async def send_movie_updates(bot, file_name, file_id): | ||
imdb_title, poster_url, caption = await get_imdb(file_name) | ||
if imdb_title in processed_movies: | ||
return | ||
processed_movies.add(imdb_title) | ||
if not poster_url or not caption: | ||
return | ||
btn = [ | ||
[InlineKeyboardButton('Get File', url=f'https://t.me/{temp.U_NAME}?start=pm_mode_file_{ADMINS[0]}_{file_id}')] | ||
] | ||
reply_markup = InlineKeyboardMarkup(btn) | ||
movie_update_channel =await db.movies_update_channel_id() | ||
try: | ||
await bot.send_photo(movie_update_channel if movie_update_channel else MOVIE_UPDATE_CHANNEL, photo=poster_url, caption=caption, reply_markup=reply_markup) | ||
except Exception as e: | ||
print('Failed to send movie update. Error - ', e) | ||
await bot.send_message(LOG_CHANNEL, f'Failed to send movie update. Error - <code>{e}</b>') |
Oops, something went wrong.