├── assets ├── Tedt ├── AJAX.png ├── logo.jpg ├── New Project 48 [C6E5D45].png └── Picsart_22-02-20_13-02-59-464.jpg ├── plugins ├── Restrictions │ ├── @ │ ├── Unban.py │ ├── Ban.py │ └── Restrict.py ├── helper_functions │ ├── @ │ ├── get_file_id.py │ ├── last_online_hlpr.py │ ├── admin_check.py │ ├── cust_p_filters.py │ ├── extract_user.py │ └── string_handling.py ├── Don │ ├── sticker.py │ ├── Report_User.py │ ├── yt_thumb_dl.py │ ├── covid.py │ ├── gtranslator.py │ ├── audiobook.py │ └── url_shortner.py ├── channel.py ├── admemes │ ├── pin_message.py │ ├── tts.py │ ├── telegraph.py │ ├── purge.py │ ├── ping.py │ ├── paste.py │ ├── list.py │ ├── in_kick.py │ └── song.py ├── lallu_tg │ ├── dice.py │ ├── goal.py │ ├── arrow.py │ ├── luck.py │ ├── json.py │ ├── runs.py │ └── whois.py ├── banned.py ├── broadcast.py ├── photo.py ├── inline.py ├── connection.py ├── genlink.py ├── index.py ├── filters.py ├── p_ttishow.py └── misc.py ├── Procfile ├── runtime.txt ├── heroku.yml ├── sample_config.py ├── start.sh ├── Dockerfile ├── logging.conf ├── sample_info.py ├── requirements.txt ├── database ├── gtrans_mdb.py ├── filters_mdb.py ├── connections_mdb.py ├── users_chats_db.py └── ia_filterdb.py ├── bot.py ├── helper_func.py ├── README.md ├── app.json ├── info.py ├── image ├── edit_3.py ├── edit_1.py └── edit_2.py └── utils.py /assets/Tedt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /plugins/Restrictions/@: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | worker: python3 bot.py -------------------------------------------------------------------------------- /plugins/helper_functions/@: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.10.2 2 | -------------------------------------------------------------------------------- /heroku.yml: -------------------------------------------------------------------------------- 1 | build: 2 | docker: 3 | worker: Dockerfile -------------------------------------------------------------------------------- /assets/AJAX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aadhi000/Ajax-Extra-Features/HEAD/assets/AJAX.png -------------------------------------------------------------------------------- /assets/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aadhi000/Ajax-Extra-Features/HEAD/assets/logo.jpg -------------------------------------------------------------------------------- /sample_config.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | class Config(object): 5 | RemoveBG_API = os.environ.get("RemoveBG_API", "") 6 | -------------------------------------------------------------------------------- /assets/New Project 48 [C6E5D45].png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aadhi000/Ajax-Extra-Features/HEAD/assets/New Project 48 [C6E5D45].png -------------------------------------------------------------------------------- /assets/Picsart_22-02-20_13-02-59-464.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aadhi000/Ajax-Extra-Features/HEAD/assets/Picsart_22-02-20_13-02-59-464.jpg -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | if [ -z $UPSTREAM_REPO ] 2 | then 3 | echo "Cloning main Repository" 4 | git clone https://github.com/Aadhi000/Ajax.git /Ajax 5 | else 6 | echo "Cloning Custom Repo from $UPSTREAM_REPO " 7 | git clone $UPSTREAM_REPO /Ajax 8 | fi 9 | cd /Ajax 10 | pip3 install -U -r requirements.txt 11 | echo "Starting ᗩᒍᗩ᙭....🔥" 12 | python3 bot.py 13 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.10-slim-buster 2 | 3 | RUN apt update && apt upgrade -y 4 | RUN apt install git -y 5 | COPY requirements.txt /requirements.txt 6 | 7 | RUN cd / 8 | RUN pip3 install -U pip && pip3 install -U -r requirements.txt 9 | RUN mkdir /Ajax-Extra-Features 10 | WORKDIR /Ajax-Extra-Features 11 | COPY start.sh /start.sh 12 | CMD ["/bin/bash", "/start.sh"] 13 | -------------------------------------------------------------------------------- /plugins/Don/sticker.py: -------------------------------------------------------------------------------- 1 | #Made 2 | #by 3 | #Don_Sflix 4 | 5 | from pyrogram import Client, filters 6 | 7 | @Client.on_message(filters.command(["stickerid"])) 8 | async def stickerid(bot, message): 9 | if message.reply_to_message.sticker: 10 | await message.reply(f"**Sticker ID is** \n `{message.reply_to_message.sticker.file_id}` \n \n ** Unique ID is ** \n\n`{message.reply_to_message.sticker.file_unique_id}`", quote=True) 11 | else: 12 | await message.reply("Oops !! Not a sticker file") 13 | -------------------------------------------------------------------------------- /plugins/channel.py: -------------------------------------------------------------------------------- 1 | from pyrogram import Client, filters 2 | from info import CHANNELS 3 | from database.ia_filterdb import save_file 4 | 5 | media_filter = filters.document | filters.video | filters.audio 6 | 7 | 8 | @Client.on_message(filters.chat(CHANNELS) & media_filter) 9 | async def media(bot, message): 10 | """Media Handler""" 11 | for file_type in ("document", "video", "audio"): 12 | media = getattr(message, file_type, None) 13 | if media is not None: 14 | break 15 | else: 16 | return 17 | 18 | media.file_type = file_type 19 | media.caption = message.caption 20 | await save_file(media) -------------------------------------------------------------------------------- /plugins/helper_functions/get_file_id.py: -------------------------------------------------------------------------------- 1 | from pyrogram.types import Message 2 | from pyrogram.types.messages_and_media import message 3 | 4 | 5 | def get_file_id(msg: Message): 6 | if msg.media: 7 | for message_type in ( 8 | "photo", 9 | "animation", 10 | "audio", 11 | "document", 12 | "video", 13 | "video_note", 14 | "voice", 15 | # "contact", 16 | # "dice", 17 | # "poll", 18 | # "location", 19 | # "venue", 20 | "sticker" 21 | ): 22 | obj = getattr(msg, message_type) 23 | if obj: 24 | setattr(obj, "message_type", message_type) 25 | return obj 26 | -------------------------------------------------------------------------------- /logging.conf: -------------------------------------------------------------------------------- 1 | [loggers] 2 | keys=root 3 | 4 | [handlers] 5 | keys=consoleHandler,fileHandler 6 | 7 | [formatters] 8 | keys=consoleFormatter,fileFormatter 9 | 10 | [logger_root] 11 | level=DEBUG 12 | handlers=consoleHandler,fileHandler 13 | 14 | [handler_consoleHandler] 15 | class=StreamHandler 16 | level=INFO 17 | formatter=consoleFormatter 18 | args=(sys.stdout,) 19 | 20 | [handler_fileHandler] 21 | class=FileHandler 22 | level=ERROR 23 | formatter=fileFormatter 24 | args=('TelegramBot.log','w',) 25 | 26 | [formatter_consoleFormatter] 27 | format=%(asctime)s - %(lineno)d - %(name)s - %(module)s - %(levelname)s - %(message)s 28 | datefmt=%I:%M:%S %p 29 | 30 | [formatter_fileFormatter] 31 | format=[%(asctime)s:%(name)s:%(lineno)d:%(levelname)s] %(message)s 32 | datefmt=%m/%d/%Y %I:%M:%S %p -------------------------------------------------------------------------------- /plugins/admemes/pin_message.py: -------------------------------------------------------------------------------- 1 | # credits: https://github.com/SpEcHiDe/PyroGramBot/pull/34 2 | 3 | 4 | from pyrogram import Client, filters 5 | from pyrogram.types import Message 6 | from info import COMMAND_HAND_LER 7 | from plugins.helper_functions.cust_p_filters import ( 8 | admin_fliter 9 | ) 10 | 11 | @Client.on_message( 12 | filters.command(["pin"], COMMAND_HAND_LER) & 13 | admin_fliter 14 | ) 15 | async def pin(_, message: Message): 16 | if not message.reply_to_message: 17 | return 18 | await message.reply_to_message.pin() 19 | 20 | 21 | @Client.on_message( 22 | filters.command(["unpin"], COMMAND_HAND_LER) & 23 | admin_fliter 24 | ) 25 | async def unpin(_, message: Message): 26 | if not message.reply_to_message: 27 | return 28 | await message.reply_to_message.unpin() 29 | -------------------------------------------------------------------------------- /plugins/lallu_tg/dice.py: -------------------------------------------------------------------------------- 1 | # codes added by @lallu_tg 2 | # use with proper credits 3 | 4 | from pyrogram import Client, filters 5 | from info import COMMAND_HAND_LER 6 | from plugins.helper_functions.cust_p_filters import f_onw_fliter 7 | 8 | # EMOJI CONSTANTS 9 | DICE_E_MOJI = "🎲" 10 | # EMOJI CONSTANTS 11 | 12 | 13 | @Client.on_message( 14 | filters.command(["roll", "dice"], COMMAND_HAND_LER) & 15 | f_onw_fliter 16 | ) 17 | async def roll_dice(client, message): 18 | """ @RollaDie """ 19 | rep_mesg_id = message.message_id 20 | if message.reply_to_message: 21 | rep_mesg_id = message.reply_to_message.message_id 22 | await client.send_dice( 23 | chat_id=message.chat.id, 24 | emoji=DICE_E_MOJI, 25 | disable_notification=True, 26 | reply_to_message_id=rep_mesg_id 27 | ) 28 | -------------------------------------------------------------------------------- /plugins/lallu_tg/goal.py: -------------------------------------------------------------------------------- 1 | # codes added by @PaulWalker_tg 2 | # use with proper credits 3 | 4 | from pyrogram import Client, filters 5 | from info import COMMAND_HAND_LER 6 | from plugins.helper_functions.cust_p_filters import f_onw_fliter 7 | 8 | # EMOJI CONSTANTS 9 | GOAL_E_MOJI = "⚽" 10 | # EMOJI CONSTANTS 11 | 12 | 13 | @Client.on_message( 14 | filters.command(["goal", "shoot"], COMMAND_HAND_LER) & 15 | f_onw_fliter 16 | ) 17 | async def roll_dice(client, message): 18 | """ @Goal """ 19 | rep_mesg_id = message.message_id 20 | if message.reply_to_message: 21 | rep_mesg_id = message.reply_to_message.message_id 22 | await client.send_dice( 23 | chat_id=message.chat.id, 24 | emoji=GOAL_E_MOJI, 25 | disable_notification=True, 26 | reply_to_message_id=rep_mesg_id 27 | ) 28 | -------------------------------------------------------------------------------- /plugins/helper_functions/last_online_hlpr.py: -------------------------------------------------------------------------------- 1 | from pyrogram.types import User 2 | from datetime import datetime 3 | 4 | 5 | def last_online(from_user: User) -> str: 6 | time = "" 7 | if from_user.is_bot: 8 | time += "🤖 Bot :(" 9 | elif from_user.status == 'recently': 10 | time += "Recently" 11 | elif from_user.status == 'within_week': 12 | time += "Within the last week" 13 | elif from_user.status == 'within_month': 14 | time += "Within the last month" 15 | elif from_user.status == 'long_time_ago': 16 | time += "A long time ago :(" 17 | elif from_user.status == 'online': 18 | time += "Currently Online" 19 | elif from_user.status == 'offline': 20 | time += datetime.fromtimestamp(from_user.last_online_date).strftime("%a, %d %b %Y, %H:%M:%S") 21 | return time 22 | -------------------------------------------------------------------------------- /sample_info.py: -------------------------------------------------------------------------------- 1 | # Bot information 2 | SESSION = 'Media_search' 3 | USER_SESSION = 'User_Bot' 4 | API_ID = 12345 5 | API_HASH = '0123456789abcdef0123456789abcdef' 6 | BOT_TOKEN = '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11' 7 | USERBOT_STRING_SESSION = '' 8 | 9 | # Bot settings 10 | CACHE_TIME = 300 11 | USE_CAPTION_FILTER = False 12 | 13 | # Admins, Channels & Users 14 | ADMINS = [12345789, 'admin123', 98765432] 15 | CHANNELS = [-10012345678, -100987654321, 'channelusername'] 16 | AUTH_USERS = [] 17 | AUTH_CHANNEL = None 18 | 19 | # MongoDB information 20 | DATABASE_URI = "mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb]?retryWrites=true&w=majority" 21 | DATABASE_NAME = 'Telegram' 22 | COLLECTION_NAME = 'channel_files' # If you are using the same database, then use different collection name for each bot 23 | 24 | 25 | -------------------------------------------------------------------------------- /plugins/lallu_tg/arrow.py: -------------------------------------------------------------------------------- 1 | # codes added by @lallu_tg 2 | # use with proper credits 3 | 4 | from pyrogram import Client, filters 5 | from info import COMMAND_HAND_LER 6 | from plugins.helper_functions.cust_p_filters import f_onw_fliter 7 | 8 | # EMOJI CONSTANTS 9 | DART_E_MOJI = "🎯" 10 | # EMOJI CONSTANTS 11 | 12 | 13 | @Client.on_message( 14 | filters.command(["throw", "dart"], COMMAND_HAND_LER) & 15 | f_onw_fliter 16 | ) 17 | async def throw_dart(client, message): 18 | """ /throw an @AnimatedDart """ 19 | rep_mesg_id = message.message_id 20 | if message.reply_to_message: 21 | rep_mesg_id = message.reply_to_message.message_id 22 | await client.send_dice( 23 | chat_id=message.chat.id, 24 | emoji=DART_E_MOJI, 25 | disable_notification=True, 26 | reply_to_message_id=rep_mesg_id 27 | ) 28 | 29 | -------------------------------------------------------------------------------- /plugins/lallu_tg/luck.py: -------------------------------------------------------------------------------- 1 | # code added by @lallu_tg 2 | # use with proper credits 3 | 4 | 5 | from pyrogram import Client, filters 6 | from info import COMMAND_HAND_LER 7 | from plugins.helper_functions.cust_p_filters import f_onw_fliter 8 | 9 | # LUCK------------ https://telegram.me/Josprojects ------------ # 10 | 11 | # EMOJI CONSTANTS 12 | TRY_YOUR_LUCK = "🎰" 13 | # EMOJI CONSTANTS 14 | 15 | @Client.on_message( 16 | filters.command(["luck", "cownd"]) 17 | ) 18 | async def luck_cownd(client, message): 19 | """ /luck an @animatedluck """ 20 | rep_mesg_id = message.message_id 21 | if message.reply_to_message: 22 | rep_mesg_id = message.reply_to_message.message_id 23 | await client.send_dice( 24 | chat_id=message.chat.id, 25 | emoji=TRY_YOUR_LUCK, 26 | disable_notification=True, 27 | reply_to_message_id=rep_mesg_id 28 | ) 29 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | git+https://github.com/subinps/pyrogram@inline-m 2 | tgcrypto 3 | pymongo[srv]==3.11.4 4 | motor==2.4.0 5 | marshmallow==3.12.2 6 | python-telegram-bot==11.1.0 7 | umongo==3.0.0 8 | requests 9 | bs4 10 | Pyromod 11 | imdbpy==2021.4.18 12 | youtube-dl 13 | youtube_search 14 | requests 15 | googletrans==3.1.0a0 16 | telegraph 17 | beautifulsoup4 18 | aiohttp==3.7.4 19 | gTTS 20 | googletrans==3.1.0a0 21 | NumPy 22 | glitch_this 23 | opencv-python-headless 24 | youtube-search-python==1.4.6 25 | yt-dlp 26 | pypng 27 | Pillow 28 | wget 29 | aiofiles 30 | psutil 31 | wheel 32 | humanize 33 | ytthumb 34 | pypdf2 35 | PyPDF2 36 | pyshorteners 37 | ffmpeg-python 38 | TgCrypto 39 | py-tgcalls 40 | python-dotenv 41 | youtube_search_python 42 | requests 43 | aiohttp 44 | aiofiles 45 | asyncio 46 | youtube_search 47 | search_engine_parser 48 | ffmpeg-python 49 | ffmpeg 50 | Pillow 51 | ujson 52 | -------------------------------------------------------------------------------- /plugins/helper_functions/admin_check.py: -------------------------------------------------------------------------------- 1 | from pyrogram.types import Message 2 | 3 | 4 | async def admin_check(message: Message) -> bool: 5 | if not message.from_user: 6 | return False 7 | 8 | if message.chat.type not in ["supergroup", "channel"]: 9 | return False 10 | 11 | if message.from_user.id in [ 12 | 777000, # Telegram Service Notifications 13 | 1087968824 # GroupAnonymousBot 14 | ]: 15 | return True 16 | 17 | client = message._client 18 | chat_id = message.chat.id 19 | user_id = message.from_user.id 20 | 21 | check_status = await client.get_chat_member( 22 | chat_id=chat_id, 23 | user_id=user_id 24 | ) 25 | admin_strings = [ 26 | "creator", 27 | "administrator" 28 | ] 29 | # https://git.colinshark.de/PyroBot/PyroBot/src/branch/master/pyrobot/modules/admin.py#L69 30 | if check_status.status not in admin_strings: 31 | return False 32 | else: 33 | return True 34 | -------------------------------------------------------------------------------- /plugins/helper_functions/cust_p_filters.py: -------------------------------------------------------------------------------- 1 | from pyrogram import ( 2 | filters 3 | ) 4 | from info import ADMINS, AUTH_USERS 5 | from plugins.helper_functions.admin_check import admin_check 6 | import os 7 | 8 | USE_AS_BOT = os.environ.get("USE_AS_BOT", True) 9 | 10 | def f_sudo_filter(filt, client, message): 11 | return bool( 12 | message.from_user.id in AUTH_USERS 13 | ) 14 | 15 | 16 | sudo_filter = filters.create( 17 | func=f_sudo_filter, 18 | name="SudoFilter" 19 | ) 20 | 21 | 22 | def onw_filter(filt, client, message): 23 | if USE_AS_BOT: 24 | return bool( 25 | True # message.from_user.id in ADMINS 26 | ) 27 | else: 28 | return bool( 29 | message.from_user and 30 | message.from_user.is_self 31 | ) 32 | 33 | 34 | f_onw_fliter = filters.create( 35 | func=onw_filter, 36 | name="OnwFilter" 37 | ) 38 | 39 | 40 | async def admin_filter_f(filt, client, message): 41 | return await admin_check(message) 42 | 43 | 44 | admin_fliter = filters.create( 45 | func=admin_filter_f, 46 | name="AdminFilter" 47 | ) 48 | -------------------------------------------------------------------------------- /database/gtrans_mdb.py: -------------------------------------------------------------------------------- 1 | import pymongo 2 | 3 | from info import DATABASE_URI, DATABASE_NAME 4 | 5 | import logging 6 | logger = logging.getLogger(__name__) 7 | logger.setLevel(logging.ERROR) 8 | 9 | myclient = pymongo.MongoClient(DATABASE_URI) 10 | mydb = myclient[DATABASE_NAME] 11 | mycol = mydb["USER"] 12 | 13 | def insert(chat_id): 14 | user_id = int(chat_id) 15 | user_det = {"_id":user_id,"lg_code":None} 16 | try: 17 | mycol.insert_one(user_det) 18 | except: 19 | pass 20 | 21 | def set(chat_id,lg_code): 22 | mycol.update_one({"_id":chat_id},{"$set":{"lg_code":lg_code}}) 23 | 24 | 25 | def unset(chat_id): 26 | mycol.update_one({"_id":chat_id},{"$set":{"lg_code":None}}) 27 | 28 | def find(chat_id): 29 | id = {"_id":chat_id} 30 | x = mycol.find(id) 31 | for i in x: 32 | lgcd = i["lg_code"] 33 | return lgcd 34 | 35 | def getid(): 36 | values = [] 37 | for key in mycol.find(): 38 | id = key["_id"] 39 | values.append((id)) 40 | return values 41 | 42 | def find_one(id): 43 | return mycol.find_one({"_id":id}) 44 | -------------------------------------------------------------------------------- /plugins/Restrictions/Unban.py: -------------------------------------------------------------------------------- 1 | from pyrogram import Client, filters 2 | from plugins.helper_functions.admin_check import admin_check 3 | from plugins.helper_functions.extract_user import extract_user 4 | 5 | 6 | @Client.on_message(filters.command(["unban", "unmute"])) 7 | async def un_ban_user(_, message): 8 | is_admin = await admin_check(message) 9 | if not is_admin: 10 | return 11 | 12 | user_id, user_first_name = extract_user(message) 13 | 14 | try: 15 | await message.chat.unban_member( 16 | user_id=user_id 17 | ) 18 | except Exception as error: 19 | await message.reply_text( 20 | str(error) 21 | ) 22 | else: 23 | if str(user_id).lower().startswith("@"): 24 | await message.reply_text( 25 | "Okay, changed ... now " 26 | f"{user_first_name} To " 27 | " You can join the group!" 28 | ) 29 | else: 30 | await message.reply_text( 31 | "Okay, changed ... now " 32 | f"" 33 | f"{user_first_name}" 34 | " To " 35 | " You can join the group!" 36 | ) 37 | -------------------------------------------------------------------------------- /plugins/Don/Report_User.py: -------------------------------------------------------------------------------- 1 | import pyrogram 2 | import asyncio 3 | import os 4 | from pyrogram import filters, Client as Sflix 5 | 6 | @Sflix.on_message((filters.command(["report"]) | filters.regex("@admins") | filters.regex("@admin")) & filters.group) 7 | async def report_user(bot, message): 8 | if message.reply_to_message: 9 | chat_id = message.chat.id 10 | reporter = str(message.from_user.id) 11 | mention = message.from_user.mention 12 | admins = await bot.get_chat_members(chat_id=chat_id, filter="administrators") 13 | success = True 14 | report = f"𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝗋 : {mention} ({reporter})" + "\n" 15 | report += f"𝖬𝖾𝗌𝗌𝖺𝗀𝖾 : {message.reply_to_message.link}" 16 | for admin in admins: 17 | try: 18 | reported_post = await message.reply_to_message.forward(admin.user.id) 19 | await reported_post.reply_text( 20 | text=report, 21 | chat_id=admin.user.id, 22 | disable_web_page_preview=True 23 | ) 24 | success = True 25 | except: 26 | pass 27 | if success: 28 | await message.reply_text("𝖱𝖾𝗉𝗈𝗋𝗍𝖾𝖽 𝗍𝗈 𝖠𝖽𝗆𝗂𝗇𝗌!") 29 | -------------------------------------------------------------------------------- /plugins/Don/yt_thumb_dl.py: -------------------------------------------------------------------------------- 1 | import os 2 | import time 3 | import ytthumb 4 | from pyrogram import Client, filters 5 | from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton 6 | 7 | 8 | @Client.on_message(filters.command(["ytthumb", 'dlthumb'])) 9 | async def send_thumbnail(bot, update): 10 | message = await update.reply_text( 11 | text="`𝙂𝙚𝙣𝙚𝙧𝙖𝙩𝙞𝙣𝙜 𝙏𝙝𝙪𝙢𝙗𝙣𝙖𝙞𝙡 𝙊𝙛 𝙔𝙤𝙪𝙧 𝙇𝙞𝙣𝙠...`", 12 | disable_web_page_preview=True, 13 | quote=True 14 | ) 15 | try: 16 | if " | " in update.text: 17 | video = update.text.split(" | ", -1)[0] 18 | quality = update.text.split(" | ", -1)[1] 19 | else: 20 | video = update.text 21 | quality = "sd" 22 | thumbnail = ytthumb.thumbnail( 23 | video=video, 24 | quality=quality 25 | ) 26 | await update.reply_photo( 27 | photo=thumbnail, 28 | quote=True 29 | ) 30 | await message.delete() 31 | except Exception as error: 32 | await message.edit_text( 33 | text="**Please Use** /ytthumb (youtube link)\n\n**Example:** `/ytthumb https://youtu.be/examplelink`", 34 | disable_web_page_preview=True 35 | ) 36 | -------------------------------------------------------------------------------- /plugins/admemes/tts.py: -------------------------------------------------------------------------------- 1 | 2 | import traceback 3 | from asyncio import get_running_loop 4 | from io import BytesIO 5 | 6 | from googletrans import Translator 7 | from gtts import gTTS 8 | from pyrogram import Client, filters 9 | from pyrogram.types import Message 10 | 11 | 12 | def convert(text): 13 | audio = BytesIO() 14 | i = Translator().translate(text, dest="en") 15 | lang = i.src 16 | tts = gTTS(text, lang=lang) 17 | audio.name = lang + ".mp3" 18 | tts.write_to_fp(audio) 19 | return audio 20 | 21 | 22 | @Client.on_message(filters.command("tts")) 23 | async def text_to_speech(_, message: Message): 24 | if not message.reply_to_message: 25 | return await message.reply_text("Reply to some text ffs.") 26 | if not message.reply_to_message.text: 27 | return await message.reply_text("Reply to some text ffs.") 28 | m = await message.reply_text("Processing") 29 | text = message.reply_to_message.text 30 | try: 31 | loop = get_running_loop() 32 | audio = await loop.run_in_executor(None, convert, text) 33 | await message.reply_audio(audio) 34 | await m.delete() 35 | audio.close() 36 | except Exception as e: 37 | await m.edit(e) 38 | e = traceback.format_exc() 39 | print(e) 40 | -------------------------------------------------------------------------------- /plugins/helper_functions/extract_user.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from pyrogram.types import Message 5 | 6 | 7 | def extract_user(message: Message) -> (int, str): 8 | """extracts the user from a message""" 9 | user_id = None 10 | user_first_name = None 11 | 12 | if message.reply_to_message: 13 | user_id = message.reply_to_message.from_user.id 14 | user_first_name = message.reply_to_message.from_user.first_name 15 | 16 | elif len(message.command) > 1: 17 | if ( 18 | len(message.entities) > 1 and 19 | message.entities[1].type == "text_mention" 20 | ): 21 | # 0: is the command used 22 | # 1: should be the user specified 23 | required_entity = message.entities[1] 24 | user_id = required_entity.user.id 25 | user_first_name = required_entity.user.first_name 26 | else: 27 | user_id = message.command[1] 28 | # don't want to make a request -_- 29 | user_first_name = user_id 30 | 31 | try: 32 | user_id = int(user_id) 33 | except ValueError: 34 | print("പൊട്ടൻ") 35 | 36 | else: 37 | user_id = message.from_user.id 38 | user_first_name = message.from_user.first_name 39 | 40 | return (user_id, user_first_name) 41 | -------------------------------------------------------------------------------- /plugins/admemes/telegraph.py: -------------------------------------------------------------------------------- 1 | import os 2 | import shutil 3 | from pyrogram import Client, filters 4 | from telegraph import upload_file 5 | from info import TMP_DOWNLOAD_DIRECTORY 6 | from plugins.helper_functions.cust_p_filters import f_onw_fliter 7 | from plugins.helper_functions.get_file_id import get_file_id 8 | 9 | 10 | @Client.on_message( 11 | filters.command("telegraph") & 12 | f_onw_fliter 13 | ) 14 | async def telegraph(client, message): 15 | replied = message.reply_to_message 16 | if not replied: 17 | await message.reply_text("𝚁𝙴𝙿𝙻𝚈 𝚃𝙾 𝙰 𝙿𝙷𝙾𝚃𝙾 𝙾𝚁 𝚅𝙸𝙳𝙴𝙾 𝚄𝙽𝙳𝙴𝚁 𝟻𝙼𝙱.") 18 | return 19 | file_info = get_file_id(replied) 20 | if not file_info: 21 | await message.reply_text("Not supported!") 22 | return 23 | _t = os.path.join( 24 | TMP_DOWNLOAD_DIRECTORY, 25 | str(replied.message_id) 26 | ) 27 | if not os.path.isdir(_t): 28 | os.makedirs(_t) 29 | _t += "/" 30 | download_location = await replied.download( 31 | _t 32 | ) 33 | try: 34 | response = upload_file(download_location) 35 | except Exception as document: 36 | await message.reply_text(message, text=document) 37 | else: 38 | await message.reply( 39 | f"Link :- https://telegra.ph{response[0]}", 40 | disable_web_page_preview=True 41 | ) 42 | finally: 43 | shutil.rmtree( 44 | _t, 45 | ignore_errors=True 46 | ) 47 | -------------------------------------------------------------------------------- /plugins/Don/covid.py: -------------------------------------------------------------------------------- 1 | import os 2 | import requests 3 | from requests.utils import requote_uri 4 | from pyrogram import Client, filters 5 | from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton 6 | 7 | API = "https://api.sumanjay.cf/covid/?country=" 8 | 9 | BUTTONS = InlineKeyboardMarkup([[InlineKeyboardButton("𝙲𝙻𝙾𝚂𝙴", callback_data='close_data')]]) 10 | 11 | @Client.on_message(filters.command("covid")) 12 | async def reply_info(client, message): 13 | query = message.text.split(None, 1)[1] 14 | await message.reply_photo( 15 | photo="https://telegra.ph/file/1b837a8df2670b0097aaf.jpg", 16 | caption=covid_info(query), 17 | quote=True 18 | ) 19 | 20 | 21 | def covid_info(country_name): 22 | try: 23 | r = requests.get(API + requote_uri(country_name.lower())) 24 | info = r.json() 25 | country = info['country'].capitalize() 26 | active = info['active'] 27 | confirmed = info['confirmed'] 28 | deaths = info['deaths'] 29 | info_id = info['id'] 30 | last_update = info['last_update'] 31 | latitude = info['latitude'] 32 | longitude = info['longitude'] 33 | recovered = info['recovered'] 34 | covid_info = f"""--**𝙲𝙾𝚅𝙸𝙳 𝟷𝟿 𝙸𝙽𝙵𝙾𝚁𝙼𝙰𝚃𝙸𝙾𝙽**-- 35 | ᚛› Country : `{country}` 36 | ᚛› Actived : `{active}` 37 | ᚛› Confirmed : `{confirmed}` 38 | ᚛› Deaths : `{deaths}` 39 | ᚛› ID : `{info_id}` 40 | ᚛› Last Update : `{last_update}` 41 | ᚛› Latitude : `{latitude}` 42 | ᚛› Longitude : `{longitude}` 43 | ᚛› Recovered : `{recovered}`""" 44 | return covid_info 45 | except Exception as error: 46 | return error 47 | -------------------------------------------------------------------------------- /bot.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import logging.config 3 | 4 | # Get logging configurations 5 | logging.config.fileConfig('logging.conf') 6 | logging.getLogger().setLevel(logging.INFO) 7 | logging.getLogger("pyrogram").setLevel(logging.ERROR) 8 | logging.getLogger("imdbpy").setLevel(logging.ERROR) 9 | 10 | from pyrogram import Client, __version__ 11 | from pyrogram.raw.all import layer 12 | from database.ia_filterdb import Media 13 | from database.users_chats_db import db 14 | from info import SESSION, API_ID, API_HASH, BOT_TOKEN, LOG_STR 15 | from utils import temp 16 | 17 | class Bot(Client): 18 | 19 | def __init__(self): 20 | super().__init__( 21 | session_name=SESSION, 22 | api_id=API_ID, 23 | api_hash=API_HASH, 24 | bot_token=BOT_TOKEN, 25 | workers=50, 26 | plugins={"root": "plugins"}, 27 | sleep_threshold=5, 28 | ) 29 | 30 | async def start(self): 31 | b_users, b_chats = await db.get_banned() 32 | temp.BANNED_USERS = b_users 33 | temp.BANNED_CHATS = b_chats 34 | await super().start() 35 | await Media.ensure_indexes() 36 | me = await self.get_me() 37 | temp.ME = me.id 38 | temp.U_NAME = me.username 39 | temp.B_NAME = me.first_name 40 | self.username = '@' + me.username 41 | logging.info(f"{me.first_name} with for Pyrogram v{__version__} (Layer {layer}) started on {me.username}.") 42 | logging.info(LOG_STR) 43 | 44 | async def stop(self, *args): 45 | await super().stop() 46 | logging.info("Restarting Ajax.") 47 | 48 | 49 | app = Bot() 50 | app.run() 51 | -------------------------------------------------------------------------------- /plugins/banned.py: -------------------------------------------------------------------------------- 1 | from pyrogram import Client, filters 2 | from utils import temp 3 | from pyrogram.types import Message 4 | from database.users_chats_db import db 5 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 6 | from info import SUPPORT_CHAT 7 | async def banned_users(_, client, message: Message): 8 | return ( 9 | message.from_user is not None or not message.sender_chat 10 | ) and message.from_user.id in temp.BANNED_USERS 11 | 12 | banned_user = filters.create(banned_users) 13 | 14 | async def disabled_chat(_, client, message: Message): 15 | return message.chat.id in temp.BANNED_CHATS 16 | 17 | disabled_group=filters.create(disabled_chat) 18 | 19 | 20 | @Client.on_message(filters.private & banned_user & filters.incoming) 21 | async def ban_reply(bot, message): 22 | ban = await db.get_ban_status(message.from_user.id) 23 | await message.reply(f'Sorry Dude, You are Banned to use be. \nBan Reason: {ban["ban_reason"]}') 24 | 25 | @Client.on_message(filters.group & disabled_group & filters.incoming) 26 | async def grp_bd(bot, message): 27 | buttons = [[ 28 | InlineKeyboardButton('Support', url=f'https://t.me/{SUPPORT_CHAT}') 29 | ]] 30 | reply_markup=InlineKeyboardMarkup(buttons) 31 | vazha = await db.get_chat(message.chat.id) 32 | k = await message.reply( 33 | 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 : {vazha['reason']}.", 34 | reply_markup=reply_markup) 35 | try: 36 | await k.pin() 37 | except: 38 | pass 39 | await bot.leave_chat(message.chat.id) -------------------------------------------------------------------------------- /plugins/lallu_tg/json.py: -------------------------------------------------------------------------------- 1 | import os 2 | from pyrogram import Client, filters 3 | from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message, CallbackQuery 4 | 5 | @Client.on_message(filters.command(["json", 'js', 'showjson'])) 6 | async def jsonify(_, message): 7 | the_real_message = None 8 | reply_to_id = None 9 | 10 | if message.reply_to_message: 11 | the_real_message = message.reply_to_message 12 | else: 13 | the_real_message = message 14 | try: 15 | pk = InlineKeyboardMarkup( 16 | [ 17 | [ 18 | InlineKeyboardButton( 19 | text="𝙲𝙻𝙾𝚂𝙴", 20 | callback_data="close_data" 21 | ) 22 | ] 23 | ] 24 | ) 25 | await message.reply_text(f"{the_real_message}", reply_markup=pk, quote=True) 26 | except Exception as e: 27 | with open("json.text", "w+", encoding="utf8") as out_file: 28 | out_file.write(str(the_real_message)) 29 | reply_markup = InlineKeyboardMarkup( 30 | [ 31 | [ 32 | InlineKeyboardButton( 33 | text="𝙲𝙻𝙾𝚂𝙴", 34 | callback_data="close_data" 35 | ) 36 | ] 37 | ] 38 | ) 39 | await message.reply_document( 40 | document="json.text", 41 | caption=str(e), 42 | disable_notification=True, 43 | quote=True, 44 | reply_markup=reply_markup 45 | ) 46 | os.remove("json.text") 47 | -------------------------------------------------------------------------------- /plugins/broadcast.py: -------------------------------------------------------------------------------- 1 | from pyrogram import Client, filters 2 | import datetime 3 | import time 4 | from database.users_chats_db import db 5 | from info import ADMINS 6 | from utils import broadcast_messages 7 | import asyncio 8 | 9 | @Client.on_message(filters.command("broadcast") & filters.user(ADMINS) & filters.reply) 10 | # https://t.me/GetTGLink/4178 11 | async def verupikkals(bot, message): 12 | users = await db.get_all_users() 13 | b_msg = message.reply_to_message 14 | sts = await message.reply_text( 15 | text='ഇപ്പൊ എല്ലാവരെയും അറിയിച്ചേക്കാം...😁...' 16 | ) 17 | start_time = time.time() 18 | total_users = await db.total_users_count() 19 | done = 0 20 | blocked = 0 21 | deleted = 0 22 | failed =0 23 | 24 | success = 0 25 | async for user in users: 26 | pti, sh = await broadcast_messages(int(user['id']), b_msg) 27 | if pti: 28 | success += 1 29 | elif pti == False: 30 | if sh == "Blocked": 31 | blocked+=1 32 | elif sh == "Deleted": 33 | deleted += 1 34 | elif sh == "Error": 35 | failed += 1 36 | done += 1 37 | await asyncio.sleep(2) 38 | if not done % 20: 39 | await sts.edit(f"Broadcast in progress:\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}") 40 | time_taken = datetime.timedelta(seconds=int(time.time()-start_time)) 41 | await sts.edit(f"Broadcast Completed:\nCompleted in {time_taken} seconds.\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}") 42 | -------------------------------------------------------------------------------- /plugins/admemes/purge.py: -------------------------------------------------------------------------------- 1 | """Purge Messages 2 | Syntax: .purge""" 3 | 4 | import asyncio 5 | from pyrogram import Client, filters 6 | from info import COMMAND_HAND_LER, TG_MAX_SELECT_LEN 7 | from plugins.helper_functions.admin_check import admin_check 8 | from plugins.helper_functions.cust_p_filters import f_onw_fliter 9 | 10 | 11 | @Client.on_message( 12 | filters.command("purge", COMMAND_HAND_LER) & 13 | f_onw_fliter 14 | ) 15 | async def purge(client, message): 16 | """ purge upto the replied message """ 17 | if message.chat.type not in (("supergroup", "channel")): 18 | # https://t.me/c/1312712379/84174 19 | return 20 | 21 | is_admin = await admin_check(message) 22 | 23 | if not is_admin: 24 | return 25 | 26 | status_message = await message.reply_text("...", quote=True) 27 | await message.delete() 28 | message_ids = [] 29 | count_del_etion_s = 0 30 | 31 | if message.reply_to_message: 32 | for a_s_message_id in range( 33 | message.reply_to_message.message_id, 34 | message.message_id 35 | ): 36 | message_ids.append(a_s_message_id) 37 | if len(message_ids) == TG_MAX_SELECT_LEN: 38 | await client.delete_messages( 39 | chat_id=message.chat.id, 40 | message_ids=message_ids, 41 | revoke=True 42 | ) 43 | count_del_etion_s += len(message_ids) 44 | message_ids = [] 45 | if len(message_ids) > 0: 46 | await client.delete_messages( 47 | chat_id=message.chat.id, 48 | message_ids=message_ids, 49 | revoke=True 50 | ) 51 | count_del_etion_s += len(message_ids) 52 | 53 | await status_message.edit_text( 54 | f"deleted {count_del_etion_s} messages" 55 | ) 56 | await asyncio.sleep(5) 57 | await status_message.delete() 58 | -------------------------------------------------------------------------------- /plugins/Don/gtranslator.py: -------------------------------------------------------------------------------- 1 | from googletrans import Translator 2 | from pyrogram import Client, filters 3 | from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery 4 | from plugins.admemes.list import list 5 | 6 | @Client.on_message(filters.command(["tr"])) 7 | async def left(client,message): 8 | if (message.reply_to_message): 9 | try: 10 | lgcd = message.text.split("/tr") 11 | lg_cd = lgcd[1].lower().replace(" ", "") 12 | tr_text = message.reply_to_message.text 13 | translator = Translator() 14 | translation = translator.translate(tr_text,dest = lg_cd) 15 | hehek = InlineKeyboardMarkup( 16 | [ 17 | [ 18 | InlineKeyboardButton( 19 | text=f"𝘔𝘰𝘳𝘦 𝘓𝘢𝘯𝘨 𝘊𝘰𝘥𝘦𝘴", url="https://cloud.google.com/translate/docs/languages" 20 | ) 21 | ], 22 | [ 23 | InlineKeyboardButton( 24 | "𝘊𝘭𝘰𝘴𝘦", callback_data="close_data" 25 | ) 26 | ], 27 | ] 28 | ) 29 | try: 30 | for i in list: 31 | if list[i]==translation.src: 32 | fromt = i 33 | if list[i] == translation.dest: 34 | to = i 35 | await message.reply_text(f"translated from {fromt.capitalize()} to {to.capitalize()}\n\n```{translation.text}```", reply_markup=hehek, quote=True) 36 | except: 37 | await message.reply_text(f"Translated from **{translation.src}** To **{translation.dest}**\n\n```{translation.text}```", reply_markup=hehek, quote=True) 38 | 39 | 40 | except : 41 | print("error") 42 | else: 43 | ms = await message.reply_text("You can Use This Command by using reply to message") 44 | await ms.delete() 45 | -------------------------------------------------------------------------------- /plugins/admemes/ping.py: -------------------------------------------------------------------------------- 1 | """Telegram Ping / Pong Speed 2 | Syntax: .ping""" 3 | 4 | import time 5 | import random 6 | from pyrogram import Client, filters 7 | from info import COMMAND_HAND_LER 8 | from plugins.helper_functions.cust_p_filters import f_onw_fliter 9 | 10 | # -- Constants -- # 11 | ALIVE = "ചത്തിട്ടില്ല മുത്തേ ഇവിടെ തന്നെ ഉണ്ട്.. നിനക്ക് ഇപ്പൊ എന്നോട് ഒരു സ്നേഹവും ഇല്ല. കൊള്ളാം.. നീ പാഴെ പോലെയേ അല്ല മാറിപോയി..😔 ഇടക്ക് എങ്കിലും ചുമ്മാ ഒന്ന് /start ചെയ്തു നോക്ക്..🙂" 12 | REPO = "𝙳𝙴𝙿𝙻𝙾𝚈 𝚃𝚄𝚃𝙾𝚁𝙸𝙰𝙻 ›› https://youtu.be/kB9TkCs8cX0" 13 | CHANNEL = "𝚈𝙾𝚄𝚃𝚄𝙱𝙴 𝙲𝙷𝙰𝙽𝙽𝙴𝙻 ›› https://youtube.com/channel/UCf_dVNrilcT0V2R--HbYpMA\n\n𝚄𝙿𝙳𝙰𝚃𝙴𝚂 𝙲𝙷𝙰𝙽𝙽𝙴𝙻 ›› https://t.me/OpusTechz\n\n𝙲𝙷𝙰𝙽𝙽𝙴𝙻 ›› https://t.me/MWUpdatez" 14 | AJAX = "𝙱𝙾𝚃 ›› https://t.me/Devil0Bot_Bot" 15 | # -- Constants End -- # 16 | 17 | 18 | @Client.on_message(filters.command("alive", COMMAND_HAND_LER) & f_onw_fliter) 19 | async def check_alive(_, message): 20 | await message.reply_text(ALIVE) 21 | 22 | 23 | @Client.on_message(filters.command("ping", COMMAND_HAND_LER) & f_onw_fliter) 24 | async def ping(_, message): 25 | start_t = time.time() 26 | rm = await message.reply_text("...") 27 | end_t = time.time() 28 | time_taken_s = (end_t - start_t) * 1000 29 | await rm.edit(f"Pong!\n{time_taken_s:.3f} ms") 30 | 31 | 32 | @Client.on_message(filters.command("repo", COMMAND_HAND_LER) & f_onw_fliter) 33 | async def repo(_, message): 34 | await message.reply_text(REPO) 35 | 36 | 37 | @Client.on_message(filters.command("group", COMMAND_HAND_LER) & f_onw_fliter) 38 | async def group(_, message): 39 | await message.reply_text(GROUP) 40 | 41 | 42 | @Client.on_message(filters.command("channel", COMMAND_HAND_LER) & f_onw_fliter) 43 | async def channel(_, message): 44 | await message.reply_text(CHANNEL) 45 | 46 | 47 | @Client.on_message(filters.command("ajax", COMMAND_HAND_LER) & f_onw_fliter) 48 | async def ajax(_, message): 49 | await message.reply_text(AJAX) 50 | 51 | 52 | -------------------------------------------------------------------------------- /plugins/admemes/paste.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import os 4 | import re 5 | import json 6 | import aiohttp 7 | import requests 8 | 9 | from pyrogram import Client, filters 10 | 11 | 12 | #Headers 13 | headers = { 14 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36", 15 | "content-type": "application/json", 16 | } 17 | 18 | #Pastebins 19 | async def p_paste(message, extension=None): 20 | siteurl = "https://pasty.lus.pm/api/v1/pastes" 21 | data = {"content": message} 22 | try: 23 | response = requests.post(url=siteurl, data=json.dumps(data), headers=headers) 24 | except Exception as e: 25 | return {"error": str(e)} 26 | if response.ok: 27 | response = response.json() 28 | purl = ( 29 | f"https://pasty.lus.pm/{response['id']}.{extension}" 30 | if extension 31 | else f"https://pasty.lus.pm/{response['id']}.txt" 32 | ) 33 | return { 34 | "url": purl, 35 | "raw": f"https://pasty.lus.pm/{response['id']}/raw", 36 | "bin": "Pasty", 37 | } 38 | return {"error": "Unable to reach pasty.lus.pm"} 39 | 40 | 41 | 42 | 43 | 44 | 45 | @Client.on_message(filters.command(["tgpaste", "pasty", "paste"])) 46 | async def pasty(client, message): 47 | pablo = await message.reply_text("`Please wait...`") 48 | tex_t = message.text 49 | message_s = tex_t 50 | if not tex_t: 51 | if not message.reply_to_message: 52 | await pablo.edit("`Only text and documents are supported.`") 53 | return 54 | if not message.reply_to_message.text: 55 | file = await message.reply_to_message.download() 56 | m_list = open(file, "r").read() 57 | message_s = m_list 58 | os.remove(file) 59 | elif message.reply_to_message.text: 60 | message_s = message.reply_to_message.text 61 | 62 | ext = "py" 63 | x = await p_paste(message_s, ext) 64 | p_link = x["url"] 65 | p_raw = x["raw"] 66 | 67 | pasted = f"**Successfully Paste to Pasty**\n\n**Link:** • [Click here]({p_link})\n\n**Raw Link:** • [Click here]({p_raw})" 68 | await pablo.edit(pasted, disable_web_page_preview=True) 69 | -------------------------------------------------------------------------------- /plugins/admemes/list.py: -------------------------------------------------------------------------------- 1 | list = { 2 | "afrikaans":"af", 3 | "albanian":"sq", 4 | "amharic":"am", 5 | "arabic":"ar", 6 | "armenian":"hy", 7 | "azerbaijani":"az", 8 | "basque":"eu", 9 | "belarusian":"be", 10 | "bengali":"bn", 11 | "bosnian":"bs", 12 | "bulgarian":"bg", 13 | "catalan":"ca", 14 | "cebuano":"ceb", 15 | "chinese": "zh", 16 | "corsican":"co", 17 | "croatian":"hr", 18 | "czech":"cs", 19 | "danish":"da", 20 | "dutch":"nl", 21 | "english":"en", 22 | "esperanto":"eo", 23 | "estonian":"et", 24 | "finnish":"fi", 25 | "french":"fr", 26 | "frisian":"fy", 27 | "galician":"gl", 28 | "georgian":"ka", 29 | "german":"de", 30 | "greek":"el", 31 | "gujarati":"gu", 32 | "haitian creole":"ht", 33 | "hausa":"ha", 34 | "hawaiian":"haw", 35 | "hebrew":"he", 36 | "hindi":"hi", 37 | "hmong":"hmn", 38 | "hungarian":"hu", 39 | "icelandic":"is", 40 | "igbo":"ig", 41 | "indonesian":"id", 42 | "irish":"ga", 43 | "italian":"it", 44 | "japanese":"ja", 45 | "javanese":"jv", 46 | "kannada":"kn", 47 | "kazakh":"kk", 48 | "khmer":"km", 49 | "kinyarwanda":"rw", 50 | "korean":"ko", 51 | "kurdish":"ku", 52 | "kyrgyz":"ky", 53 | "lao":"lo", 54 | "latin":"la", 55 | "latvian":"lv", 56 | "lithuanian":"lt", 57 | "luxembourgish":"lb", 58 | "macedonian":"mk", 59 | "malagasy":"mg", 60 | "malay":"ms", 61 | "malayalam":"ml", 62 | "maltese":"mt", 63 | "maori":"mi", 64 | "marathi":"mr", 65 | "mongolian":"mn", 66 | "myanmar":"my", 67 | "nepali":"ne", 68 | "norwegian":"no", 69 | "nyanja":"ny", 70 | "odia":"or", 71 | "pashto":"ps", 72 | "persian":"fa", 73 | "polish":"pl", 74 | "portuguese":"pt", 75 | "punjabi":"pa", 76 | "romanian":"ro", 77 | "russian":"ru", 78 | "samoan":"sm", 79 | "scots gaelic":"gd", 80 | "serbian":"sr", 81 | "sesotho":"st", 82 | "shona":"sn", 83 | "sindhi":"sd", 84 | "sinhala":"si", 85 | "slovak":"sk", 86 | "slovenian":"sl", 87 | "somali":"so", 88 | "spanish":"es", 89 | "sundanese":"su", 90 | "swahili":"sw", 91 | "swedish":"sv", 92 | "tagalog":"tl", 93 | "tajik":"tg", 94 | "tamil":"ta", 95 | "tatar":"tt", 96 | "telugu":"te", 97 | "thai":"th", 98 | "turkish":"tr", 99 | "turkmen":"tk", 100 | "ukrainian":"uk", 101 | "urdu":"ur", 102 | "uyghur":"ug", 103 | "uzbek":"uz", 104 | "vietnamese":"vi", 105 | "welsh":"cy", 106 | "xhosa":"xh", 107 | "yiddish":"yi", 108 | "yoruba":"yo", 109 | "zulu":"zu"} 110 | -------------------------------------------------------------------------------- /plugins/lallu_tg/runs.py: -------------------------------------------------------------------------------- 1 | import random 2 | from pyrogram import Client, filters 3 | from info import COMMAND_HAND_LER 4 | from plugins.helper_functions.cust_p_filters import f_onw_fliter 5 | 6 | 7 | RUN_STRINGS = ( 8 | "ഓ.. ധിക്കാരം... പഴേപോലെ തന്നെ....ഒരു മാറ്റോമില്ല.....ചുമ്മാതല്ല ഗതി പിടിക്കാത്തത്....!!!", 9 | "അള്ളാ... പിള്ളേരുടെ ഓരോ... പെഷനെ...", 10 | "എനിക്ക് എഴുതാൻ അല്ലെ അറിയൂ സാറേ.... വായിക്കാൻ അറിയില്ലല്ലോ....", 11 | "ഇന്ന് ഇനി നീ മിണ്ടരുത്... ഇന്നത്തെ കോട്ട കഴിഞ്ഞ്.....", 12 | "ചാരമാണെന്ന് കരുതി ചെകയാൻ നിൽക്കണ്ട കനൽ കെട്ടിട്ടില്ലെങ്കിൽ പൊള്ളും.", 13 | "ഒറ്റ ജീവിതമേ ഉള്ളു മനസിലാക്കിക്കോ, സ്വർഗ്ഗമില്ല നരകമില്ല, 'ഒറ്റ ജീവിതം', അത് എവിടെ എങ്ങനെ വേണമെന്ന് അവനവൻ തീരുമാനിക്കും", 14 | "വാട്ട് എ ബോംബെസ്റ്റിക് എക്സ്പ്ലോഷൻ! സച് എ ടെറിഫിക് ഡിസ്ക്ലോസ്!!", 15 | "ഗോ എവേ സ്ടുപ്പിഡ് ഇൻ ദി ഹൗസ് ഓഫ് മൈ വൈഫ്‌ ആൻഡ് ഡോട്ടർ യൂവിൽ നോട്ട് സി എനി മിനിറ്റ് ഓഫ് ദി ടുഡേ... ഇറങ്ങി പോടാ..", 16 | "ഐ കാൻ ഡു ദാറ്റ്‌ ഡു കാൻ ഐ ദാറ്റ്‌", 17 | "ക്രീം ബിസ്കറ്റിൽ ക്രീം ഉണ്ടന്ന് കരുതി ടൈഗർ ബിസ്കറ്റിൽ ടൈഗർ ഉണ്ടാകണമെന്നില്ല. പണി പാളും മോനെ...", 18 | "പട പേടിച്ചു പന്തളത്തു ചെന്നപ്പോ പന്തോം കുത്തി പട പന്തളത്തോട്ടെന്ന് പറഞ്ഞ പോലെ ആയല്ലോ.", 19 | "എന്റ കർത്താവെ.... എന്നെ നീ നല്ലവനാകാൻ സമ്മതിക്കൂല്ല അല്ലെ.", 20 | "കാർ എൻജിൻ ഔട്ട് കംപ്ലീറ്റ്‌ലി......", 21 | "തള്ളെ കലിപ്പ് തീരണില്ലല്ലോ!!", 22 | "പാതിരാത്രിക്ക് നിന്റെ അച്ഛൻ ഉണ്ടാക്കി വെച്ചിരിക്കുന്നോ പൊറോട്ടയും ചിക്കനും....", 23 | "ഓ പിന്നെ നീ ഒക്കെ പ്രേമിക്കുമ്പോൾ അത് പ്രണയം.... നമ്മൾ ഒക്കെ പ്രേമിക്കുമ്പോൾ അത് കമ്പി....", 24 | "ദൈവമേ എന്നെ മാത്രം രക്ഷിക്കണേ....", 25 | "അവളെ ഓർത്ത് കുടിച്ച കള്ളും നനഞ്ഞ മഴയും വേസ്റ്റ്....", 26 | "ഇത്രേം കാലം എവിടെ ആയിരുന്നു....!", 27 | "ഇൻഗ്ലീഷ് തീരെ പിടി ഇല്ല അല്ലെ....", 28 | "ആൾ ദി ഡ്രീംസ്‌ ലൈക്‌ ട്വിങ്കിൽ സ്റ്റാർസ്...", 29 | "എന്റെ പ്രാന്തൻ മുത്തപ്പാ അവനെ ഒരു വഴിയാക്കി തരണേ", 30 | "പെങ്ങളെ കെട്ടിയ സ്ത്രീധന തുക തരുമോ അളിയാ", 31 | "നീ വല്ലാതെ ക്ഷീണിച്ചു പൊയി", 32 | "കണ്ണിലെണ്ണയൊഴിച്ചു കാത്തിരിക്കുവായിരുന്നളിയാ.", 33 | "ചെല്ലാക്കണ്ടു എന്നിച്ചു പോടാ തടി.യാ .\ 34 | ഷട്ട് ഉഒ യുവർ മൗത് ബ്ലഡി gramavasis.", 35 | "പോയി ചാവട .\ 36 | നിന്നെ കൊണ്ട് ചാവാൻ patto.", 37 | "നിന്നെ കൊണ്ട് നാട്ടുകാർക്കും ഗുണോല്ല്യ വിട്ടുകാർക്കും ഗുണോല്ല്യ എന്തിനാ ഇങ്ങനെ നാണം കേട്ടു ജീവിക്കുന്നട പാട് വാഴെ ചെങ്കതളി വാഴ .", 38 | ) 39 | 40 | 41 | @Client.on_message( 42 | filters.command("runs", COMMAND_HAND_LER) & 43 | f_onw_fliter 44 | ) 45 | async def runs(_, message): 46 | """ /runs strings """ 47 | effective_string = random.choice(RUN_STRINGS) 48 | if message.reply_to_message: 49 | await message.reply_to_message.reply_text(effective_string) 50 | else: 51 | await message.reply_text(effective_string) 52 | -------------------------------------------------------------------------------- /plugins/Don/audiobook.py: -------------------------------------------------------------------------------- 1 | import os 2 | import pyrogram 3 | import PyPDF2 4 | import time 5 | from pyrogram import Client, filters 6 | from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton 7 | from pyrogram.types import User, Message, Document 8 | from gtts import gTTS 9 | from info import DOWNLOAD_LOCATION 10 | 11 | Thanks = """ Thats The End Of Your Audio Book, And Thanks for Using this Service""" 12 | 13 | @Client.on_message(filters.command(["audiobook"])) # PdfToText 14 | async def pdf_to_text(bot, message): 15 | try: 16 | if message.reply_to_message: 17 | pdf_path = DOWNLOAD_LOCATION + f"{message.chat.id}.pdf" #pdfFileObject 18 | txt = await message.reply("Downloading.....") 19 | await message.reply_to_message.download(pdf_path) 20 | await txt.edit("Downloaded File") 21 | pdf = open(pdf_path,'rb') 22 | pdf_reader = PyPDF2.PdfFileReader(pdf) #pdfReaderObject 23 | await txt.edit("Getting Number of Pages....") 24 | num_of_pages = pdf_reader.getNumPages() # Number of Pages 25 | await txt.edit(f"Found {num_of_pages} Page") 26 | page_no = pdf_reader.getPage(0) # pageObject 27 | await txt.edit("Finding Text from Pdf File... ") 28 | page_content = """ """ # EmptyString 29 | chat_id = message.chat.id 30 | with open(f'{message.chat.id}.txt', 'a+') as text_path: 31 | for page in range (0,num_of_pages): 32 | page_no = pdf_reader.getPage(page) # Iteration of page number 33 | page_content += page_no.extractText() 34 | await txt.edit(f"Creating Your Audio Book...\n Please Don't Do Anything") 35 | output_text = page_content + Thanks 36 | # Change Voice by editing the Language 37 | language = 'en-in' # 'en': ['en-us', 'en-ca', 'en-uk', 'en-gb', 'en-au', 'en-gh', 'en-in', 38 | # 'en-ie', 'en-nz', 'en-ng', 'en-ph', 'en-za', 'en-tz'], 39 | tts_file = gTTS(text=output_text, lang=language, slow=False) 40 | tts_file.save(f"{message.chat.id}.mp3") 41 | with open(f"{message.chat.id}.mp3", "rb") as speech: 42 | await bot.send_voice(chat_id, speech) 43 | await txt.edit("Thanks For Using Me") 44 | os.remove(pdf_path) 45 | 46 | 47 | else : 48 | await message.reply("Please Reply to PDF file") 49 | except Exception as error : 50 | print(error) 51 | await txt.delete() 52 | os.remove(pdf_path) 53 | -------------------------------------------------------------------------------- /plugins/photo.py: -------------------------------------------------------------------------------- 1 | from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message 2 | from pyrogram import Client, filters 3 | 4 | 5 | @Client.on_message(filters.photo & filters.private) 6 | async def photo(client: Client, message: Message): 7 | try: 8 | await client.send_message( 9 | chat_id=message.chat.id, 10 | text="Select your required mode from below!ㅤㅤ", 11 | reply_markup=InlineKeyboardMarkup( 12 | [ 13 | [ 14 | InlineKeyboardButton(text="𝖡𝗋𝗂𝗀𝗍𝗁", callback_data="bright"), 15 | InlineKeyboardButton(text="𝖬𝗂𝗑𝖾𝖽", callback_data="mix"), 16 | InlineKeyboardButton(text="𝖡 & 𝖶", callback_data="b|w"), 17 | ], 18 | [ 19 | InlineKeyboardButton(text="𝖢𝗂𝗋𝖼𝗅𝖾", callback_data="circle"), 20 | InlineKeyboardButton(text="𝖡𝗅𝗎𝗋", callback_data="blur"), 21 | InlineKeyboardButton(text="𝖡𝗈𝗋𝖽𝖾𝗋", callback_data="border"), 22 | ], 23 | [ 24 | InlineKeyboardButton(text="𝖲𝗍𝗂𝖼𝗄𝖾𝗋", callback_data="stick"), 25 | InlineKeyboardButton(text="𝖱𝗈𝗍𝖺𝗍𝖾", callback_data="rotate"), 26 | InlineKeyboardButton(text="𝖢𝗈𝗇𝗍𝗋𝖺𝗌𝗍", callback_data="contrast"), 27 | ], 28 | [ 29 | InlineKeyboardButton(text="𝖲𝖾𝗉𝗂𝖺", callback_data="sepia"), 30 | InlineKeyboardButton(text="𝖯𝖾𝗇𝖼𝗂𝗅", callback_data="pencil"), 31 | InlineKeyboardButton(text="𝖢𝖺𝗋𝗍𝗈𝗈𝗇", callback_data="cartoon"), 32 | ], 33 | [ 34 | InlineKeyboardButton(text="𝖨𝗇𝗏𝖾𝗋𝗍", callback_data="inverted"), 35 | InlineKeyboardButton(text="𝖦𝗅𝗂𝗍𝖼𝗁", callback_data="glitch"), 36 | InlineKeyboardButton( 37 | text="𝖱𝖾𝗆𝗈𝗏𝖾 𝖡𝖦", callback_data="removebg" 38 | ), 39 | ], 40 | [ 41 | InlineKeyboardButton(text="𝖢𝗅𝗈𝗌𝖾", callback_data="close_data"), 42 | ], 43 | ] 44 | ), 45 | reply_to_message_id=message.message_id, 46 | ) 47 | except Exception as e: 48 | print("photomarkup error - " + str(e)) 49 | if "USER_IS_BLOCKED" in str(e): 50 | return 51 | else: 52 | try: 53 | await message.reply_text("Something went wrong!", quote=True) 54 | except Exception: 55 | return 56 | -------------------------------------------------------------------------------- /plugins/Restrictions/Ban.py: -------------------------------------------------------------------------------- 1 | from pyrogram import Client, filters 2 | from plugins.helper_functions.admin_check import admin_check 3 | from plugins.helper_functions.extract_user import extract_user 4 | from plugins.helper_functions.string_handling import extract_time 5 | 6 | 7 | @Client.on_message(filters.command("ban")) 8 | async def ban_user(_, message): 9 | is_admin = await admin_check(message) 10 | if not is_admin: 11 | return 12 | 13 | user_id, user_first_name = extract_user(message) 14 | 15 | try: 16 | await message.chat.kick_member( 17 | user_id=user_id 18 | ) 19 | except Exception as error: 20 | await message.reply_text( 21 | str(error) 22 | ) 23 | else: 24 | if str(user_id).lower().startswith("@"): 25 | await message.reply_text( 26 | "Someone else is dusting off..! " 27 | f"{user_first_name}" 28 | " Is forbidden." 29 | ) 30 | else: 31 | await message.reply_text( 32 | "Someone else is dusting off..! " 33 | f"" 34 | f"{user_first_name}" 35 | "" 36 | " Is forbidden." 37 | ) 38 | 39 | 40 | @Client.on_message(filters.command("tban")) 41 | async def temp_ban_user(_, message): 42 | is_admin = await admin_check(message) 43 | if not is_admin: 44 | return 45 | 46 | if not len(message.command) > 1: 47 | return 48 | 49 | user_id, user_first_name = extract_user(message) 50 | 51 | until_date_val = extract_time(message.command[1]) 52 | if until_date_val is None: 53 | await message.reply_text( 54 | ( 55 | "Invalid time type specified. " 56 | "Expected m, h, or d, Got it: {}" 57 | ).format( 58 | message.command[1][-1] 59 | ) 60 | ) 61 | return 62 | 63 | try: 64 | await message.chat.kick_member( 65 | user_id=user_id, 66 | until_date=until_date_val 67 | ) 68 | except Exception as error: 69 | await message.reply_text( 70 | str(error) 71 | ) 72 | else: 73 | if str(user_id).lower().startswith("@"): 74 | await message.reply_text( 75 | "Someone else is dusting off..! " 76 | f"{user_first_name}" 77 | f" banned for {message.command[1]}!" 78 | ) 79 | else: 80 | await message.reply_text( 81 | "Someone else is dusting off..! " 82 | f"" 83 | "Lavane" 84 | "" 85 | f" banned for {message.command[1]}!" 86 | ) 87 | -------------------------------------------------------------------------------- /helper_func.py: -------------------------------------------------------------------------------- 1 | #(©)Codexbotz 2 | 3 | import base64 4 | import re 5 | import asyncio 6 | from pyrogram import filters 7 | from config import FORCE_SUB_CHANNEL, ADMINS 8 | from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant 9 | from pyrogram.errors import FloodWait 10 | 11 | async def is_subscribed(filter, client, update): 12 | if not FORCE_SUB_CHANNEL: 13 | return True 14 | user_id = update.from_user.id 15 | if user_id in ADMINS: 16 | return True 17 | try: 18 | member = await client.get_chat_member(chat_id = FORCE_SUB_CHANNEL, user_id = user_id) 19 | except UserNotParticipant: 20 | return False 21 | 22 | if not member.status in ["creator", "administrator", "member"]: 23 | return False 24 | else: 25 | return True 26 | 27 | async def encode(string): 28 | string_bytes = string.encode("ascii") 29 | base64_bytes = base64.b64encode(string_bytes) 30 | base64_string = base64_bytes.decode("ascii") 31 | return base64_string 32 | 33 | async def decode(base64_string): 34 | base64_bytes = base64_string.encode("ascii") 35 | string_bytes = base64.b64decode(base64_bytes) 36 | string = string_bytes.decode("ascii") 37 | return string 38 | 39 | async def get_messages(client, message_ids): 40 | messages = [] 41 | total_messages = 0 42 | while total_messages != len(message_ids): 43 | temb_ids = message_ids[total_messages:total_messages+200] 44 | try: 45 | msgs = await client.get_messages( 46 | chat_id=client.db_channel.id, 47 | message_ids=temb_ids 48 | ) 49 | except FloodWait as e: 50 | await asyncio.sleep(e.x) 51 | msgs = await client.get_messages( 52 | chat_id=client.db_channel.id, 53 | message_ids=temb_ids 54 | ) 55 | except: 56 | pass 57 | total_messages += len(temb_ids) 58 | messages.extend(msgs) 59 | return messages 60 | 61 | async def get_message_id(client, message): 62 | if message.forward_from_chat: 63 | if message.forward_from_chat.id == client.db_channel.id: 64 | return message.forward_from_message_id 65 | else: 66 | return 0 67 | elif message.forward_sender_name: 68 | return 0 69 | elif message.text: 70 | pattern = "https://t.me/(?:c/)?(.*)/(\d+)" 71 | matches = re.match(pattern,message.text) 72 | if not matches: 73 | return 0 74 | channel_id = matches.group(1) 75 | msg_id = int(matches.group(2)) 76 | if channel_id.isdigit(): 77 | if f"-100{channel_id}" == str(client.db_channel.id): 78 | return msg_id 79 | else: 80 | if channel_id == client.db_channel.username: 81 | return msg_id 82 | else: 83 | return 0 84 | 85 | subscribed = filters.create(is_subscribed) 86 | -------------------------------------------------------------------------------- /plugins/Restrictions/Restrict.py: -------------------------------------------------------------------------------- 1 | from pyrogram import ( 2 | Client, 3 | filters 4 | ) 5 | from pyrogram.types import ( 6 | ChatPermissions 7 | ) 8 | from plugins.helper_functions.admin_check import admin_check 9 | from plugins.helper_functions.extract_user import extract_user 10 | from plugins.helper_functions.string_handling import extract_time 11 | 12 | 13 | @Client.on_message(filters.command("mute")) 14 | async def mute_user(_, message): 15 | is_admin = await admin_check(message) 16 | if not is_admin: 17 | return 18 | 19 | user_id, user_first_name = extract_user(message) 20 | 21 | try: 22 | await message.chat.restrict_member( 23 | user_id=user_id, 24 | permissions=ChatPermissions( 25 | ) 26 | ) 27 | except Exception as error: 28 | await message.reply_text( 29 | str(error) 30 | ) 31 | else: 32 | if str(user_id).lower().startswith("@"): 33 | await message.reply_text( 34 | "👍🏻 " 35 | f"{user_first_name}" 36 | " Lavender's mouth is shut! 🤐" 37 | ) 38 | else: 39 | await message.reply_text( 40 | "👍🏻 " 41 | f"" 42 | "Of lavender" 43 | "" 44 | " The mouth is closed! 🤐" 45 | ) 46 | 47 | 48 | @Client.on_message(filters.command("tmute")) 49 | async def temp_mute_user(_, message): 50 | is_admin = await admin_check(message) 51 | if not is_admin: 52 | return 53 | 54 | if not len(message.command) > 1: 55 | return 56 | 57 | user_id, user_first_name = extract_user(message) 58 | 59 | until_date_val = extract_time(message.command[1]) 60 | if until_date_val is None: 61 | await message.reply_text( 62 | ( 63 | "Invalid time type specified. " 64 | "Expected m, h, or d, Got it: {}" 65 | ).format( 66 | message.command[1][-1] 67 | ) 68 | ) 69 | return 70 | 71 | try: 72 | await message.chat.restrict_member( 73 | user_id=user_id, 74 | permissions=ChatPermissions( 75 | ), 76 | until_date=until_date_val 77 | ) 78 | except Exception as error: 79 | await message.reply_text( 80 | str(error) 81 | ) 82 | else: 83 | if str(user_id).lower().startswith("@"): 84 | await message.reply_text( 85 | "Be quiet for a while! 😠" 86 | f"{user_first_name}" 87 | f" muted for {message.command[1]}!" 88 | ) 89 | else: 90 | await message.reply_text( 91 | "Be quiet for a while! 😠" 92 | f"" 93 | "Of lavender" 94 | "" 95 | " Mouth " 96 | f" muted for {message.command[1]}!" 97 | ) 98 | -------------------------------------------------------------------------------- /plugins/lallu_tg/whois.py: -------------------------------------------------------------------------------- 1 | # codes added by @lallu_tg 2 | # use with proper credits 3 | 4 | """Get info about the replied user 5 | Syntax: .whois""" 6 | 7 | import os 8 | import time 9 | from datetime import datetime 10 | from pyrogram import Client, filters 11 | from pyrogram.errors import UserNotParticipant 12 | from info import COMMAND_HAND_LER 13 | from plugins.helper_functions.extract_user import extract_user 14 | from plugins.helper_functions.cust_p_filters import f_onw_fliter 15 | from plugins.helper_functions.last_online_hlpr import last_online 16 | 17 | 18 | @Client.on_message( 19 | filters.command(["whois", "info"], COMMAND_HAND_LER) & 20 | f_onw_fliter 21 | ) 22 | async def who_is(client, message): 23 | """ extract user information """ 24 | status_message = await message.reply_text( 25 | "Wait Bro Let Me Check 🙂" 26 | ) 27 | from_user = None 28 | from_user_id, _ = extract_user(message) 29 | try: 30 | from_user = await client.get_users(from_user_id) 31 | except Exception as error: 32 | await status_message.edit(str(error)) 33 | return 34 | if from_user is None: 35 | await status_message.edit("no valid user_id / message specified") 36 | return 37 | 38 | first_name = from_user.first_name or "" 39 | last_name = from_user.last_name or "" 40 | username = from_user.username or "" 41 | 42 | message_out_str = ( 43 | "᚛› 𝙽𝙰𝙼𝙴 : " 44 | f"{first_name}\n" 45 | f"᚛› 𝚂𝚄𝙵𝙵𝙸𝚇 : {last_name}\n" 46 | f"᚛› 𝚄𝚂𝙴𝚁𝙽𝙰𝙼𝙴 : @{username}\n" 47 | f"᚛› 𝚄𝚂𝙴𝚁 𝙸𝙳 : {from_user.id}\n" 48 | f"᚛› 𝚄𝚂𝙴𝚁 𝙻𝙸𝙽𝙺 : {from_user.mention}\n" if from_user.username else "" 49 | f"᚛› 𝙸𝚂 𝙰𝙲𝙲𝙾𝚄𝙽𝚃 𝙳𝙴𝙻𝙴𝚃𝙴𝙳 : True\n" if from_user.is_deleted else "" 50 | f"᚛› 𝙸𝚂 𝚅𝙴𝚁𝙸𝙵𝙸𝙴𝙳 : True" if from_user.is_verified else "" 51 | f"᚛› 𝙸𝚂 𝚂𝙲𝙰𝙼 : True" if from_user.is_scam else "" 52 | # f"Is Fake: True" if from_user.is_fake else "" 53 | f"᚛› 𝙻𝙰𝚂𝚃 𝚂𝙴𝙴𝙽 : {last_online(from_user)}\n\n" 54 | ) 55 | 56 | if message.chat.type in ["supergroup", "channel"]: 57 | try: 58 | chat_member_p = await message.chat.get_member(from_user.id) 59 | joined_date = datetime.fromtimestamp( 60 | chat_member_p.joined_date or time.time() 61 | ).strftime("%Y.%m.%d %H:%M:%S") 62 | message_out_str += ( 63 | "Joined on: " 64 | f"{joined_date}" 65 | "\n" 66 | ) 67 | except UserNotParticipant: 68 | pass 69 | chat_photo = from_user.photo 70 | if chat_photo: 71 | local_user_photo = await client.download_media( 72 | message=chat_photo.big_file_id 73 | ) 74 | await message.reply_photo( 75 | photo=local_user_photo, 76 | quote=True, 77 | caption=message_out_str, 78 | disable_notification=True 79 | ) 80 | os.remove(local_user_photo) 81 | else: 82 | await message.reply_text( 83 | text=message_out_str, 84 | quote=True, 85 | disable_notification=True 86 | ) 87 | await status_message.delete() 88 | -------------------------------------------------------------------------------- /database/filters_mdb.py: -------------------------------------------------------------------------------- 1 | import pymongo 2 | from info import DATABASE_URI, DATABASE_NAME 3 | import logging 4 | logger = logging.getLogger(__name__) 5 | logger.setLevel(logging.ERROR) 6 | 7 | myclient = pymongo.MongoClient(DATABASE_URI) 8 | mydb = myclient[DATABASE_NAME] 9 | 10 | 11 | 12 | async def add_filter(grp_id, text, reply_text, btn, file, alert): 13 | mycol = mydb[str(grp_id)] 14 | # mycol.create_index([('text', 'text')]) 15 | 16 | data = { 17 | 'text':str(text), 18 | 'reply':str(reply_text), 19 | 'btn':str(btn), 20 | 'file':str(file), 21 | 'alert':str(alert) 22 | } 23 | 24 | try: 25 | mycol.update_one({'text': str(text)}, {"$set": data}, upsert=True) 26 | except: 27 | logger.exception('Some error occured!', exc_info=True) 28 | 29 | 30 | async def find_filter(group_id, name): 31 | mycol = mydb[str(group_id)] 32 | 33 | query = mycol.find( {"text":name}) 34 | # query = mycol.find( { "$text": {"$search": name}}) 35 | try: 36 | for file in query: 37 | reply_text = file['reply'] 38 | btn = file['btn'] 39 | fileid = file['file'] 40 | try: 41 | alert = file['alert'] 42 | except: 43 | alert = None 44 | return reply_text, btn, alert, fileid 45 | except: 46 | return None, None, None, None 47 | 48 | 49 | async def get_filters(group_id): 50 | mycol = mydb[str(group_id)] 51 | 52 | texts = [] 53 | query = mycol.find() 54 | try: 55 | for file in query: 56 | text = file['text'] 57 | texts.append(text) 58 | except: 59 | pass 60 | return texts 61 | 62 | 63 | async def delete_filter(message, text, group_id): 64 | mycol = mydb[str(group_id)] 65 | 66 | myquery = {'text':text } 67 | query = mycol.count_documents(myquery) 68 | if query == 1: 69 | mycol.delete_one(myquery) 70 | await message.reply_text( 71 | f"'`{text}`' deleted. I'll not respond to that filter anymore.", 72 | quote=True, 73 | parse_mode="md" 74 | ) 75 | else: 76 | await message.reply_text("Couldn't find that filter!", quote=True) 77 | 78 | 79 | async def del_all(message, group_id, title): 80 | if str(group_id) not in mydb.list_collection_names(): 81 | await message.edit_text(f"Nothing to remove in {title}!") 82 | return 83 | 84 | mycol = mydb[str(group_id)] 85 | try: 86 | mycol.drop() 87 | await message.edit_text(f"All filters from {title} has been removed") 88 | except: 89 | await message.edit_text("Couldn't remove all filters from group!") 90 | return 91 | 92 | 93 | async def count_filters(group_id): 94 | mycol = mydb[str(group_id)] 95 | 96 | count = mycol.count() 97 | if count == 0: 98 | return False 99 | else: 100 | return count 101 | 102 | 103 | async def filter_stats(): 104 | collections = mydb.list_collection_names() 105 | 106 | if "CONNECTION" in collections: 107 | collections.remove("CONNECTION") 108 | 109 | totalcount = 0 110 | for collection in collections: 111 | mycol = mydb[collection] 112 | count = mycol.count() 113 | totalcount += count 114 | 115 | totalcollections = len(collections) 116 | 117 | return totalcollections, totalcount 118 | -------------------------------------------------------------------------------- /plugins/helper_functions/string_handling.py: -------------------------------------------------------------------------------- 1 | import re 2 | import time 3 | from typing import List 4 | from pyrogram.types import Message, InlineKeyboardButton 5 | from info import COMMAND_HAND_LER 6 | 7 | 8 | # NOTE: the url \ escape may cause double escapes 9 | # match * (bold) (don't escape if in url) 10 | # match _ (italics) (don't escape if in url) 11 | # match ` (code) 12 | # match []() (markdown link) 13 | # else, escape *, _, `, and [ 14 | MATCH_MD = re.compile(r'\*(.*?)\*|' 15 | r'_(.*?)_|' 16 | r'`(.*?)`|' 17 | r'(?[*_`\[])') 19 | 20 | # regex to find []() links -> hyperlinks/buttons 21 | LINK_REGEX = re.compile(r'(? (str, List): 28 | # offset = len(args[2]) - len(raw_text) 29 | # set correct offset relative to command + notename 30 | markdown_note = None 31 | if msg.media: 32 | if msg.caption: 33 | markdown_note = msg.caption.markdown 34 | else: 35 | markdown_note = msg.text.markdown 36 | note_data = "" 37 | buttons = [] 38 | if markdown_note is None: 39 | return note_data, buttons 40 | # 41 | if markdown_note.startswith(COMMAND_HAND_LER): 42 | args = markdown_note.split(None, 2) 43 | # use python's maxsplit to separate cmd and args 44 | markdown_note = args[2] 45 | prev = 0 46 | for match in BTN_URL_REGEX.finditer(markdown_note): 47 | # Check if btnurl is escaped 48 | n_escapes = 0 49 | to_check = match.start(1) - 1 50 | while to_check > 0 and markdown_note[to_check] == "\\": 51 | n_escapes += 1 52 | to_check -= 1 53 | 54 | # if even, not escaped -> create button 55 | if n_escapes % 2 == 0: 56 | # create a thruple with button label, url, and newline status 57 | if bool(match.group(4)) and buttons: 58 | buttons[-1].append(InlineKeyboardButton( 59 | text=match.group(2), 60 | url=match.group(3) 61 | )) 62 | else: 63 | buttons.append([InlineKeyboardButton( 64 | text=match.group(2), 65 | url=match.group(3) 66 | )]) 67 | note_data += markdown_note[prev:match.start(1)] 68 | prev = match.end(1) 69 | # if odd, escaped -> move along 70 | else: 71 | note_data += markdown_note[prev:to_check] 72 | prev = match.start(1) - 1 73 | else: 74 | note_data += markdown_note[prev:] 75 | 76 | return note_data, buttons 77 | 78 | 79 | def extract_time(time_val): 80 | if any(time_val.endswith(unit) for unit in ('s', 'm', 'h', 'd')): 81 | unit = time_val[-1] 82 | time_num = time_val[:-1] # type: str 83 | if not time_num.isdigit(): 84 | return None 85 | 86 | if unit == 's': 87 | bantime = int(time.time() + int(time_num)) 88 | elif unit == 'm': 89 | bantime = int(time.time() + int(time_num) * 60) 90 | elif unit == 'h': 91 | bantime = int(time.time() + int(time_num) * 60 * 60) 92 | elif unit == 'd': 93 | bantime = int(time.time() + int(time_num) * 24 * 60 * 60) 94 | else: 95 | # how even...? 96 | return None 97 | return bantime 98 | else: 99 | return None 100 | 101 | 102 | def format_welcome_caption(html_string, chat_member): 103 | return html_string.format( 104 | dc_id=chat_member.dc_id, 105 | first_name=chat_member.first_name, 106 | id=chat_member.id, 107 | last_name=chat_member.last_name, 108 | mention=chat_member.mention, 109 | username=chat_member.username 110 | ) 111 | -------------------------------------------------------------------------------- /database/connections_mdb.py: -------------------------------------------------------------------------------- 1 | import pymongo 2 | 3 | from info import DATABASE_URI, DATABASE_NAME 4 | 5 | import logging 6 | logger = logging.getLogger(__name__) 7 | logger.setLevel(logging.ERROR) 8 | 9 | myclient = pymongo.MongoClient(DATABASE_URI) 10 | mydb = myclient[DATABASE_NAME] 11 | mycol = mydb['CONNECTION'] 12 | 13 | 14 | async def add_connection(group_id, user_id): 15 | query = mycol.find_one( 16 | { "_id": user_id }, 17 | { "_id": 0, "active_group": 0 } 18 | ) 19 | if query is not None: 20 | group_ids = [x["group_id"] for x in query["group_details"]] 21 | if group_id in group_ids: 22 | return False 23 | 24 | group_details = { 25 | "group_id" : group_id 26 | } 27 | 28 | data = { 29 | '_id': user_id, 30 | 'group_details' : [group_details], 31 | 'active_group' : group_id, 32 | } 33 | 34 | if mycol.count_documents( {"_id": user_id} ) == 0: 35 | try: 36 | mycol.insert_one(data) 37 | return True 38 | except: 39 | logger.exception('Some error occured!', exc_info=True) 40 | 41 | else: 42 | try: 43 | mycol.update_one( 44 | {'_id': user_id}, 45 | { 46 | "$push": {"group_details": group_details}, 47 | "$set": {"active_group" : group_id} 48 | } 49 | ) 50 | return True 51 | except: 52 | logger.exception('Some error occured!', exc_info=True) 53 | 54 | 55 | async def active_connection(user_id): 56 | 57 | query = mycol.find_one( 58 | { "_id": user_id }, 59 | { "_id": 0, "group_details": 0 } 60 | ) 61 | if not query: 62 | return None 63 | 64 | group_id = query['active_group'] 65 | if group_id != None: 66 | return int(group_id) 67 | else: 68 | return None 69 | 70 | 71 | async def all_connections(user_id): 72 | query = mycol.find_one( 73 | { "_id": user_id }, 74 | { "_id": 0, "active_group": 0 } 75 | ) 76 | if query is not None: 77 | return [x["group_id"] for x in query["group_details"]] 78 | else: 79 | return None 80 | 81 | 82 | async def if_active(user_id, group_id): 83 | query = mycol.find_one( 84 | { "_id": user_id }, 85 | { "_id": 0, "group_details": 0 } 86 | ) 87 | return query is not None and query['active_group'] == group_id 88 | 89 | 90 | async def make_active(user_id, group_id): 91 | update = mycol.update_one( 92 | {'_id': user_id}, 93 | {"$set": {"active_group" : group_id}} 94 | ) 95 | return update.modified_count != 0 96 | 97 | 98 | async def make_inactive(user_id): 99 | update = mycol.update_one( 100 | {'_id': user_id}, 101 | {"$set": {"active_group" : None}} 102 | ) 103 | return update.modified_count != 0 104 | 105 | 106 | async def delete_connection(user_id, group_id): 107 | 108 | try: 109 | update = mycol.update_one( 110 | {"_id": user_id}, 111 | {"$pull" : { "group_details" : {"group_id":group_id} } } 112 | ) 113 | if update.modified_count == 0: 114 | return False 115 | query = mycol.find_one( 116 | { "_id": user_id }, 117 | { "_id": 0 } 118 | ) 119 | if len(query["group_details"]) >= 1: 120 | if query['active_group'] == group_id: 121 | prvs_group_id = query["group_details"][len(query["group_details"]) - 1]["group_id"] 122 | 123 | mycol.update_one( 124 | {'_id': user_id}, 125 | {"$set": {"active_group" : prvs_group_id}} 126 | ) 127 | else: 128 | mycol.update_one( 129 | {'_id': user_id}, 130 | {"$set": {"active_group" : None}} 131 | ) 132 | return True 133 | except Exception as e: 134 | logger.exception(f'Some error occured! {e}', exc_info=True) 135 | return False 136 | 137 | -------------------------------------------------------------------------------- /plugins/admemes/in_kick.py: -------------------------------------------------------------------------------- 1 | from info import ADMINS 2 | from Script import script 3 | from time import time, sleep 4 | from pyrogram import Client, filters 5 | from pyrogram.errors import FloodWait 6 | from pyrogram.errors.exceptions.forbidden_403 import ChatWriteForbidden 7 | from pyrogram.errors.exceptions.bad_request_400 import ChatAdminRequired, UserAdminInvalid 8 | 9 | 10 | @Client.on_message(filters.incoming & ~filters.private & filters.command('inkick')) 11 | def inkick(client, message): 12 | user = client.get_chat_member(message.chat.id, message.from_user.id) 13 | if user.status == ("creator"): 14 | if len(message.command) > 1: 15 | input_str = message.command 16 | sent_message = message.reply_text(script.START_KICK) 17 | sleep(20) 18 | sent_message.delete() 19 | message.delete() 20 | count = 0 21 | for member in client.iter_chat_members(message.chat.id): 22 | if member.user.status in input_str and not member.status in ('administrator', 'creator'): 23 | try: 24 | client.kick_chat_member(message.chat.id, member.user.id, int(time() + 45)) 25 | count += 1 26 | sleep(1) 27 | except (ChatAdminRequired, UserAdminInvalid): 28 | sent_message.edit(script.ADMIN_REQUIRED) 29 | client.leave_chat(message.chat.id) 30 | break 31 | except FloodWait as e: 32 | sleep(e.x) 33 | try: 34 | sent_message.edit(script.KICKED.format(count)) 35 | except ChatWriteForbidden: 36 | pass 37 | else: 38 | message.reply_text(script.INPUT_REQUIRED) 39 | else: 40 | sent_message = message.reply_text(script.CREATOR_REQUIRED) 41 | sleep(5) 42 | sent_message.delete() 43 | message.delete() 44 | 45 | @Client.on_message(filters.incoming & ~filters.private & filters.command('dkick')) 46 | def dkick(client, message): 47 | user = client.get_chat_member(message.chat.id, message.from_user.id) 48 | if user.status == ("creator"): 49 | sent_message = message.reply_text(script.START_KICK) 50 | sleep(20) 51 | sent_message.delete() 52 | message.delete() 53 | count = 0 54 | for member in client.iter_chat_members(message.chat.id): 55 | if member.user.is_deleted and not member.status in ('administrator', 'creator'): 56 | try: 57 | client.kick_chat_member(message.chat.id, member.user.id, int(time() + 45)) 58 | count += 1 59 | sleep(1) 60 | except (ChatAdminRequired, UserAdminInvalid): 61 | sent_message.edit(script.ADMIN_REQUIRED) 62 | client.leave_chat(message.chat.id) 63 | break 64 | except FloodWait as e: 65 | sleep(e.x) 66 | try: 67 | sent_message.edit(script.DKICK.format(count)) 68 | except ChatWriteForbidden: 69 | pass 70 | else: 71 | sent_message = message.reply_text(script.CREATOR_REQUIRED) 72 | sleep(5) 73 | sent_message.delete() 74 | message.delete() 75 | 76 | @Client.on_message(filters.incoming & ~filters.private & filters.command('instatus')) 77 | def instatus(client, message): 78 | user = client.get_chat_member(message.chat.id, message.from_user.id) 79 | if user.status in ('administrator', 'creator', 'ADMINS'): 80 | sent_message = message.reply_text(script.FETCHING_INFO) 81 | recently = 0 82 | within_week = 0 83 | within_month = 0 84 | long_time_ago = 0 85 | deleted_acc = 0 86 | uncached = 0 87 | bot = 0 88 | for member in client.iter_chat_members(message.chat.id): 89 | user = member.user 90 | if user.is_deleted: 91 | deleted_acc += 1 92 | elif user.is_bot: 93 | bot += 1 94 | elif user.status == "recently": 95 | recently += 1 96 | elif user.status == "within_week": 97 | within_week += 1 98 | elif user.status == "within_month": 99 | within_month += 1 100 | elif user.status == "long_time_ago": 101 | long_time_ago += 1 102 | else: 103 | uncached += 1 104 | sent_message.edit(script.STATUS.format(message.chat.title, recently, within_week, within_month, long_time_ago, deleted_acc, bot, uncached)) 105 | -------------------------------------------------------------------------------- /plugins/inline.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from pyrogram import Client, emoji, filters 3 | from pyrogram.errors.exceptions.bad_request_400 import QueryIdInvalid 4 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, InlineQueryResultCachedDocument 5 | from database.ia_filterdb import get_search_results 6 | from utils import is_subscribed, get_size 7 | from info import CACHE_TIME, AUTH_USERS, AUTH_CHANNEL, CUSTOM_FILE_CAPTION 8 | 9 | logger = logging.getLogger(__name__) 10 | cache_time = 0 if AUTH_USERS or AUTH_CHANNEL else CACHE_TIME 11 | 12 | 13 | @Client.on_inline_query(filters.user(AUTH_USERS) if AUTH_USERS else None) 14 | async def answer(bot, query): 15 | """Show search results for given inline query""" 16 | 17 | if AUTH_CHANNEL and not await is_subscribed(bot, query): 18 | await query.answer(results=[], 19 | cache_time=0, 20 | switch_pm_text='You have to subscribe my channel to use the bot', 21 | switch_pm_parameter="subscribe") 22 | return 23 | 24 | results = [] 25 | if '|' in query.query: 26 | string, file_type = query.query.split('|', maxsplit=1) 27 | string = string.strip() 28 | file_type = file_type.strip().lower() 29 | else: 30 | string = query.query.strip() 31 | file_type = None 32 | 33 | offset = int(query.offset or 0) 34 | reply_markup = get_reply_markup(query=string) 35 | files, next_offset, total = await get_search_results(string, 36 | file_type=file_type, 37 | max_results=10, 38 | offset=offset) 39 | 40 | for file in files: 41 | title=file.file_name 42 | size=get_size(file.file_size) 43 | f_caption=file.caption 44 | if CUSTOM_FILE_CAPTION: 45 | try: 46 | f_caption=CUSTOM_FILE_CAPTION.format(file_name=title, file_size=size, file_caption=f_caption) 47 | except Exception as e: 48 | logger.exception(e) 49 | f_caption=f_caption 50 | if f_caption is None: 51 | f_caption = f"{file.file_name}" 52 | results.append( 53 | InlineQueryResultCachedDocument( 54 | title=file.file_name, 55 | file_id=file.file_id, 56 | caption=f_caption, 57 | description=f'Size: {get_size(file.file_size)}\nType: {file.file_type}', 58 | reply_markup=reply_markup)) 59 | 60 | if results: 61 | switch_pm_text = f"{emoji.FILE_FOLDER} Results - {total}" 62 | if string: 63 | switch_pm_text += f" for {string}" 64 | try: 65 | await query.answer(results=results, 66 | is_personal = True, 67 | cache_time=cache_time, 68 | switch_pm_text=switch_pm_text, 69 | switch_pm_parameter="start", 70 | next_offset=str(next_offset)) 71 | except QueryIdInvalid: 72 | pass 73 | except Exception as e: 74 | logging.exception(str(e)) 75 | await query.answer(results=[], is_personal=True, 76 | cache_time=cache_time, 77 | switch_pm_text=str(e)[:63], 78 | switch_pm_parameter="error") 79 | else: 80 | switch_pm_text = f'{emoji.CROSS_MARK} No results' 81 | if string: 82 | switch_pm_text += f' for "{string}"' 83 | 84 | await query.answer(results=[], 85 | is_personal = True, 86 | cache_time=cache_time, 87 | switch_pm_text=switch_pm_text, 88 | switch_pm_parameter="okay") 89 | 90 | 91 | def get_reply_markup(query): 92 | buttons = [ 93 | [ 94 | InlineKeyboardButton('Search again', switch_inline_query_current_chat=query) 95 | ] 96 | ] 97 | return InlineKeyboardMarkup(buttons) 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Ajax-Extra-FeaturesLogo 3 |

4 |

5 | 𝙰𝙹𝙰𝚇-𝙴𝚇𝚃𝚁𝙰-𝙵𝙴𝙰𝚃𝚄𝚁𝙴𝚂 6 |

7 | 8 | 9 | 10 | 11 | 12 | [![Stars](https://img.shields.io/github/stars/Aadhi000/Ajax-Extra-Features?style=flat-square&color=green)](https://github.com/Aadhi000/Ajax-Extra-Features/stargazers) 13 | [![Forks](https://img.shields.io/github/forks/Aadhi000/Ajax-Extra-Features?style=flat-square&color=blue)](https://github.com/Aadhi000/Ajax-Extra-Features/fork) 14 | [![Size](https://img.shields.io/github/repo-size/Aadhi000/Ajax-Extra-Features?style=flat-square&color=red)](https://github.com/Aadhi000/Ajax-Extra-Features) 15 | [![Open Source happy ](https://badges.frapsoft.com/os/v2/open-source.svg?v=103)](https://github.com/Aadhi000/Ajax-Extra-Features) 16 | [![Contributors](https://img.shields.io/github/contributors/Aadhi000/Ajax-Extra-Features?style=flat-square&color=green)](https://github.com/Aadhi000/Ajax-Extra-Features/graphs/contributors) 17 | ## Features 18 | 19 | - [x] Auto Filter 20 | - [x] Manual Filter 21 | - [x] IMDB 22 | - [x] Admin Commands 23 | - [x] Broadcast 24 | - [x] Index 25 | - [x] IMDB search 26 | - [x] Inline Search 27 | - [x] Random pics 28 | - [x] ids and User info 29 | - [x] Stats, Users, Chats, Ban, Unban, Leave, Disable, Channel 30 | - [x] Spelling Check Feature 31 | - [x] Youtube Video , Song , Thumbnail Download. 32 | - [x] Image Edit. 33 | - [x] Google Translator. 34 | - [x] Telegraph 35 | - [x] Entertainment 36 | - [x] Sticker ID Generator 37 | - [x] COVID Information 38 | - [x] File Store 39 | - [X] Image Editor 40 | 41 | ## Variables 42 | 43 | ### Required Variables 44 | * `BOT_TOKEN`: Create a bot using [@BotFather](https://telegram.dog/BotFather), and get the Telegram API token. 45 | * `API_ID`: Get this value from [telegram.org](https://my.telegram.org/apps) 46 | * `API_HASH`: Get this value from [telegram.org](https://my.telegram.org/apps) 47 | * `CHANNELS`: Username or ID of channel or group. Separate multiple IDs by space 48 | * `ADMINS`: Username or ID of Admin. Separate multiple Admins by space 49 | * `DATABASE_URI`: [mongoDB](https://www.mongodb.com) URI. Get this value from [mongoDB](https://www.mongodb.com). 50 | * `DATABASE_NAME`: Name of the database in [mongoDB](https://www.mongodb.com). For more help watch this 51 | * `LOG_CHANNEL` : A channel to log the activities of bot. Make sure bot is an admin in the channel. 52 | * `SUPPORT_CHAT` : @MWUpdatez 53 | * `PICS`: Telegraph links of images to show in start message.( Multiple images can be used seperated by space ) 54 | ### Optional Variables 55 | 56 | ## Deploy 57 | You can deploy this bot anywhere. 58 | 59 | 60 | Deploy To Heroku 61 |
62 |

63 | 64 | Deploy 65 | 66 |

67 | 68 | 69 | 70 |
71 | 72 |
Deploy To VPS 73 |

74 |

 75 | git clone https://github.com/Aadhi000/Ajax-Extra-Features
 76 | # Install Packages
 77 | pip3 install -r requirements.txt
 78 | Edit info.py with variables as given below then run bot
 79 | python3 bot.py
 80 | 
81 |

82 |
83 | 84 | 85 | ## Commands 86 | ``` 87 | * /logs - to get the rescent errors 88 | * /stats - to get status of files in db. 89 | * /filter - add manual filters 90 | * /filters - view filters 91 | * /connect - connect to PM. 92 | * /disconnect - disconnect from PM 93 | * /del - delete a filter 94 | * /delall - delete all filters 95 | * /deleteall - delete all index(autofilter) 96 | * /delete - delete a specific file from index. 97 | * /info - get user info 98 | * /id - get tg ids. 99 | * /video - Download Video 100 | * /song - Download Song 101 | * /imdb - fetch info from imdb. 102 | * /users - to get list of my users and ids. 103 | * /chats - to get list of the my chats and ids 104 | * /index - to add files from a channel 105 | * /leave - to leave from a chat. 106 | * /disable - do disable a chat. 107 | * /enable - re-enable chat. 108 | * /ban - to ban a user. 109 | * /unban - to unban a user. 110 | * /channel - to get list of total connected channels 111 | * /broadcast - to broadcast a message to all Ajax users 112 | ``` 113 | 114 | ᴅᴇᴠᴇʟᴏᴘᴇʀ ›› [ᴀᴀᴅʜɪ](https://telegram.dog/AboutAadhi) | [ɪɴsᴛᴀɢʀᴀᴍ](https://www.instagram.com/aadhi.xr/) | [ɢɪᴛʜᴜʙ](GitHub.com/Aadhi000) 115 | ᴄʜᴀɴɴᴇʟ ›› [ᴍᴡ ᴜᴘᴅᴀᴛᴇᴢ](https://t.me/MWUpdatez) 116 | -------------------------------------------------------------------------------- /database/users_chats_db.py: -------------------------------------------------------------------------------- 1 | # https://github.com/odysseusmax/animated-lamp/blob/master/bot/database/database.py 2 | import motor.motor_asyncio 3 | from info import DATABASE_NAME, DATABASE_URI, IMDB, IMDB_TEMPLATE, MELCOW_NEW_USERS, P_TTI_SHOW_OFF, SINGLE_BUTTON, SPELL_CHECK_REPLY, PROTECT_CONTENT 4 | 5 | class Database: 6 | 7 | def __init__(self, uri, database_name): 8 | self._client = motor.motor_asyncio.AsyncIOMotorClient(uri) 9 | self.db = self._client[database_name] 10 | self.col = self.db.users 11 | self.grp = self.db.groups 12 | 13 | 14 | def new_user(self, id, name): 15 | return dict( 16 | id = id, 17 | name = name, 18 | ban_status=dict( 19 | is_banned=False, 20 | ban_reason="", 21 | ), 22 | ) 23 | 24 | 25 | def new_group(self, id, title): 26 | return dict( 27 | id = id, 28 | title = title, 29 | chat_status=dict( 30 | is_disabled=False, 31 | reason="", 32 | ), 33 | ) 34 | 35 | async def add_user(self, id, name): 36 | user = self.new_user(id, name) 37 | await self.col.insert_one(user) 38 | 39 | async def is_user_exist(self, id): 40 | user = await self.col.find_one({'id':int(id)}) 41 | return bool(user) 42 | 43 | async def total_users_count(self): 44 | count = await self.col.count_documents({}) 45 | return count 46 | 47 | async def remove_ban(self, id): 48 | ban_status = dict( 49 | is_banned=False, 50 | ban_reason='' 51 | ) 52 | await self.col.update_one({'id': id}, {'$set': {'ban_status': ban_status}}) 53 | 54 | async def ban_user(self, user_id, ban_reason="No Reason"): 55 | ban_status = dict( 56 | is_banned=True, 57 | ban_reason=ban_reason 58 | ) 59 | await self.col.update_one({'id': user_id}, {'$set': {'ban_status': ban_status}}) 60 | 61 | async def get_ban_status(self, id): 62 | default = dict( 63 | is_banned=False, 64 | ban_reason='' 65 | ) 66 | user = await self.col.find_one({'id':int(id)}) 67 | if not user: 68 | return default 69 | return user.get('ban_status', default) 70 | 71 | async def get_all_users(self): 72 | return self.col.find({}) 73 | 74 | 75 | async def delete_user(self, user_id): 76 | await self.col.delete_many({'id': int(user_id)}) 77 | 78 | 79 | async def get_banned(self): 80 | users = self.col.find({'ban_status.is_banned': True}) 81 | chats = self.grp.find({'chat_status.is_disabled': True}) 82 | b_chats = [chat['id'] async for chat in chats] 83 | b_users = [user['id'] async for user in users] 84 | return b_users, b_chats 85 | 86 | 87 | 88 | async def add_chat(self, chat, title): 89 | chat = self.new_group(chat, title) 90 | await self.grp.insert_one(chat) 91 | 92 | 93 | async def get_chat(self, chat): 94 | chat = await self.grp.find_one({'id':int(chat)}) 95 | return False if not chat else chat.get('chat_status') 96 | 97 | 98 | async def re_enable_chat(self, id): 99 | chat_status=dict( 100 | is_disabled=False, 101 | reason="", 102 | ) 103 | await self.grp.update_one({'id': int(id)}, {'$set': {'chat_status': chat_status}}) 104 | 105 | async def update_settings(self, id, settings): 106 | await self.grp.update_one({'id': int(id)}, {'$set': {'settings': settings}}) 107 | 108 | 109 | async def get_settings(self, id): 110 | default = { 111 | 'button': SINGLE_BUTTON, 112 | 'botpm': P_TTI_SHOW_OFF, 113 | 'file_secure': PROTECT_CONTENT, 114 | 'imdb': IMDB, 115 | 'spell_check': SPELL_CHECK_REPLY, 116 | 'welcome': MELCOW_NEW_USERS, 117 | 'template': IMDB_TEMPLATE 118 | } 119 | chat = await self.grp.find_one({'id':int(id)}) 120 | if chat: 121 | return chat.get('settings', default) 122 | return default 123 | 124 | 125 | async def disable_chat(self, chat, reason="No Reason"): 126 | chat_status=dict( 127 | is_disabled=True, 128 | reason=reason, 129 | ) 130 | await self.grp.update_one({'id': int(chat)}, {'$set': {'chat_status': chat_status}}) 131 | 132 | 133 | async def total_chat_count(self): 134 | count = await self.grp.count_documents({}) 135 | return count 136 | 137 | 138 | async def get_all_chats(self): 139 | return self.grp.find({}) 140 | 141 | 142 | async def get_db_size(self): 143 | return (await self.db.command("dbstats"))['dataSize'] 144 | 145 | 146 | db = Database(DATABASE_URI, DATABASE_NAME) 147 | -------------------------------------------------------------------------------- /database/ia_filterdb.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from struct import pack 3 | import re 4 | import base64 5 | from pyrogram.file_id import FileId 6 | from pymongo.errors import DuplicateKeyError 7 | from umongo import Instance, Document, fields 8 | from motor.motor_asyncio import AsyncIOMotorClient 9 | from marshmallow.exceptions import ValidationError 10 | from info import DATABASE_URI, DATABASE_NAME, COLLECTION_NAME, USE_CAPTION_FILTER 11 | 12 | logger = logging.getLogger(__name__) 13 | logger.setLevel(logging.INFO) 14 | 15 | 16 | client = AsyncIOMotorClient(DATABASE_URI) 17 | db = client[DATABASE_NAME] 18 | instance = Instance.from_db(db) 19 | 20 | @instance.register 21 | class Media(Document): 22 | file_id = fields.StrField(attribute='_id') 23 | file_ref = fields.StrField(allow_none=True) 24 | file_name = fields.StrField(required=True) 25 | file_size = fields.IntField(required=True) 26 | file_type = fields.StrField(allow_none=True) 27 | mime_type = fields.StrField(allow_none=True) 28 | caption = fields.StrField(allow_none=True) 29 | 30 | class Meta: 31 | collection_name = COLLECTION_NAME 32 | 33 | 34 | async def save_file(media): 35 | """Save file in database""" 36 | 37 | # TODO: Find better way to get same file_id for same media to avoid duplicates 38 | file_id, file_ref = unpack_new_file_id(media.file_id) 39 | file_name = re.sub(r"(_|\-|\.|\+)", " ", str(media.file_name)) 40 | try: 41 | file = Media( 42 | file_id=file_id, 43 | file_ref=file_ref, 44 | file_name=file_name, 45 | file_size=media.file_size, 46 | file_type=media.file_type, 47 | mime_type=media.mime_type, 48 | caption=media.caption.html if media.caption else None, 49 | ) 50 | except ValidationError: 51 | logger.exception('Error occurred while saving file in database') 52 | return False, 2 53 | else: 54 | try: 55 | await file.commit() 56 | except DuplicateKeyError: 57 | logger.warning(media.file_name + " is already saved in database") 58 | return False, 0 59 | else: 60 | logger.info(media.file_name + " is saved in database") 61 | return True, 1 62 | 63 | 64 | 65 | async def get_search_results(query, file_type=None, max_results=6, offset=0, filter=False): 66 | """For given query return (results, next_offset)""" 67 | 68 | query = query.strip() 69 | #if filter: 70 | #better ? 71 | #query = query.replace(' ', r'(\s|\.|\+|\-|_)') 72 | #raw_pattern = r'(\s|_|\-|\.|\+)' + query + r'(\s|_|\-|\.|\+)' 73 | if not query: 74 | raw_pattern = '.' 75 | elif ' ' not in query: 76 | raw_pattern = r'(\b|[\.\+\-_])' + query + r'(\b|[\.\+\-_])' 77 | else: 78 | raw_pattern = query.replace(' ', r'.*[\s\.\+\-_]') 79 | 80 | try: 81 | regex = re.compile(raw_pattern, flags=re.IGNORECASE) 82 | except: 83 | return [] 84 | 85 | if USE_CAPTION_FILTER: 86 | filter = {'$or': [{'file_name': regex}, {'caption': regex}]} 87 | else: 88 | filter = {'file_name': regex} 89 | 90 | if file_type: 91 | filter['file_type'] = file_type 92 | 93 | total_results = await Media.count_documents(filter) 94 | next_offset = offset + max_results 95 | 96 | if next_offset > total_results: 97 | next_offset = '' 98 | 99 | cursor = Media.find(filter) 100 | # Sort by recent 101 | cursor.sort('$natural', -1) 102 | # Slice files according to offset and max results 103 | cursor.skip(offset).limit(max_results) 104 | # Get list of files 105 | files = await cursor.to_list(length=max_results) 106 | 107 | return files, next_offset, total_results 108 | 109 | 110 | 111 | async def get_file_details(query): 112 | filter = {'file_id': query} 113 | cursor = Media.find(filter) 114 | filedetails = await cursor.to_list(length=1) 115 | return filedetails 116 | 117 | 118 | def encode_file_id(s: bytes) -> str: 119 | r = b"" 120 | n = 0 121 | 122 | for i in s + bytes([22]) + bytes([4]): 123 | if i == 0: 124 | n += 1 125 | else: 126 | if n: 127 | r += b"\x00" + bytes([n]) 128 | n = 0 129 | 130 | r += bytes([i]) 131 | 132 | return base64.urlsafe_b64encode(r).decode().rstrip("=") 133 | 134 | 135 | def encode_file_ref(file_ref: bytes) -> str: 136 | return base64.urlsafe_b64encode(file_ref).decode().rstrip("=") 137 | 138 | 139 | def unpack_new_file_id(new_file_id): 140 | """Return file_id, file_ref""" 141 | decoded = FileId.decode(new_file_id) 142 | file_id = encode_file_id( 143 | pack( 144 | " [None,str]: 93 | text_to_return = message.text 94 | if message.text is None: 95 | return None 96 | if " " not in text_to_return: 97 | return None 98 | try: 99 | return message.text.split(None, 1)[1] 100 | except IndexError: 101 | return None 102 | 103 | 104 | @Client.on_message(filters.command(["video", "mp4"])) 105 | async def vsong(client, message: Message): 106 | urlissed = get_text(message) 107 | 108 | pablo = await client.send_message( 109 | message.chat.id, f"**sᴇᴀʀᴄʜɪɴɢ ʏᴏᴜʀ ᴠᴜᴅᴇᴏ** `{urlissed}`" 110 | ) 111 | if not urlissed: 112 | await pablo.edit("Invalid Command Syntax Please Check help Menu To Know More!") 113 | return 114 | 115 | search = SearchVideos(f"{urlissed}", offset=1, mode="dict", max_results=1) 116 | mi = search.result() 117 | mio = mi["search_result"] 118 | mo = mio[0]["link"] 119 | thum = mio[0]["title"] 120 | fridayz = mio[0]["id"] 121 | mio[0]["channel"] 122 | kekme = f"https://img.youtube.com/vi/{fridayz}/hqdefault.jpg" 123 | await asyncio.sleep(0.6) 124 | url = mo 125 | sedlyf = wget.download(kekme) 126 | opts = { 127 | "format": "best", 128 | "addmetadata": True, 129 | "key": "FFmpegMetadata", 130 | "prefer_ffmpeg": True, 131 | "geo_bypass": True, 132 | "nocheckcertificate": True, 133 | "postprocessors": [{"key": "FFmpegVideoConvertor", "preferedformat": "mp4"}], 134 | "outtmpl": "%(id)s.mp4", 135 | "logtostderr": False, 136 | "quiet": True, 137 | } 138 | try: 139 | with YoutubeDL(opts) as ytdl: 140 | ytdl_data = ytdl.extract_info(url, download=True) 141 | except Exception as e: 142 | await event.edit(event, f"**𝙳𝚘𝚠𝚗𝚕𝚘𝚊𝚍 𝙵𝚊𝚒𝚕𝚎𝚍 𝙿𝚕𝚎𝚊𝚜𝚎 𝚃𝚛𝚢 𝙰𝚐𝚊𝚒𝚗..♥️** \n**Error :** `{str(e)}`") 143 | return 144 | c_time = time.time() 145 | file_stark = f"{ytdl_data['id']}.mp4" 146 | capy = f""" 147 | **ᴛɪᴛʟᴇ :** [{thum}]({mo}) 148 | **ʀᴇǫᴜᴇsᴛᴇᴅ ʙʏ :** {message.from_user.mention} 149 | """ 150 | await client.send_video( 151 | message.chat.id, 152 | video=open(file_stark, "rb"), 153 | duration=int(ytdl_data["duration"]), 154 | file_name=str(ytdl_data["title"]), 155 | thumb=sedlyf, 156 | caption=capy, 157 | supports_streaming=True, 158 | reply_to_message_id=message.message_id 159 | ) 160 | await pablo.delete() 161 | for files in (sedlyf, file_stark): 162 | if files and os.path.exists(files): 163 | os.remove(files) 164 | -------------------------------------------------------------------------------- /plugins/connection.py: -------------------------------------------------------------------------------- 1 | from pyrogram import filters, Client 2 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 3 | from database.connections_mdb import add_connection, all_connections, if_active, delete_connection 4 | from info import ADMINS 5 | import logging 6 | logger = logging.getLogger(__name__) 7 | logger.setLevel(logging.ERROR) 8 | @Client.on_message((filters.private | filters.group) & filters.command('connect')) 9 | async def addconnection(client,message): 10 | userid = message.from_user.id if message.from_user else None 11 | if not userid: 12 | return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") 13 | chat_type = message.chat.type 14 | 15 | if chat_type == "private": 16 | try: 17 | cmd, group_id = message.text.split(" ", 1) 18 | except: 19 | await message.reply_text( 20 | "𝙴𝙽𝚃𝙴𝚁 𝙸𝙽 𝙲𝙾𝚁𝚁𝙴𝙲𝚃 𝙵𝙾𝚁𝙼𝙰𝚃\n" 21 | "**/connect 𝙶𝚁𝙾𝚄𝙿 𝙸𝙳\n**" 22 | "**Get your Group id by adding this bot to your group and use /id**", 23 | quote=True 24 | ) 25 | return 26 | 27 | elif chat_type in ["group", "supergroup"]: 28 | group_id = message.chat.id 29 | 30 | try: 31 | st = await client.get_chat_member(group_id, userid) 32 | if ( 33 | st.status != "administrator" 34 | and st.status != "creator" 35 | and str(userid) not in ADMINS 36 | ): 37 | await message.reply_text("You should be an admin in Given group!", quote=True) 38 | return 39 | except Exception as e: 40 | logger.exception(e) 41 | await message.reply_text( 42 | "Invalid Group ID!\n\nIf correct, Make sure I'm present in your group!!", 43 | quote=True, 44 | ) 45 | 46 | return 47 | try: 48 | st = await client.get_chat_member(group_id, "me") 49 | if st.status == "administrator": 50 | ttl = await client.get_chat(group_id) 51 | title = ttl.title 52 | 53 | addcon = await add_connection(str(group_id), str(userid)) 54 | if addcon: 55 | await message.reply_text( 56 | f"𝚂𝚄𝙲𝙲𝙴𝚂𝚂𝙵𝚄𝙻𝙻𝚈 𝙲𝙾𝙽𝙽𝙴𝙲𝚃 𝚃𝙾 **{title}**\n𝙽𝙾𝚆 𝚈𝙾𝚄 𝙲𝙰𝙽 𝙼𝙰𝙽𝙰𝙶𝙴 𝚈𝙾𝚄𝚁 𝙶𝚁𝙾𝚄𝙿 𝙵𝚁𝙾𝙼 𝙷𝙴𝚁𝙴../", 57 | quote=True, 58 | parse_mode="md" 59 | ) 60 | if chat_type in ["group", "supergroup"]: 61 | await client.send_message( 62 | userid, 63 | f"Connected to **{title}** !", 64 | parse_mode="md" 65 | ) 66 | else: 67 | await message.reply_text( 68 | "You're already connected to this chat!", 69 | quote=True 70 | ) 71 | else: 72 | await message.reply_text("Add me as an admin in group", quote=True) 73 | except Exception as e: 74 | logger.exception(e) 75 | await message.reply_text('Some error occured! Try again later.', quote=True) 76 | return 77 | 78 | 79 | @Client.on_message((filters.private | filters.group) & filters.command('disconnect')) 80 | async def deleteconnection(client,message): 81 | userid = message.from_user.id if message.from_user else None 82 | if not userid: 83 | return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") 84 | chat_type = message.chat.type 85 | 86 | if chat_type == "private": 87 | await message.reply_text("Run /connections to view or disconnect from groups!", quote=True) 88 | 89 | elif chat_type in ["group", "supergroup"]: 90 | group_id = message.chat.id 91 | 92 | st = await client.get_chat_member(group_id, userid) 93 | if ( 94 | st.status != "administrator" 95 | and st.status != "creator" 96 | and str(userid) not in ADMINS 97 | ): 98 | return 99 | 100 | delcon = await delete_connection(str(userid), str(group_id)) 101 | if delcon: 102 | await message.reply_text("Successfully disconnected from this chat", quote=True) 103 | else: 104 | await message.reply_text("This chat isn't connected to me!\nDo /connect to connect.", quote=True) 105 | 106 | 107 | 108 | @Client.on_message(filters.private & filters.command(["connections"])) 109 | async def connections(client,message): 110 | userid = message.from_user.id 111 | 112 | groupids = await all_connections(str(userid)) 113 | if groupids is None: 114 | await message.reply_text( 115 | "There are no active connections!! Connect to some groups first.", 116 | quote=True 117 | ) 118 | return 119 | buttons = [] 120 | for groupid in groupids: 121 | try: 122 | ttl = await client.get_chat(int(groupid)) 123 | title = ttl.title 124 | active = await if_active(str(userid), str(groupid)) 125 | act = " › 𝙰𝙲𝚃𝙸𝚅𝙴" if active else "" 126 | buttons.append( 127 | [ 128 | InlineKeyboardButton( 129 | text=f"{title}{act}", callback_data=f"groupcb:{groupid}:{act}" 130 | ) 131 | ] 132 | ) 133 | except: 134 | pass 135 | if buttons: 136 | await message.reply_text( 137 | "𝙲𝙾𝙽𝙽𝙴𝙲𝚃𝙴𝙳 𝙶𝚁𝙾𝚄𝙿𝚂 :-\n\n", 138 | reply_markup=InlineKeyboardMarkup(buttons), 139 | quote=True 140 | ) 141 | else: 142 | await message.reply_text( 143 | "There are no active connections!! Connect to some groups first.", 144 | quote=True 145 | ) 146 | -------------------------------------------------------------------------------- /info.py: -------------------------------------------------------------------------------- 1 | import re 2 | from os import environ 3 | import asyncio 4 | import json 5 | from collections import defaultdict 6 | from typing import Dict, List, Union 7 | from pyrogram import Client 8 | 9 | id_pattern = re.compile(r'^.\d+$') 10 | def is_enabled(value, default): 11 | if value.lower() in ["true", "yes", "1", "enable", "y"]: 12 | return True 13 | elif value.lower() in ["false", "no", "0", "disable", "n"]: 14 | return False 15 | else: 16 | return default 17 | 18 | class evamaria(Client): 19 | filterstore: Dict[str, Dict[str, str]] = defaultdict(dict) 20 | warndatastore: Dict[ 21 | str, Dict[str, Union[str, int, List[str]]] 22 | ] = defaultdict(dict) 23 | warnsettingsstore: Dict[str, str] = defaultdict(dict) 24 | 25 | def __init__(self): 26 | name = self.__class__.__name__.lower() 27 | super().__init__( 28 | ":memory:", 29 | plugins=dict(root=f"{name}/plugins"), 30 | workdir=TMP_DOWNLOAD_DIRECTORY, 31 | api_id=APP_ID, 32 | api_hash=API_HASH, 33 | bot_token=BOT_TOKEN, 34 | parse_mode="html", 35 | sleep_threshold=60 36 | ) 37 | 38 | # Bot information 39 | SESSION = environ.get('SESSION', 'Media_search') 40 | API_ID = int(environ['API_ID']) 41 | API_HASH = environ['API_HASH'] 42 | BOT_TOKEN = environ['BOT_TOKEN'] 43 | 44 | # Bot settings 45 | CACHE_TIME = int(environ.get('CACHE_TIME', 300)) 46 | USE_CAPTION_FILTER = bool(environ.get('USE_CAPTION_FILTER', False)) 47 | PICS = (environ.get('PICS' ,'https://telegra.ph/file/3d87cdb638b5444198c59.jpg https://telegra.ph/file/2140af3c0cb1c848ef5a0.jpg https://telegra.ph/file/f5c3720b2ce9d1d97d59f.jpg https://telegra.ph/file/e67137996688342d75f1e.jpg')).split() 48 | 49 | # Admins, Channels & Users 50 | ADMINS = [int(admin) if id_pattern.search(admin) else admin for admin in environ.get('ADMINS', '').split()] 51 | CHANNELS = [int(ch) if id_pattern.search(ch) else ch for ch in environ.get('CHANNELS', '0').split()] 52 | auth_users = [int(user) if id_pattern.search(user) else user for user in environ.get('AUTH_USERS', '').split()] 53 | AUTH_USERS = (auth_users + ADMINS) if auth_users else [] 54 | auth_channel = environ.get('AUTH_CHANNEL') 55 | auth_grp = environ.get('AUTH_GROUP') 56 | AUTH_CHANNEL = int(auth_channel) if auth_channel and id_pattern.search(auth_channel) else None 57 | AUTH_GROUPS = [int(ch) for ch in auth_grp.split()] if auth_grp else None 58 | USE_AS_BOT = environ.get("USE_AS_BOT", True) 59 | 60 | # maximum message length in Telegram 61 | MAX_MESSAGE_LENGTH = 4096 62 | 63 | # This is required for the plugins involving the file system. 64 | TMP_DOWNLOAD_DIRECTORY = environ.get("TMP_DOWNLOAD_DIRECTORY", "./DOWNLOADS/") 65 | 66 | # the maximum number of 'selectable' messages in Telegram 67 | TG_MAX_SELECT_LEN = environ.get("TG_MAX_SELECT_LEN", "100") 68 | 69 | # Command 70 | COMMAND_HAND_LER = environ.get("COMMAND_HAND_LER", "/") 71 | 72 | # MongoDB information 73 | DATABASE_URI = environ.get('DATABASE_URI', "") 74 | DATABASE_NAME = environ.get('DATABASE_NAME', "Rajappan") 75 | COLLECTION_NAME = environ.get('COLLECTION_NAME', 'Telegram_files') 76 | 77 | #Downloader 78 | DOWNLOAD_LOCATION = environ.get("DOWNLOAD_LOCATION", "./DOWNLOADS/AudioBoT/") 79 | 80 | # Others 81 | LOG_CHANNEL = int(environ.get('LOG_CHANNEL', 0)) 82 | SUPPORT_CHAT = environ.get('SUPPORT_CHAT', 'TeamEvamaria') 83 | P_TTI_SHOW_OFF = is_enabled((environ.get('P_TTI_SHOW_OFF', "False")), False) 84 | IMDB = is_enabled((environ.get('IMDB', "True")), True) 85 | SINGLE_BUTTON = is_enabled((environ.get('SINGLE_BUTTON', "False")), False) 86 | CUSTOM_FILE_CAPTION = environ.get("CUSTOM_FILE_CAPTION", None) 87 | BATCH_FILE_CAPTION = environ.get("BATCH_FILE_CAPTION", CUSTOM_FILE_CAPTION) 88 | IMDB_TEMPLATE = environ.get("IMDB_TEMPLATE", "Query: {query} \n‌IMDb Data:\n\n🏷 Title: {title}\n🎭 Genres: {genres}\n📆 Year: {year}\n🌟 Rating: {rating} / 10") 89 | LONG_IMDB_DESCRIPTION = is_enabled(environ.get("LONG_IMDB_DESCRIPTION", "False"), False) 90 | SPELL_CHECK_REPLY = is_enabled(environ.get("SPELL_CHECK_REPLY", "True"), True) 91 | MAX_LIST_ELM = environ.get("MAX_LIST_ELM", None) 92 | FILE_STORE_CHANNEL = [int(ch) for ch in (environ.get('FILE_STORE_CHANNEL', '')).split()] 93 | MELCOW_NEW_USERS = is_enabled((environ.get('MELCOW_NEW_USERS', "True")), True) 94 | PROTECT_CONTENT = is_enabled((environ.get('PROTECT_CONTENT', "False")), False) 95 | PUBLIC_FILE_STORE = is_enabled((environ.get('PUBLIC_FILE_STORE', "True")), True) 96 | 97 | LOG_STR = "Current Cusomized Configurations are:-\n" 98 | LOG_STR += ("IMDB Results are enabled, Bot will be showing imdb details for you queries.\n" if IMDB else "IMBD Results are disabled.\n") 99 | LOG_STR += ("P_TTI_SHOW_OFF found , Users will be redirected to send /start to Bot PM instead of sending file file directly\n" if P_TTI_SHOW_OFF else "P_TTI_SHOW_OFF is disabled files will be send in PM, instead of sending start.\n") 100 | LOG_STR += ("SINGLE_BUTTON is Found, filename and files size will be shown in a single button instead of two seperate buttons\n" if SINGLE_BUTTON else "SINGLE_BUTTON is disabled , filename and file_sixe will be shown as diffrent buttons\n") 101 | LOG_STR += (f"CUSTOM_FILE_CAPTION enabled with value {CUSTOM_FILE_CAPTION}, your files will be send along with this customized caption.\n" if CUSTOM_FILE_CAPTION else "No CUSTOM_FILE_CAPTION Found, Default captions of file will be used.\n") 102 | LOG_STR += ("Long IMDB storyline enabled." if LONG_IMDB_DESCRIPTION else "LONG_IMDB_DESCRIPTION is disabled , Plot will be shorter.\n") 103 | LOG_STR += ("Spell Check Mode Is Enabled, bot will be suggesting related movies if movie not found\n" if SPELL_CHECK_REPLY else "SPELL_CHECK_REPLY Mode disabled\n") 104 | LOG_STR += (f"MAX_LIST_ELM Found, long list will be shortened to first {MAX_LIST_ELM} elements\n" if MAX_LIST_ELM else "Full List of casts and crew will be shown in imdb template, restrict them by adding a value to MAX_LIST_ELM\n") 105 | LOG_STR += f"Your Currect IMDB template is {IMDB_TEMPLATE}" 106 | -------------------------------------------------------------------------------- /plugins/genlink.py: -------------------------------------------------------------------------------- 1 | import re 2 | from pyrogram import filters, Client 3 | from pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, UsernameInvalid, UsernameNotModified 4 | from info import ADMINS, LOG_CHANNEL, FILE_STORE_CHANNEL, PUBLIC_FILE_STORE 5 | from database.ia_filterdb import unpack_new_file_id 6 | from utils import temp 7 | import re 8 | import os 9 | import json 10 | import base64 11 | import logging 12 | 13 | logger = logging.getLogger(__name__) 14 | logger.setLevel(logging.INFO) 15 | 16 | async def allowed(_, __, message): 17 | if PUBLIC_FILE_STORE: 18 | return True 19 | if message.from_user and message.from_user.id in ADMINS: 20 | return True 21 | return False 22 | 23 | @Client.on_message(filters.command(['link', 'plink']) & filters.create(allowed)) 24 | async def gen_link_s(bot, message): 25 | replied = message.reply_to_message 26 | if not replied: 27 | return await message.reply('𝚁𝙴𝙿𝙻𝚈 𝚃𝙾 𝙰 𝙼𝙴𝚂𝚂𝙰𝙶𝙴 𝙾𝚁 𝙰 𝙵𝙸𝙻𝙴. 𝙸 𝚆𝙸𝙻𝙻 𝙶𝙸𝚅𝙴 𝚈𝙾𝚄 𝙰 𝚂𝙷𝙰𝚁𝙰𝙱𝙻𝙴 𝙿𝙴𝚁𝙼𝙰𝙽𝙴𝙽𝚃 𝙻𝙸𝙽𝙺') 28 | file_type = replied.media 29 | if file_type not in ["video", 'audio', 'document']: 30 | return await message.reply("𝚁𝙴𝙿𝙻𝚈 𝚃𝙾 𝙰 𝚂𝚄𝙿𝙿𝙾𝚁𝚃𝙴𝙳 𝙼𝙴𝙳𝙸𝙰") 31 | if message.has_protected_content and message.chat.id not in ADMINS: 32 | return await message.reply("𝙾𝙺 𝙱𝚁𝙾") 33 | file_id, ref = unpack_new_file_id((getattr(replied, file_type)).file_id) 34 | string = 'filep_' if message.text.lower().strip() == "/plink" else 'file_' 35 | string += file_id 36 | outstr = base64.urlsafe_b64encode(string.encode("ascii")).decode().strip("=") 37 | await message.reply(f"⪼ 𝙷𝙴𝚁𝙴 𝙸𝚂 𝚈𝙾𝚄𝚁 𝙻𝙸𝙽𝙺:\n\nhttps://t.me/{temp.U_NAME}?start={outstr}") 38 | 39 | 40 | @Client.on_message(filters.command(['batch', 'pbatch']) & filters.create(allowed)) 41 | async def gen_link_batch(bot, message): 42 | if " " not in message.text: 43 | return await message.reply("𝚄𝚂𝙴 𝙲𝙾𝚁𝚁𝙴𝙲𝚃 𝙵𝙾𝚁𝙼𝙰𝚃.\n𝙴𝚇𝙰𝙼𝙿𝙻𝙴 ›› /batch https://t.me/MWUpdatez/3 https://t.me/MWUpdatez/8.") 44 | links = message.text.strip().split(" ") 45 | if len(links) != 3: 46 | return await message.reply("Use correct format.\nExample /batch https://t.me/MWUpdatez/3 https://t.me/MWUpdatez/8.") 47 | cmd, first, last = links 48 | regex = re.compile("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$") 49 | match = regex.match(first) 50 | if not match: 51 | return await message.reply('Invalid link') 52 | f_chat_id = match.group(4) 53 | f_msg_id = int(match.group(5)) 54 | if f_chat_id.isnumeric(): 55 | f_chat_id = int(("-100" + f_chat_id)) 56 | 57 | match = regex.match(last) 58 | if not match: 59 | return await message.reply('Invalid link') 60 | l_chat_id = match.group(4) 61 | l_msg_id = int(match.group(5)) 62 | if l_chat_id.isnumeric(): 63 | l_chat_id = int(("-100" + l_chat_id)) 64 | 65 | if f_chat_id != l_chat_id: 66 | return await message.reply("Chat ids not matched.") 67 | try: 68 | chat_id = (await bot.get_chat(f_chat_id)).id 69 | except ChannelInvalid: 70 | return await message.reply('𝚃𝙷𝙸𝚂 𝙼𝙰𝚈 𝙱𝙴 𝙰 𝙿𝚁𝙸𝚅𝙰𝚃𝙴 𝙲𝙷𝙰𝙽𝙽𝙴𝙻 / 𝙶𝚁𝙾𝚄𝙿. 𝙼𝙰𝙺𝙴 𝙼𝙴 𝙰𝙽 𝙰𝙳𝙼𝙸𝙽 𝙾𝚅𝙴𝚁 𝚃𝙷𝙴𝚁𝙴 𝚃𝙾 𝙸𝙽𝙳𝙴𝚇 𝚃𝙷𝙴 𝙵𝙸𝙻𝙴𝚂.') 71 | except (UsernameInvalid, UsernameNotModified): 72 | return await message.reply('Invalid Link specified.') 73 | except Exception as e: 74 | return await message.reply(f'Errors - {e}') 75 | 76 | sts = await message.reply("𝙶𝚎𝚗𝚎𝚛𝚊𝚝𝚒𝚗𝚐 𝙻𝚒𝚗𝚔 𝙵𝚘𝚛 𝚈𝚘𝚞𝚛 𝙼𝚎𝚜𝚜𝚊𝚐𝚎.\n𝚃𝙷𝙸𝚂 𝙼𝙰𝚈𝙱𝙴 𝚃𝙰𝙺𝙴 𝚃𝙸𝙼𝙴 𝙳𝙴𝙿𝙴𝙽𝙳𝙸𝙽𝙶 𝚄𝙿𝙾𝙽 𝚃𝙷𝙴 𝙽𝚄𝙼𝙱𝙴𝚁 𝙾𝙵 𝙼𝙴𝚂𝚂𝙰𝙶𝙴𝚂") 77 | if chat_id in FILE_STORE_CHANNEL: 78 | string = f"{f_msg_id}_{l_msg_id}_{chat_id}_{cmd.lower().strip()}" 79 | b_64 = base64.urlsafe_b64encode(string.encode("ascii")).decode().strip("=") 80 | return await sts.edit(f"⪼ 𝙷𝙴𝚁𝙴 𝙸𝚂 𝚈𝙾𝚄𝚁 𝙻𝙸𝙽𝙺 ›› https://t.me/{temp.U_NAME}?start=DSTORE-{b_64}") 81 | 82 | FRMT = "╭━━━━━━━━━━━━━━━➣\n┣⪼𝙶𝙴𝙽𝙴𝚁𝙰𝚃𝙸𝙽𝙶 𝙻𝙸𝙽𝙺...\n┣⪼𝚃𝙾𝚃𝙰𝙻 𝙼𝙴𝚂𝚂𝙰𝙶𝙴𝚂: `{total}`\n┣⪼𝙳𝙾𝙽𝙴: `{current}`\n┣⪼𝚁𝙴𝙼𝙰𝙸𝙽𝙸𝙽𝙶: `{rem}`\n┣⪼𝚂𝚃𝙰𝚃𝚄𝚂: `{sts}`\n╰━━━━━━━━━━━━━━━➣" 83 | 84 | outlist = [] 85 | 86 | # file store without db channel 87 | og_msg = 0 88 | tot = 0 89 | async for msg in bot.iter_messages(f_chat_id, l_msg_id, f_msg_id): 90 | tot += 1 91 | if msg.empty or msg.service: 92 | continue 93 | if not msg.media: 94 | # only media messages supported. 95 | continue 96 | try: 97 | file_type = msg.media 98 | file = getattr(msg, file_type) 99 | caption = getattr(msg, 'caption', '') 100 | if caption: 101 | caption = caption.html 102 | if file: 103 | file = { 104 | "file_id": file.file_id, 105 | "caption": caption, 106 | "title": getattr(file, "file_name", ""), 107 | "size": file.file_size, 108 | "protect": cmd.lower().strip() == "/pbatch", 109 | } 110 | 111 | og_msg +=1 112 | outlist.append(file) 113 | except: 114 | pass 115 | if not og_msg % 20: 116 | try: 117 | await sts.edit(FRMT.format(total=l_msg_id-f_msg_id, current=tot, rem=((l_msg_id-f_msg_id) - tot), sts="Saving Messages")) 118 | except: 119 | pass 120 | with open(f"batchmode_{message.from_user.id}.json", "w+") as out: 121 | json.dump(outlist, out) 122 | post = await bot.send_document(LOG_CHANNEL, f"batchmode_{message.from_user.id}.json", file_name="Batch.json", caption="👩🏻‍💻 File Store Logs 👩🏻‍💻") 123 | os.remove(f"batchmode_{message.from_user.id}.json") 124 | file_id, ref = unpack_new_file_id(post.document.file_id) 125 | await sts.edit(f"⪼ 𝙷𝙴𝚁𝙴 𝙸𝚂 𝚈𝙾𝚄𝚁 𝙻𝙸𝙽𝙺\n𝙲𝙾𝙽𝚃𝙰𝙸𝙽𝚂 `{og_msg}` 𝙵𝙸𝙻𝙴𝚂.\n\n›› https://t.me/{temp.U_NAME}?start=BATCH-{file_id}") 126 | -------------------------------------------------------------------------------- /plugins/Don/url_shortner.py: -------------------------------------------------------------------------------- 1 | import os 2 | import aiohttp 3 | from pyrogram import Client, filters 4 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, InlineQueryResultArticle, InputTextMessageContent 5 | from pyrogram.handlers import MessageHandler 6 | from pyshorteners import Shortener 7 | 8 | BITLY_API = os.environ.get("BITLY_API", "8df1df8c23f719e5cf97788cc2d40321ea30092b") 9 | CUTTLY_API = os.environ.get("CUTTLY_API", "f64dffbde033b6c307387dd50b7c76e505f1c") 10 | SHORTCM_API = os.environ.get("SHORTCM_API", "pk_...NIZv") 11 | GPLINKS_API = os.environ.get("GPLINKS_API", "008ccaedd6061ad1948838f410947603de9007a7") 12 | 13 | reply_markup = InlineKeyboardMarkup( 14 | [[ 15 | InlineKeyboardButton("𝘊𝘭𝘰𝘴𝘦", callback_data='close_data') 16 | ]] 17 | ) 18 | 19 | @Client.on_message(filters.command(["short"]) & filters.regex(r'https?://[^\s]+')) 20 | async def reply_shortens(bot, update): 21 | message = await update.reply_text( 22 | text="`Analysing your link...`", 23 | disable_web_page_preview=True, 24 | quote=True 25 | ) 26 | link = update.matches[0].group(0) 27 | shorten_urls = await short(link) 28 | await message.edit_text( 29 | text=shorten_urls, 30 | disable_web_page_preview=True 31 | ) 32 | 33 | @Client.on_inline_query(filters.regex(r'https?://[^\s]+')) 34 | async def inline_short(bot, update): 35 | link = update.matches[0].group(0), 36 | shorten_urls = await short(link) 37 | answers = [ 38 | InlineQueryResultArticle( 39 | title="Short Links", 40 | description=update.query, 41 | input_message_content=InputTextMessageContent( 42 | message_text=shorten_urls, 43 | disable_web_page_preview=True 44 | ), 45 | reply_to_message_id=message.message_id 46 | ) 47 | ] 48 | await bot.answer_inline_query( 49 | inline_query_id=update.id, 50 | results=answers 51 | ) 52 | 53 | async def short(link): 54 | shorten_urls = "**--Shorted URLs--**\n" 55 | 56 | # Bit.ly shorten 57 | if BITLY_API: 58 | try: 59 | s = Shortener(api_key=BITLY_API) 60 | url = s.bitly.short(link) 61 | shorten_urls += f"\n**Bit.ly :-** {url}" 62 | except Exception as error: 63 | print(f"Bit.ly error :- {error}") 64 | 65 | # Chilp.it shorten 66 | try: 67 | s = Shortener() 68 | url = s.chilpit.short(link) 69 | shorten_urls += f"\n**Chilp.it :-** {url}" 70 | except Exception as error: 71 | print(f"Chilp.it error :- {error}") 72 | 73 | # Clck.ru shorten 74 | try: 75 | s = Shortener() 76 | url = s.clckru.short(link) 77 | shorten_urls += f"\n**Clck.ru :-** {url}" 78 | except Exception as error: 79 | print(f"Click.ru error :- {error}") 80 | 81 | # Cutt.ly shorten 82 | if CUTTLY_API: 83 | try: 84 | s = Shortener(api_key=CUTTLY_API) 85 | url = s.cuttly.short(link) 86 | shorten_urls += f"\n**Cutt.ly :-** {url}" 87 | except Exception as error: 88 | print(f"Cutt.ly error :- {error}") 89 | 90 | # Da.gd shorten 91 | try: 92 | s = Shortener() 93 | url = s.dagd.short(link) 94 | shorten_urls += f"\n**Da.gd :-** {url}" 95 | except Exception as error: 96 | print(f"Da.gd error :- {error}") 97 | 98 | # Is.gd shorten 99 | try: 100 | s = Shortener() 101 | url = s.isgd.short(link) 102 | shorten_urls += f"\n**Is.gd :-** {url}" 103 | except Exception as error: 104 | print(f"Is.gd error :- {error}") 105 | 106 | # Osdb.link shorten 107 | try: 108 | s = Shortener() 109 | url = s.osdb.short(link) 110 | shorten_urls += f"\n**Osdb.link :-** {url}" 111 | except Exception as error: 112 | print(f"Osdb.link error :- {error}") 113 | 114 | # Ow.ly shorten 115 | try: 116 | s = Shortener() 117 | url = s.owly.short(link) 118 | shorten_urls += f"\n**Ow.ly :-** {url}" 119 | except Exception as error: 120 | print(f"Ow.ly error :- {error}") 121 | 122 | # Po.st shorten 123 | try: 124 | s = Shortener() 125 | url = s.post.short(link) 126 | shorten_urls += f"\n**Po.st :-** {url}" 127 | except Exception as error: 128 | print(f"Po.st error :- {error}") 129 | 130 | # Qps.ru shorten 131 | try: 132 | s = Shortener() 133 | url = s.qpsru.short(link) 134 | shorten_urls += f"\n**Qps.ru :-** {url}" 135 | except Exception as error: 136 | print(f"Qps.ru error :- {error}") 137 | 138 | # Short.cm shorten 139 | if SHORTCM_API: 140 | try: 141 | s = Shortener(api_key=SHORTCM_API) 142 | url = s.shortcm.short(link) 143 | shorten_urls += f"\n**Short.cm :-** {url}" 144 | except Exception as error: 145 | print(f"Short.cm error :- {error}") 146 | 147 | # TinyURL.com shorten 148 | try: 149 | s = Shortener() 150 | url = s.tinyurl.short(link) 151 | shorten_urls += f"\n**TinyURL.com :-** {url}" 152 | except Exception as error: 153 | print(f"TinyURL.com error :- {error}") 154 | 155 | # NullPointer shorten 156 | try: 157 | s = Shortener(domain='https://0x0.st') 158 | url = s.nullpointer.short(link) 159 | shorten_urls += f"\n**0x0.st :-** {url}" 160 | except Exception as error: 161 | print(f"NullPointer error :- {error}") 162 | 163 | # GPLinks shorten 164 | try: 165 | api_url = "https://gplinks.in/api" 166 | params = {'api': GPLINKS_API, 'url': link} 167 | async with aiohttp.ClientSession() as session: 168 | async with session.get(api_url, params=params, raise_for_status=True) as response: 169 | data = await response.json() 170 | url = data["shortenedUrl"] 171 | shorten_urls += f"\n**GPLinks.in :-** {url}" 172 | except Exception as error: 173 | print(f"GPLink error :- {error}") 174 | 175 | # Send the text 176 | try: 177 | shorten_urls += "" 178 | return shorten_urls 179 | except Exception as error: 180 | return error 181 | -------------------------------------------------------------------------------- /image/edit_3.py: -------------------------------------------------------------------------------- 1 | from PIL import Image, ImageOps 2 | import shutil 3 | import os 4 | 5 | 6 | async def black_border(client, message): 7 | try: 8 | userid = str(message.chat.id) 9 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 10 | os.makedirs(f"./DOWNLOADS/{userid}") 11 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 12 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "imaged-black-border.png" 13 | if not message.reply_to_message.empty: 14 | msg = await message.reply_to_message.reply_text( 15 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 16 | ) 17 | a = await client.download_media( 18 | message=message.reply_to_message, file_name=download_location 19 | ) 20 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 21 | img = Image.open(a) 22 | img_with_border = ImageOps.expand(img, border=100, fill="black") 23 | img_with_border.save(edit_img_loc) 24 | await message.reply_chat_action("upload_photo") 25 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 26 | await msg.delete() 27 | else: 28 | await message.reply_text("Why did you delete that??") 29 | try: 30 | shutil.rmtree(f"./DOWNLOADS/{userid}") 31 | except Exception: 32 | pass 33 | except Exception as e: 34 | print("black_border-error - " + str(e)) 35 | if "USER_IS_BLOCKED" in str(e): 36 | return 37 | else: 38 | try: 39 | await message.reply_to_message.reply_text( 40 | "Something went wrong!", quote=True 41 | ) 42 | except Exception: 43 | return 44 | 45 | 46 | async def green_border(client, message): 47 | try: 48 | userid = str(message.chat.id) 49 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 50 | os.makedirs(f"./DOWNLOADS/{userid}") 51 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 52 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "imaged-green-border.png" 53 | if not message.reply_to_message.empty: 54 | msg = await message.reply_to_message.reply_text( 55 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 56 | ) 57 | a = await client.download_media( 58 | message=message.reply_to_message, file_name=download_location 59 | ) 60 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 61 | img = Image.open(a) 62 | img_with_border = ImageOps.expand(img, border=100, fill="green") 63 | img_with_border.save(edit_img_loc) 64 | await message.reply_chat_action("upload_photo") 65 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 66 | await msg.delete() 67 | else: 68 | await message.reply_text("Why did you delete that??") 69 | try: 70 | shutil.rmtree(f"./DOWNLOADS/{userid}") 71 | except Exception: 72 | pass 73 | except Exception as e: 74 | print("green_border-error - " + str(e)) 75 | if "USER_IS_BLOCKED" in str(e): 76 | return 77 | else: 78 | try: 79 | await message.reply_to_message.reply_text( 80 | "Something went wrong!", quote=True 81 | ) 82 | except Exception: 83 | return 84 | 85 | 86 | async def blue_border(client, message): 87 | try: 88 | userid = str(message.chat.id) 89 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 90 | os.makedirs(f"./DOWNLOADS/{userid}") 91 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 92 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "imaged-blue-border.png" 93 | if not message.reply_to_message.empty: 94 | msg = await message.reply_to_message.reply_text( 95 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 96 | ) 97 | a = await client.download_media( 98 | message=message.reply_to_message, file_name=download_location 99 | ) 100 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 101 | img = Image.open(a) 102 | img_with_border = ImageOps.expand(img, border=100, fill="blue") 103 | img_with_border.save(edit_img_loc) 104 | await message.reply_chat_action("upload_photo") 105 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 106 | await msg.delete() 107 | else: 108 | await message.reply_text("Why did you delete that??") 109 | try: 110 | shutil.rmtree(f"./DOWNLOADS/{userid}") 111 | except Exception: 112 | pass 113 | except Exception as e: 114 | print("blue_border-error - " + str(e)) 115 | if "USER_IS_BLOCKED" in str(e): 116 | return 117 | else: 118 | try: 119 | await message.reply_to_message.reply_text( 120 | "Something went wrong!", quote=True 121 | ) 122 | except Exception: 123 | return 124 | 125 | 126 | async def red_border(client, message): 127 | try: 128 | userid = str(message.chat.id) 129 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 130 | os.makedirs(f"./DOWNLOADS/{userid}") 131 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 132 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "imaged-red-border.png" 133 | if not message.reply_to_message.empty: 134 | msg = await message.reply_to_message.reply_text( 135 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 136 | ) 137 | a = await client.download_media( 138 | message=message.reply_to_message, file_name=download_location 139 | ) 140 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 141 | img = Image.open(a) 142 | img_with_border = ImageOps.expand(img, border=100, fill="red") 143 | img_with_border.save(edit_img_loc) 144 | await message.reply_chat_action("upload_photo") 145 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 146 | await msg.delete() 147 | else: 148 | await message.reply_text("Why did you delete that??") 149 | try: 150 | shutil.rmtree(f"./DOWNLOADS/{userid}") 151 | except Exception: 152 | pass 153 | except Exception as e: 154 | print("red_border-error - " + str(e)) 155 | if "USER_IS_BLOCKED" in str(e): 156 | return 157 | else: 158 | try: 159 | await message.reply_to_message.reply_text( 160 | "Something went wrong!", quote=True 161 | ) 162 | except Exception: 163 | return 164 | -------------------------------------------------------------------------------- /plugins/index.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import asyncio 3 | from pyrogram import Client, filters 4 | from pyrogram.errors import FloodWait 5 | from pyrogram.errors.exceptions.bad_request_400 import ChannelInvalid, ChatAdminRequired, UsernameInvalid, UsernameNotModified 6 | from info import ADMINS, LOG_CHANNEL 7 | from database.ia_filterdb import save_file 8 | from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton 9 | from utils import temp 10 | import re 11 | logger = logging.getLogger(__name__) 12 | logger.setLevel(logging.INFO) 13 | lock = asyncio.Lock() 14 | 15 | 16 | @Client.on_callback_query(filters.regex(r'^index')) 17 | async def index_files(bot, query): 18 | if query.data.startswith('index_cancel'): 19 | temp.CANCEL = True 20 | return await query.answer("Cancelling Indexing") 21 | _, raju, chat, lst_msg_id, from_user = query.data.split("#") 22 | if raju == 'reject': 23 | await query.message.delete() 24 | await bot.send_message(int(from_user), 25 | f'Your Submission for indexing {chat} has been decliened by our moderators.', 26 | reply_to_message_id=int(lst_msg_id)) 27 | return 28 | 29 | if lock.locked(): 30 | return await query.answer('Wait until previous process complete.', show_alert=True) 31 | msg = query.message 32 | 33 | await query.answer('Processing...⏳', show_alert=True) 34 | if int(from_user) not in ADMINS: 35 | await bot.send_message(int(from_user), 36 | f'Your Submission for indexing {chat} has been accepted by our moderators and will be added soon.', 37 | reply_to_message_id=int(lst_msg_id)) 38 | await msg.edit( 39 | "Starting Indexing", 40 | reply_markup=InlineKeyboardMarkup( 41 | [[InlineKeyboardButton('Cancel', callback_data='index_cancel')]] 42 | ) 43 | ) 44 | try: 45 | chat = int(chat) 46 | except: 47 | chat = chat 48 | await index_files_to_db(int(lst_msg_id), chat, msg, bot) 49 | 50 | 51 | @Client.on_message((filters.forwarded | (filters.regex("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$")) & filters.text ) & filters.private & filters.incoming) 52 | async def send_for_index(bot, message): 53 | if message.text: 54 | regex = re.compile("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$") 55 | match = regex.match(message.text) 56 | if not match: 57 | return await message.reply('Invalid link') 58 | chat_id = match.group(4) 59 | last_msg_id = int(match.group(5)) 60 | if chat_id.isnumeric(): 61 | chat_id = int(("-100" + chat_id)) 62 | elif message.forward_from_chat.type == 'channel': 63 | last_msg_id = message.forward_from_message_id 64 | chat_id = message.forward_from_chat.username or message.forward_from_chat.id 65 | else: 66 | return 67 | try: 68 | await bot.get_chat(chat_id) 69 | except ChannelInvalid: 70 | return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.') 71 | except (UsernameInvalid, UsernameNotModified): 72 | return await message.reply('Invalid Link specified.') 73 | except Exception as e: 74 | logger.exception(e) 75 | return await message.reply(f'Errors - {e}') 76 | try: 77 | k = await bot.get_messages(chat_id, last_msg_id) 78 | except: 79 | return await message.reply('Make Sure That Iam An Admin In The Channel, if channel is private') 80 | if k.empty: 81 | return await message.reply('This may be group and iam not a admin of the group.') 82 | 83 | if message.from_user.id in ADMINS: 84 | buttons = [ 85 | [ 86 | InlineKeyboardButton('Yes', 87 | callback_data=f'index#accept#{chat_id}#{last_msg_id}#{message.from_user.id}') 88 | ], 89 | [ 90 | InlineKeyboardButton('close', callback_data='close_data'), 91 | ] 92 | ] 93 | reply_markup = InlineKeyboardMarkup(buttons) 94 | return await message.reply( 95 | f'Do you Want To Index This Channel/ Group ?\n\nChat ID/ Username: {chat_id}\nLast Message ID: {last_msg_id}', 96 | reply_markup=reply_markup) 97 | 98 | if type(chat_id) is int: 99 | try: 100 | link = (await bot.create_chat_invite_link(chat_id)).invite_link 101 | except ChatAdminRequired: 102 | return await message.reply('Make sure iam an admin in the chat and have permission to invite users.') 103 | else: 104 | link = f"@{message.forward_from_chat.username}" 105 | buttons = [ 106 | [ 107 | InlineKeyboardButton('Accept Index', 108 | callback_data=f'index#accept#{chat_id}#{last_msg_id}#{message.from_user.id}') 109 | ], 110 | [ 111 | InlineKeyboardButton('Reject Index', 112 | callback_data=f'index#reject#{chat_id}#{message.message_id}#{message.from_user.id}'), 113 | ] 114 | ] 115 | reply_markup = InlineKeyboardMarkup(buttons) 116 | await bot.send_message(LOG_CHANNEL, 117 | f'#IndexRequest\n\nBy : {message.from_user.mention} ({message.from_user.id})\nChat ID/ Username - {chat_id}\nLast Message ID - {last_msg_id}\nInviteLink - {link}', 118 | reply_markup=reply_markup) 119 | await message.reply('ThankYou For the Contribution, Wait For My Moderators to verify the files.') 120 | 121 | 122 | @Client.on_message(filters.command('setskip') & filters.user(ADMINS)) 123 | async def set_skip_number(bot, message): 124 | if ' ' in message.text: 125 | _, skip = message.text.split(" ") 126 | try: 127 | skip = int(skip) 128 | except: 129 | return await message.reply("Skip number should be an integer.") 130 | await message.reply(f"Succesfully set SKIP number as {skip}") 131 | temp.CURRENT = int(skip) 132 | else: 133 | await message.reply("Give me a skip number") 134 | 135 | 136 | async def index_files_to_db(lst_msg_id, chat, msg, bot): 137 | total_files = 0 138 | duplicate = 0 139 | errors = 0 140 | deleted = 0 141 | no_media = 0 142 | async with lock: 143 | try: 144 | total = lst_msg_id + 1 145 | current = temp.CURRENT 146 | temp.CANCEL = False 147 | while current < total: 148 | if temp.CANCEL: 149 | await msg.edit("Succesfully Cancelled") 150 | break 151 | try: 152 | message = await bot.get_messages(chat_id=chat, message_ids=current, replies=0) 153 | except FloodWait as e: 154 | await asyncio.sleep(e.x) 155 | message = await bot.get_messages( 156 | chat, 157 | current, 158 | replies=0 159 | ) 160 | except Exception as e: 161 | logger.exception(e) 162 | try: 163 | for file_type in ("document", "video", "audio"): 164 | media = getattr(message, file_type, None) 165 | if media is not None: 166 | break 167 | else: 168 | continue 169 | media.file_type = file_type 170 | media.caption = message.caption 171 | aynav, vnay = await save_file(media) 172 | if aynav: 173 | total_files += 1 174 | elif vnay == 0: 175 | duplicate += 1 176 | elif vnay == 2: 177 | errors += 1 178 | except Exception as e: 179 | if "NoneType" in str(e): 180 | if message.empty: 181 | deleted += 1 182 | elif not media: 183 | no_media += 1 184 | logger.warning("Skipping deleted / Non-Media messages (if this continues for long, use /setskip to set a skip number)") 185 | else: 186 | logger.exception(e) 187 | current += 1 188 | if current % 20 == 0: 189 | can = [[InlineKeyboardButton('Cancel', callback_data='index_cancel')]] 190 | reply = InlineKeyboardMarkup(can) 191 | await msg.edit_text( 192 | text=f"Total messages fetched: {current}\nTotal messages saved: {total_files}\nDuplicate Files Skipped: {duplicate}\nDeleted Messages Skipped: {deleted}\nNon-Media messages skipped: {no_media}\nErrors Occured: {errors}", 193 | reply_markup=reply) 194 | except Exception as e: 195 | logger.exception(e) 196 | await msg.edit(f'Error: {e}') 197 | else: 198 | await msg.edit(f'Succesfully saved {total_files} to dataBase!\nDuplicate Files Skipped: {duplicate}\nDeleted Messages Skipped: {deleted}\nNon-Media messages skipped: {no_media}\nErrors Occured: {errors}') 199 | -------------------------------------------------------------------------------- /plugins/filters.py: -------------------------------------------------------------------------------- 1 | import io 2 | from pyrogram import filters, Client 3 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 4 | from database.filters_mdb import( 5 | add_filter, 6 | get_filters, 7 | delete_filter, 8 | count_filters 9 | ) 10 | 11 | from database.connections_mdb import active_connection 12 | from utils import get_file_id, parser, split_quotes 13 | from info import ADMINS 14 | 15 | 16 | @Client.on_message(filters.command(['filter', 'add']) & filters.incoming) 17 | async def addfilter(client, message): 18 | userid = message.from_user.id if message.from_user else None 19 | if not userid: 20 | return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") 21 | chat_type = message.chat.type 22 | args = message.text.html.split(None, 1) 23 | 24 | if chat_type == "private": 25 | grpid = await active_connection(str(userid)) 26 | if grpid is not None: 27 | grp_id = grpid 28 | try: 29 | chat = await client.get_chat(grpid) 30 | title = chat.title 31 | except: 32 | await message.reply_text("Make sure I'm present in your group!!", quote=True) 33 | return 34 | else: 35 | await message.reply_text("I'm not connected to any groups!", quote=True) 36 | return 37 | 38 | elif chat_type in ["group", "supergroup"]: 39 | grp_id = message.chat.id 40 | title = message.chat.title 41 | 42 | else: 43 | return 44 | 45 | st = await client.get_chat_member(grp_id, userid) 46 | if ( 47 | st.status != "administrator" 48 | and st.status != "creator" 49 | and str(userid) not in ADMINS 50 | ): 51 | return 52 | 53 | 54 | if len(args) < 2: 55 | await message.reply_text("Command Incomplete :(", quote=True) 56 | return 57 | 58 | extracted = split_quotes(args[1]) 59 | text = extracted[0].lower() 60 | 61 | if not message.reply_to_message and len(extracted) < 2: 62 | await message.reply_text("Add some content to save your filter!", quote=True) 63 | return 64 | 65 | if (len(extracted) >= 2) and not message.reply_to_message: 66 | reply_text, btn, alert = parser(extracted[1], text) 67 | fileid = None 68 | if not reply_text: 69 | await message.reply_text("You cannot have buttons alone, give some text to go with it!", quote=True) 70 | return 71 | 72 | elif message.reply_to_message and message.reply_to_message.reply_markup: 73 | try: 74 | rm = message.reply_to_message.reply_markup 75 | btn = rm.inline_keyboard 76 | msg = get_file_id(message.reply_to_message) 77 | if msg: 78 | fileid = msg.file_id 79 | reply_text = message.reply_to_message.caption.html 80 | else: 81 | reply_text = message.reply_to_message.text.html 82 | fileid = None 83 | alert = None 84 | except: 85 | reply_text = "" 86 | btn = "[]" 87 | fileid = None 88 | alert = None 89 | 90 | elif message.reply_to_message and message.reply_to_message.media: 91 | try: 92 | msg = get_file_id(message.reply_to_message) 93 | fileid = msg.file_id if msg else None 94 | reply_text, btn, alert = parser(extracted[1], text) if message.reply_to_message.sticker else parser(message.reply_to_message.caption.html, text) 95 | except: 96 | reply_text = "" 97 | btn = "[]" 98 | alert = None 99 | elif message.reply_to_message and message.reply_to_message.text: 100 | try: 101 | fileid = None 102 | reply_text, btn, alert = parser(message.reply_to_message.text.html, text) 103 | except: 104 | reply_text = "" 105 | btn = "[]" 106 | alert = None 107 | else: 108 | return 109 | 110 | await add_filter(grp_id, text, reply_text, btn, fileid, alert) 111 | 112 | await message.reply_text( 113 | f"Filter for `{text}` added in **{title}**", 114 | quote=True, 115 | parse_mode="md" 116 | ) 117 | 118 | 119 | @Client.on_message(filters.command(['viewfilters', 'filters']) & filters.incoming) 120 | async def get_all(client, message): 121 | 122 | chat_type = message.chat.type 123 | userid = message.from_user.id if message.from_user else None 124 | if not userid: 125 | return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") 126 | if chat_type == "private": 127 | userid = message.from_user.id 128 | grpid = await active_connection(str(userid)) 129 | if grpid is not None: 130 | grp_id = grpid 131 | try: 132 | chat = await client.get_chat(grpid) 133 | title = chat.title 134 | except: 135 | await message.reply_text("Make sure I'm present in your group!!", quote=True) 136 | return 137 | else: 138 | await message.reply_text("I'm not connected to any groups!", quote=True) 139 | return 140 | 141 | elif chat_type in ["group", "supergroup"]: 142 | grp_id = message.chat.id 143 | title = message.chat.title 144 | 145 | else: 146 | return 147 | 148 | st = await client.get_chat_member(grp_id, userid) 149 | if ( 150 | st.status != "administrator" 151 | and st.status != "creator" 152 | and str(userid) not in ADMINS 153 | ): 154 | return 155 | 156 | texts = await get_filters(grp_id) 157 | count = await count_filters(grp_id) 158 | if count: 159 | filterlist = f"Total number of filters in **{title}** : {count}\n\n" 160 | 161 | for text in texts: 162 | keywords = " × `{}`\n".format(text) 163 | 164 | filterlist += keywords 165 | 166 | if len(filterlist) > 4096: 167 | with io.BytesIO(str.encode(filterlist.replace("`", ""))) as keyword_file: 168 | keyword_file.name = "keywords.txt" 169 | await message.reply_document( 170 | document=keyword_file, 171 | quote=True 172 | ) 173 | return 174 | else: 175 | filterlist = f"There are no active filters in **{title}**" 176 | 177 | await message.reply_text( 178 | text=filterlist, 179 | quote=True, 180 | parse_mode="md" 181 | ) 182 | 183 | @Client.on_message(filters.command('del') & filters.incoming) 184 | async def deletefilter(client, message): 185 | userid = message.from_user.id if message.from_user else None 186 | if not userid: 187 | return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") 188 | chat_type = message.chat.type 189 | 190 | if chat_type == "private": 191 | grpid = await active_connection(str(userid)) 192 | if grpid is not None: 193 | grp_id = grpid 194 | try: 195 | chat = await client.get_chat(grpid) 196 | title = chat.title 197 | except: 198 | await message.reply_text("Make sure I'm present in your group!!", quote=True) 199 | return 200 | else: 201 | await message.reply_text("I'm not connected to any groups!", quote=True) 202 | 203 | elif chat_type in ["group", "supergroup"]: 204 | grp_id = message.chat.id 205 | title = message.chat.title 206 | 207 | else: 208 | return 209 | 210 | st = await client.get_chat_member(grp_id, userid) 211 | if ( 212 | st.status != "administrator" 213 | and st.status != "creator" 214 | and str(userid) not in ADMINS 215 | ): 216 | return 217 | 218 | try: 219 | cmd, text = message.text.split(" ", 1) 220 | except: 221 | await message.reply_text( 222 | "Mention the filtername which you wanna delete!\n\n" 223 | "/del filtername\n\n" 224 | "Use /viewfilters to view all available filters", 225 | quote=True 226 | ) 227 | return 228 | 229 | query = text.lower() 230 | 231 | await delete_filter(message, query, grp_id) 232 | 233 | 234 | @Client.on_message(filters.command('delall') & filters.incoming) 235 | async def delallconfirm(client, message): 236 | userid = message.from_user.id if message.from_user else None 237 | if not userid: 238 | return await message.reply(f"You are anonymous admin. Use /connect {message.chat.id} in PM") 239 | chat_type = message.chat.type 240 | 241 | if chat_type == "private": 242 | grpid = await active_connection(str(userid)) 243 | if grpid is not None: 244 | grp_id = grpid 245 | try: 246 | chat = await client.get_chat(grpid) 247 | title = chat.title 248 | except: 249 | await message.reply_text("Make sure I'm present in your group!!", quote=True) 250 | return 251 | else: 252 | await message.reply_text("I'm not connected to any groups!", quote=True) 253 | return 254 | 255 | elif chat_type in ["group", "supergroup"]: 256 | grp_id = message.chat.id 257 | title = message.chat.title 258 | 259 | else: 260 | return 261 | 262 | st = await client.get_chat_member(grp_id, userid) 263 | if (st.status == "creator") or (str(userid) in ADMINS): 264 | await message.reply_text( 265 | f"This will delete all filters from '{title}'.\nDo you want to continue??", 266 | reply_markup=InlineKeyboardMarkup([ 267 | [InlineKeyboardButton(text="YES",callback_data="delallconfirm")], 268 | [InlineKeyboardButton(text="CANCEL",callback_data="delallcancel")] 269 | ]), 270 | quote=True 271 | ) 272 | 273 | -------------------------------------------------------------------------------- /image/edit_1.py: -------------------------------------------------------------------------------- 1 | from PIL import Image, ImageEnhance, ImageFilter 2 | import shutil 3 | import cv2 4 | import os 5 | 6 | 7 | async def bright(client, message): 8 | try: 9 | userid = str(message.chat.id) 10 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 11 | os.makedirs(f"./DOWNLOADS/{userid}") 12 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 13 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "brightness.jpg" 14 | if not message.reply_to_message.empty: 15 | msg = await message.reply_to_message.reply_text( 16 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 17 | ) 18 | a = await client.download_media( 19 | message=message.reply_to_message, file_name=download_location 20 | ) 21 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 22 | image = Image.open(a) 23 | brightness = ImageEnhance.Brightness(image) 24 | brightness.enhance(1.5).save(edit_img_loc) 25 | await message.reply_chat_action("upload_photo") 26 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 27 | await msg.delete() 28 | else: 29 | await message.reply_text("Why did you delete that??") 30 | try: 31 | shutil.rmtree(f"./DOWNLOADS/{userid}") 32 | except Exception: 33 | pass 34 | except Exception as e: 35 | print("bright-error - " + str(e)) 36 | if "USER_IS_BLOCKED" in str(e): 37 | return 38 | else: 39 | try: 40 | await message.reply_to_message.reply_text( 41 | "Something went wrong!", quote=True 42 | ) 43 | except Exception: 44 | return 45 | 46 | 47 | async def mix(client, message): 48 | try: 49 | userid = str(message.chat.id) 50 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 51 | os.makedirs(f"./DOWNLOADS/{userid}") 52 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 53 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "mix.jpg" 54 | if not message.reply_to_message.empty: 55 | msg = await message.reply_to_message.reply_text( 56 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 57 | ) 58 | a = await client.download_media( 59 | message=message.reply_to_message, file_name=download_location 60 | ) 61 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 62 | image = Image.open(a) 63 | red, green, blue = image.split() 64 | new_image = Image.merge("RGB", (green, red, blue)) 65 | new_image.save(edit_img_loc) 66 | await message.reply_chat_action("upload_photo") 67 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 68 | await msg.delete() 69 | else: 70 | await message.reply_text("Why did you delete that??") 71 | try: 72 | shutil.rmtree(f"./DOWNLOADS/{userid}") 73 | except Exception: 74 | pass 75 | except Exception as e: 76 | print("mix-error - " + str(e)) 77 | if "USER_IS_BLOCKED" in str(e): 78 | return 79 | else: 80 | try: 81 | await message.reply_to_message.reply_text( 82 | "Something went wrong!", quote=True 83 | ) 84 | except Exception: 85 | return 86 | 87 | 88 | async def black_white(client, message): 89 | try: 90 | userid = str(message.chat.id) 91 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 92 | os.makedirs(f"./DOWNLOADS/{userid}") 93 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 94 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "black_white.jpg" 95 | if not message.reply_to_message.empty: 96 | msg = await message.reply_to_message.reply_text( 97 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 98 | ) 99 | a = await client.download_media( 100 | message=message.reply_to_message, file_name=download_location 101 | ) 102 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 103 | image_file = cv2.imread(a) 104 | grayImage = cv2.cvtColor(image_file, cv2.COLOR_BGR2GRAY) 105 | cv2.imwrite(edit_img_loc, grayImage) 106 | await message.reply_chat_action("upload_photo") 107 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 108 | await msg.delete() 109 | else: 110 | await message.reply_text("Why did you delete that??") 111 | try: 112 | shutil.rmtree(f"./DOWNLOADS/{userid}") 113 | except Exception: 114 | pass 115 | except Exception as e: 116 | print("black_white-error - " + str(e)) 117 | if "USER_IS_BLOCKED" in str(e): 118 | return 119 | else: 120 | try: 121 | await message.reply_to_message.reply_text( 122 | "Something went wrong!", quote=True 123 | ) 124 | except Exception: 125 | return 126 | 127 | 128 | async def normal_blur(client, message): 129 | try: 130 | userid = str(message.chat.id) 131 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 132 | os.makedirs(f"./DOWNLOADS/{userid}") 133 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 134 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "BlurImage.jpg" 135 | if not message.reply_to_message.empty: 136 | msg = await message.reply_to_message.reply_text( 137 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 138 | ) 139 | a = await client.download_media( 140 | message=message.reply_to_message, file_name=download_location 141 | ) 142 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 143 | OriImage = Image.open(a) 144 | blurImage = OriImage.filter(ImageFilter.BLUR) 145 | blurImage.save(edit_img_loc) 146 | await message.reply_chat_action("upload_photo") 147 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 148 | await msg.delete() 149 | else: 150 | await message.reply_text("Why did you delete that??") 151 | try: 152 | shutil.rmtree(f"./DOWNLOADS/{userid}") 153 | except Exception: 154 | pass 155 | except Exception as e: 156 | print("normal_blur-error - " + str(e)) 157 | if "USER_IS_BLOCKED" in str(e): 158 | return 159 | else: 160 | try: 161 | await message.reply_to_message.reply_text( 162 | "Something went wrong!", quote=True 163 | ) 164 | except Exception: 165 | return 166 | 167 | 168 | async def g_blur(client, message): 169 | try: 170 | userid = str(message.chat.id) 171 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 172 | os.makedirs(f"./DOWNLOADS/{userid}") 173 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 174 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "gaussian_blur.jpg" 175 | if not message.reply_to_message.empty: 176 | msg = await message.reply_to_message.reply_text( 177 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 178 | ) 179 | a = await client.download_media( 180 | message=message.reply_to_message, file_name=download_location 181 | ) 182 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 183 | im1 = Image.open(a) 184 | im2 = im1.filter(ImageFilter.GaussianBlur(radius=5)) 185 | im2.save(edit_img_loc) 186 | await message.reply_chat_action("upload_photo") 187 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 188 | await msg.delete() 189 | else: 190 | await message.reply_text("Why did you delete that??") 191 | try: 192 | shutil.rmtree(f"./DOWNLOADS/{userid}") 193 | except Exception: 194 | pass 195 | except Exception as e: 196 | print("g_blur-error - " + str(e)) 197 | if "USER_IS_BLOCKED" in str(e): 198 | return 199 | else: 200 | try: 201 | await message.reply_to_message.reply_text( 202 | "Something went wrong!", quote=True 203 | ) 204 | except Exception: 205 | return 206 | 207 | 208 | async def box_blur(client, message): 209 | try: 210 | userid = str(message.chat.id) 211 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 212 | os.makedirs(f"./DOWNLOADS/{userid}") 213 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 214 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "box_blur.jpg" 215 | if not message.reply_to_message.empty: 216 | msg = await message.reply_to_message.reply_text( 217 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 218 | ) 219 | a = await client.download_media( 220 | message=message.reply_to_message, file_name=download_location 221 | ) 222 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 223 | im1 = Image.open(a) 224 | im2 = im1.filter(ImageFilter.BoxBlur(0)) 225 | im2.save(edit_img_loc) 226 | await message.reply_chat_action("upload_photo") 227 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 228 | await msg.delete() 229 | else: 230 | await message.reply_text("Why did you delete that??") 231 | try: 232 | shutil.rmtree(f"./DOWNLOADS/{userid}") 233 | except Exception: 234 | pass 235 | except Exception as e: 236 | print("box_blur-error - " + str(e)) 237 | if "USER_IS_BLOCKED" in str(e): 238 | return 239 | else: 240 | try: 241 | await message.reply_to_message.reply_text( 242 | "Something went wrong!", quote=True 243 | ) 244 | except Exception: 245 | return 246 | -------------------------------------------------------------------------------- /plugins/p_ttishow.py: -------------------------------------------------------------------------------- 1 | from pyrogram import Client, filters 2 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 3 | from pyrogram.errors.exceptions.bad_request_400 import MessageTooLong, PeerIdInvalid 4 | from info import ADMINS, LOG_CHANNEL, SUPPORT_CHAT 5 | from database.users_chats_db import db 6 | from database.ia_filterdb import Media 7 | from utils import get_size, temp 8 | from Script import script 9 | from pyrogram.errors import ChatAdminRequired 10 | 11 | """-----------------------------------------https://t.me/GetTGLink/4179 --------------------------------------""" 12 | 13 | @Client.on_message(filters.new_chat_members & filters.group) 14 | async def save_group(bot, message): 15 | r_j_check = [u.id for u in message.new_chat_members] 16 | if temp.ME in r_j_check: 17 | if not await db.get_chat(message.chat.id): 18 | total=await bot.get_chat_members_count(message.chat.id) 19 | r_j = message.from_user.mention if message.from_user else "Anonymous" 20 | await bot.send_message(LOG_CHANNEL, script.LOG_TEXT_G.format(message.chat.title, message.chat.id, total, r_j)) 21 | await db.add_chat(message.chat.id, message.chat.title) 22 | if message.chat.id in temp.BANNED_CHATS: 23 | # Inspired from a boat of a banana tree 24 | buttons = [[ 25 | InlineKeyboardButton('𝚂𝚄𝙿𝙿𝙾𝚁𝚃', url=f'https://t.me/{SUPPORT_CHAT}') 26 | ]] 27 | reply_markup=InlineKeyboardMarkup(buttons) 28 | k = await message.reply( 29 | text='CHAT NOT ALLOWED 🐞\n\n𝙼𝚈 𝙰𝙳𝙼𝙸𝙽𝚂 𝙷𝙰𝚂 𝚁𝙴𝚂𝚃𝚁𝙸𝙲𝚃𝙴𝙳 𝙼𝙴 𝙵𝚁𝙾𝙼 𝚆𝙾𝚁𝙺𝙸𝙽𝙶 𝙷𝙴𝚁𝙴 !𝙸𝙵 𝚈𝙾𝚄 𝚆𝙰𝙽𝚃 𝚃𝙾 𝙺𝙽𝙾𝚆 𝙼𝙾𝚁𝙴 𝙰𝙱𝙾𝚄𝚃 𝙸𝚃 𝙲𝙾𝙽𝚃𝙰𝙲𝚃 𝙾𝚆𝙽𝙴𝚁...', 30 | reply_markup=reply_markup, 31 | ) 32 | 33 | try: 34 | await k.pin() 35 | except: 36 | pass 37 | await bot.leave_chat(message.chat.id) 38 | return 39 | buttons = [ 40 | [ 41 | InlineKeyboardButton('𝙷𝙾𝚆 𝚃𝙾 𝚄𝚂𝙴 𝙼𝙴', url=f"https://t.me/{temp.U_NAME}?start=help") 42 | ] 43 | ] 44 | reply_markup=InlineKeyboardMarkup(buttons) 45 | await message.reply_text( 46 | text=f"›› 𝚃𝙷𝙰𝙽𝙺𝚂 𝚃𝙾 𝙰𝙳𝙳 𝙼𝙴 𝚃𝙾 𝚈𝙾𝚄𝚁 𝙶𝚁𝙾𝚄𝙿.\n›› 𝙳𝙾𝙽'𝚃 𝙵𝙾𝚁𝙶𝙴𝚃 𝚃𝙾 𝙼𝙰𝙺𝙴 𝙼𝙴 𝙰𝙳𝙼𝙸𝙽.\n›› 𝙸𝚂 𝙰𝙽𝚈 𝙳𝙾𝚄𝙱𝚃𝚂 𝙰𝙱𝙾𝚄𝚃 𝚄𝚂𝙸𝙽𝙶 𝙼𝙴 𝙲𝙻𝙸𝙲𝙺 𝙱𝙴𝙻𝙾𝚆 𝙱𝚄𝚃𝚃𝙾𝙽..⚡⚡.", 47 | reply_markup=reply_markup) 48 | else: 49 | for u in message.new_chat_members: 50 | if (temp.MELCOW).get('welcome') is not None: 51 | try: 52 | await (temp.MELCOW['welcome']).delete() 53 | except: 54 | pass 55 | temp.MELCOW['welcome'] = await message.reply(f"Hey ♥️ {u.mention}, Welcome to {message.chat.title}.../") 56 | 57 | 58 | @Client.on_message(filters.command('leave') & filters.user(ADMINS)) 59 | async def leave_a_chat(bot, message): 60 | if len(message.command) == 1: 61 | return await message.reply('Give me a chat id') 62 | chat = message.command[1] 63 | try: 64 | chat = int(chat) 65 | except: 66 | chat = chat 67 | try: 68 | buttons = [[ 69 | InlineKeyboardButton('𝚂𝚄𝙿𝙿𝙾𝚁𝚃', url=f'https://t.me/{SUPPORT_CHAT}') 70 | ]] 71 | reply_markup=InlineKeyboardMarkup(buttons) 72 | await bot.send_message( 73 | chat_id=chat, 74 | text='Hello Friends, \nMy admin has told me to leave from group so i go! If you wanna add me again contact my support group.', 75 | reply_markup=reply_markup, 76 | ) 77 | 78 | await bot.leave_chat(chat) 79 | except Exception as e: 80 | await message.reply(f'Error - {e}') 81 | 82 | @Client.on_message(filters.command('disable') & filters.user(ADMINS)) 83 | async def disable_chat(bot, message): 84 | if len(message.command) == 1: 85 | return await message.reply('Give me a chat id') 86 | r = message.text.split(None) 87 | if len(r) > 2: 88 | reason = message.text.split(None, 2)[2] 89 | chat = message.text.split(None, 2)[1] 90 | else: 91 | chat = message.command[1] 92 | reason = "No reason Provided" 93 | try: 94 | chat_ = int(chat) 95 | except: 96 | return await message.reply('Give Me A Valid Chat ID') 97 | cha_t = await db.get_chat(int(chat_)) 98 | if not cha_t: 99 | return await message.reply("Chat Not Found In DB") 100 | if cha_t['is_disabled']: 101 | return await message.reply(f"This chat is already disabled:\nReason- {cha_t['reason']} ") 102 | await db.disable_chat(int(chat_), reason) 103 | temp.BANNED_CHATS.append(int(chat_)) 104 | await message.reply('Chat Succesfully Disabled') 105 | try: 106 | buttons = [[ 107 | InlineKeyboardButton('𝚂𝚄𝙿𝙿𝙾𝚁𝚃', url=f'https://t.me/{SUPPORT_CHAT}') 108 | ]] 109 | reply_markup=InlineKeyboardMarkup(buttons) 110 | await bot.send_message( 111 | chat_id=chat_, 112 | text=f'Hello Friends, \nMy admin has told me to leave from group so i go! If you wanna add me again contact my support group. \nReason : {reason}', 113 | reply_markup=reply_markup) 114 | await bot.leave_chat(chat_) 115 | except Exception as e: 116 | await message.reply(f"Error - {e}") 117 | 118 | 119 | @Client.on_message(filters.command('enable') & filters.user(ADMINS)) 120 | async def re_enable_chat(bot, message): 121 | if len(message.command) == 1: 122 | return await message.reply('Give me a chat id') 123 | chat = message.command[1] 124 | try: 125 | chat_ = int(chat) 126 | except: 127 | return await message.reply('Give Me A Valid Chat ID') 128 | sts = await db.get_chat(int(chat)) 129 | if not sts: 130 | return await message.reply("Chat Not Found In DB !") 131 | if not sts.get('is_disabled'): 132 | return await message.reply('This chat is not yet disabled.') 133 | await db.re_enable_chat(int(chat_)) 134 | temp.BANNED_CHATS.remove(int(chat_)) 135 | await message.reply("Chat Succesfully re-enabled") 136 | 137 | 138 | @Client.on_message(filters.command('stats') & filters.incoming) 139 | async def get_ststs(bot, message): 140 | rju = await message.reply('𝙰𝙲𝙲𝙴𝚂𝚂𝙸𝙽𝙶 𝚂𝚃𝙰𝚃𝚄𝚂 𝙳𝙴𝚃𝙰𝙸𝙻𝚂...') 141 | total_users = await db.total_users_count() 142 | totl_chats = await db.total_chat_count() 143 | files = await Media.count_documents() 144 | size = await db.get_db_size() 145 | free = 536870912 - size 146 | size = get_size(size) 147 | free = get_size(free) 148 | await rju.edit(script.STATUS_TXT.format(files, total_users, totl_chats, size, free)) 149 | 150 | 151 | # a function for trespassing into others groups, Inspired by a Vazha 152 | # Not to be used , But Just to showcase his vazhatharam. 153 | # @Client.on_message(filters.command('invite') & filters.user(ADMINS)) 154 | async def gen_invite(bot, message): 155 | if len(message.command) == 1: 156 | return await message.reply('Give me a chat id') 157 | chat = message.command[1] 158 | try: 159 | chat = int(chat) 160 | except: 161 | return await message.reply('Give Me A Valid Chat ID') 162 | try: 163 | link = await bot.create_chat_invite_link(chat) 164 | except ChatAdminRequired: 165 | return await message.reply("Invite Link Generation Failed, Iam Not Having Sufficient Rights") 166 | except Exception as e: 167 | return await message.reply(f'Error {e}') 168 | await message.reply(f'Here is your Invite Link {link.invite_link}') 169 | 170 | @Client.on_message(filters.command('ban_user') & filters.user(ADMINS)) 171 | async def ban_a_user(bot, message): 172 | # https://t.me/GetTGLink/4185 173 | if len(message.command) == 1: 174 | return await message.reply('Give me a user id / username') 175 | r = message.text.split(None) 176 | if len(r) > 2: 177 | reason = message.text.split(None, 2)[2] 178 | chat = message.text.split(None, 2)[1] 179 | else: 180 | chat = message.command[1] 181 | reason = "No reason Provided" 182 | try: 183 | chat = int(chat) 184 | except: 185 | pass 186 | try: 187 | k = await bot.get_users(chat) 188 | except PeerIdInvalid: 189 | return await message.reply("This is an invalid user, make sure ia have met him before.") 190 | except IndexError: 191 | return await message.reply("This might be a channel, make sure its a user.") 192 | except Exception as e: 193 | return await message.reply(f'Error - {e}') 194 | else: 195 | jar = await db.get_ban_status(k.id) 196 | if jar['is_banned']: 197 | return await message.reply(f"{k.mention} is already banned\nReason: {jar['ban_reason']}") 198 | await db.ban_user(k.id, reason) 199 | temp.BANNED_USERS.append(k.id) 200 | await message.reply(f"Succesfully banned {k.mention}") 201 | 202 | 203 | 204 | @Client.on_message(filters.command('unban_user') & filters.user(ADMINS)) 205 | async def unban_a_user(bot, message): 206 | if len(message.command) == 1: 207 | return await message.reply('Give me a user id / username') 208 | r = message.text.split(None) 209 | if len(r) > 2: 210 | reason = message.text.split(None, 2)[2] 211 | chat = message.text.split(None, 2)[1] 212 | else: 213 | chat = message.command[1] 214 | reason = "No reason Provided" 215 | try: 216 | chat = int(chat) 217 | except: 218 | pass 219 | try: 220 | k = await bot.get_users(chat) 221 | except PeerIdInvalid: 222 | return await message.reply("This is an invalid user, make sure ia have met him before.") 223 | except IndexError: 224 | return await message.reply("Thismight be a channel, make sure its a user.") 225 | except Exception as e: 226 | return await message.reply(f'Error - {e}') 227 | else: 228 | jar = await db.get_ban_status(k.id) 229 | if not jar['is_banned']: 230 | return await message.reply(f"{k.mention} is not yet banned.") 231 | await db.remove_ban(k.id) 232 | temp.BANNED_USERS.remove(k.id) 233 | await message.reply(f"Succesfully unbanned {k.mention}") 234 | 235 | 236 | 237 | @Client.on_message(filters.command('users') & filters.user(ADMINS)) 238 | async def list_users(bot, message): 239 | # https://t.me/GetTGLink/4184 240 | raju = await message.reply('Getting List Of Users') 241 | users = await db.get_all_users() 242 | out = "Users Saved In DB Are:\n\n" 243 | async for user in users: 244 | out += f"{user['name']}\n" 245 | try: 246 | await raju.edit_text(out) 247 | except MessageTooLong: 248 | with open('users.txt', 'w+') as outfile: 249 | outfile.write(out) 250 | await message.reply_document('users.txt', caption="List Of Users") 251 | 252 | @Client.on_message(filters.command('chats') & filters.user(ADMINS)) 253 | async def list_chats(bot, message): 254 | raju = await message.reply('Getting List Of chats') 255 | chats = await db.get_all_chats() 256 | out = "Chats Saved In DB Are:\n\n" 257 | async for chat in chats: 258 | out += f"**Title:** `{chat['title']}`\n**- ID:** `{chat['id']}`\n" 259 | try: 260 | await raju.edit_text(out) 261 | except MessageTooLong: 262 | with open('chats.txt', 'w+') as outfile: 263 | outfile.write(out) 264 | await message.reply_document('chats.txt', caption="List Of Chats") 265 | -------------------------------------------------------------------------------- /plugins/misc.py: -------------------------------------------------------------------------------- 1 | import os 2 | from pyrogram import Client, filters 3 | from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant, MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty 4 | from Script import script 5 | from info import PICS 6 | from info import IMDB_TEMPLATE 7 | from utils import extract_user, get_file_id, get_poster, last_online 8 | import time 9 | import random 10 | from datetime import datetime 11 | from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery 12 | import logging 13 | logger = logging.getLogger(__name__) 14 | logger.setLevel(logging.ERROR) 15 | 16 | @Client.on_message(filters.command('id')) 17 | async def showid(client, message): 18 | chat_type = message.chat.type 19 | if chat_type == "private": 20 | user_id = message.chat.id 21 | first = message.from_user.first_name 22 | last = message.from_user.last_name or "" 23 | username = message.from_user.username 24 | dc_id = message.from_user.dc_id or "" 25 | await message.reply_text( 26 | f"➪ First Name: {first}\n➪ Last Name: {last}\n➪ Username: {username}\n➪ Telegram ID: {user_id}\n➪ Data Centre: {dc_id}", 27 | quote=True 28 | ) 29 | 30 | elif chat_type in ["group", "supergroup"]: 31 | _id = "" 32 | _id += ( 33 | "➛ Chat ID: " 34 | f"{message.chat.id}\n" 35 | ) 36 | if message.reply_to_message: 37 | _id += ( 38 | "➛ User ID: " 39 | f"{message.from_user.id if message.from_user else 'Anonymous'}\n" 40 | "➛ Replied User ID: " 41 | f"{message.reply_to_message.from_user.id if message.reply_to_message.from_user else 'Anonymous'}\n" 42 | ) 43 | file_info = get_file_id(message.reply_to_message) 44 | else: 45 | _id += ( 46 | "➛ User ID: " 47 | f"{message.from_user.id if message.from_user else 'Anonymous'}\n" 48 | ) 49 | file_info = get_file_id(message) 50 | if file_info: 51 | _id += ( 52 | f"{file_info.message_type}: " 53 | f"{file_info.file_id}\n" 54 | ) 55 | await message.reply_text( 56 | _id, 57 | quote=True 58 | ) 59 | 60 | @Client.on_message(filters.command("about")) 61 | async def aboutme(client, message): 62 | buttons= [[ 63 | InlineKeyboardButton('♥️ 𝙳𝙴𝙿𝙻𝙾𝚈 𝚃𝚄𝚃𝙾𝚁𝙸𝙰𝙻 ♥️', url='https://youtu.be/kB9TkCs8cX0') 64 | ],[ 65 | InlineKeyboardButton('🏠 𝙷𝙾𝙼𝙴 🏠', callback_data='start'), 66 | InlineKeyboardButton('🔐 𝙲𝙻𝙾𝚂𝙴 🔐', callback_data='close_data') 67 | ]] 68 | reply_markup = InlineKeyboardMarkup(buttons) 69 | await message.reply_photo( 70 | photo=random.choice(PICS), 71 | caption=script.ABOUT_TXT.format(message.from_user.mention), 72 | reply_markup=reply_markup, 73 | parse_mode='html' 74 | ) 75 | 76 | @Client.on_message(filters.command(["info"])) 77 | async def who_is(client, message): 78 | # https://github.com/SpEcHiDe/PyroGramBot/blob/master/pyrobot/plugins/admemes/whois.py#L19 79 | status_message = await message.reply_text( 80 | "`𝚂𝙴𝙰𝚁𝙲𝙷𝙸𝙽𝙶 𝚄𝚂𝙴𝚁...`" 81 | ) 82 | await status_message.edit( 83 | "`𝙰𝙲𝙲𝙴𝚂𝚂𝙸𝙽𝙶 𝙸𝙽𝙵𝙾𝚁𝙼𝙰𝚃𝙸𝙾𝙽...`" 84 | ) 85 | from_user = None 86 | from_user_id, _ = extract_user(message) 87 | try: 88 | from_user = await client.get_users(from_user_id) 89 | except Exception as error: 90 | await status_message.edit(str(error)) 91 | return 92 | if from_user is None: 93 | return await status_message.edit("no valid user_id / message specified") 94 | message_out_str = "" 95 | message_out_str += f"➾ First Name: {from_user.first_name}\n" 96 | last_name = from_user.last_name or "None" 97 | message_out_str += f"➾ Last Name: {last_name}\n" 98 | message_out_str += f"➾ Telegram ID: {from_user.id}\n" 99 | username = from_user.username or "None" 100 | dc_id = from_user.dc_id or "[User Doesnt Have A Valid DP]" 101 | message_out_str += f"➾ Data Centre: {dc_id}\n" 102 | message_out_str += f"➾ User Name: @{username}\n" 103 | message_out_str += f"➾ User 𝖫𝗂𝗇𝗄: Click Here\n" 104 | if message.chat.type in (("supergroup", "channel")): 105 | try: 106 | chat_member_p = await message.chat.get_member(from_user.id) 107 | joined_date = datetime.fromtimestamp( 108 | chat_member_p.joined_date or time.time() 109 | ).strftime("%Y.%m.%d %H:%M:%S") 110 | message_out_str += ( 111 | "➾ Joined this Chat on: " 112 | f"{joined_date}" 113 | "\n" 114 | ) 115 | except UserNotParticipant: 116 | pass 117 | chat_photo = from_user.photo 118 | if chat_photo: 119 | local_user_photo = await client.download_media( 120 | message=chat_photo.big_file_id 121 | ) 122 | buttons = [[ 123 | InlineKeyboardButton('🔐 Close', callback_data='close_data') 124 | ]] 125 | reply_markup = InlineKeyboardMarkup(buttons) 126 | await message.reply_photo( 127 | photo=local_user_photo, 128 | quote=True, 129 | reply_markup=reply_markup, 130 | caption=message_out_str, 131 | parse_mode="html", 132 | disable_notification=True 133 | ) 134 | os.remove(local_user_photo) 135 | else: 136 | buttons = [[ 137 | InlineKeyboardButton('🔐 Close', callback_data='close_data') 138 | ]] 139 | reply_markup = InlineKeyboardMarkup(buttons) 140 | await message.reply_text( 141 | text=message_out_str, 142 | reply_markup=reply_markup, 143 | quote=True, 144 | parse_mode="html", 145 | disable_notification=True 146 | ) 147 | await status_message.delete() 148 | 149 | @Client.on_message(filters.command("help")) 150 | async def help(client, message): 151 | buttons = [[ 152 | InlineKeyboardButton('𝙼𝙰𝙽𝚄𝙴𝙻 𝙵𝙸𝙻𝚃𝙴𝚁', callback_data='manuelfilter'), 153 | InlineKeyboardButton('𝙰𝚄𝚃𝙾 𝙵𝙸𝙻𝚃𝙴𝚁', callback_data='autofilter'), 154 | InlineKeyboardButton('𝙲𝙾𝙽𝙽𝙴𝙲𝚃𝙸𝙾𝙽𝚂', callback_data='coct') 155 | ],[ 156 | InlineKeyboardButton('𝚂𝙾𝙽𝙶', callback_data='songs'), 157 | InlineKeyboardButton('𝙴𝚇𝚃𝚁𝙰', callback_data='extra'), 158 | InlineKeyboardButton("𝚅𝙸𝙳𝙴𝙾", callback_data='video') 159 | ],[ 160 | InlineKeyboardButton('𝙿𝙸𝙽', callback_data='pin'), 161 | InlineKeyboardButton('𝙿𝙰𝚂𝚃𝙴', callback_data='pastes'), 162 | InlineKeyboardButton("𝙸𝙼𝙰𝙶𝙴", callback_data='image') 163 | ],[ 164 | InlineKeyboardButton('𝙵𝚄𝙽', callback_data='fun'), 165 | InlineKeyboardButton('𝙹𝚂𝙾𝙽𝙴', callback_data='son'), 166 | InlineKeyboardButton('𝚃𝚃𝚂', callback_data='ttss') 167 | ],[ 168 | InlineKeyboardButton('𝙿𝚄𝚁𝙶𝙴', callback_data='purges'), 169 | InlineKeyboardButton('𝙿𝙸𝙽𝙶', callback_data='pings'), 170 | InlineKeyboardButton('𝚃𝙴𝙻𝙴𝙶𝚁𝙰𝙿𝙷', callback_data='tele') 171 | ],[ 172 | InlineKeyboardButton('𝚆𝙷𝙾𝙸𝚂', callback_data='whois'), 173 | InlineKeyboardButton('𝙼𝚄𝚃𝙴', callback_data='restric'), 174 | InlineKeyboardButton('𝙺𝙸𝙲𝙺', callback_data='zombies') 175 | ],[ 176 | InlineKeyboardButton('𝚁𝙴𝙿𝙾𝚁𝚃', callback_data='report'), 177 | InlineKeyboardButton('𝚈𝚃-𝚃𝙷𝚄𝙼𝙱', callback_data='ytthumb'), 178 | InlineKeyboardButton('𝚂𝚃𝙸𝙲𝙺𝙴𝚁-𝙸𝙳', callback_data='sticker') 179 | ],[ 180 | InlineKeyboardButton('𝙲𝙾𝚅𝙸𝙳', callback_data='corona'), 181 | InlineKeyboardButton('𝙰𝚄𝙳𝙸𝙾-𝙱𝙾𝙾𝙺', callback_data='abook'), 182 | InlineKeyboardButton('𝚄𝚁𝙻-𝚂𝙷𝙾𝚁𝚃', callback_data='urlshort') 183 | ],[ 184 | InlineKeyboardButton('𝙶-𝚃𝚁𝙰𝙽𝚂', callback_data='gtrans'), 185 | InlineKeyboardButton('𝙵𝙸𝙻𝙴-𝚂𝚃𝙾𝚁𝙴', callback_data='newdata'), 186 | InlineKeyboardButton('𝚂𝚃𝙰𝚃𝚄𝚂', callback_data='stats') 187 | ]] 188 | reply_markup = InlineKeyboardMarkup(buttons) 189 | await message.reply_photo( 190 | photo=random.choice(PICS), 191 | caption=script.HELP_TXT.format(message.from_user.mention), 192 | reply_markup=reply_markup, 193 | parse_mode='html' 194 | ) 195 | 196 | 197 | @Client.on_message(filters.command(["imdb", 'search'])) 198 | async def imdb_search(client, message): 199 | if ' ' in message.text: 200 | k = await message.reply('Searching ImDB') 201 | r, title = message.text.split(None, 1) 202 | movies = await get_poster(title, bulk=True) 203 | if not movies: 204 | return await message.reply("No results Found") 205 | btn = [ 206 | [ 207 | InlineKeyboardButton( 208 | text=f"{movie.get('title')} - {movie.get('year')}", 209 | callback_data=f"imdb#{movie.movieID}", 210 | ) 211 | ] 212 | for movie in movies 213 | ] 214 | await k.edit('Here is what i found on IMDb', reply_markup=InlineKeyboardMarkup(btn)) 215 | else: 216 | await message.reply('Give me a movie / series Name') 217 | 218 | @Client.on_callback_query(filters.regex('^imdb')) 219 | async def imdb_callback(bot: Client, quer_y: CallbackQuery): 220 | i, movie = quer_y.data.split('#') 221 | imdb = await get_poster(query=movie, id=True) 222 | btn = [ 223 | [ 224 | InlineKeyboardButton( 225 | text=f"{imdb.get('title')}", 226 | url=imdb['url'], 227 | ) 228 | ] 229 | ] 230 | message = quer_y.message.reply_to_message or quer_y.message 231 | if imdb: 232 | caption = IMDB_TEMPLATE.format( 233 | query = imdb['title'], 234 | title = imdb['title'], 235 | votes = imdb['votes'], 236 | aka = imdb["aka"], 237 | seasons = imdb["seasons"], 238 | box_office = imdb['box_office'], 239 | localized_title = imdb['localized_title'], 240 | kind = imdb['kind'], 241 | imdb_id = imdb["imdb_id"], 242 | cast = imdb["cast"], 243 | runtime = imdb["runtime"], 244 | countries = imdb["countries"], 245 | certificates = imdb["certificates"], 246 | languages = imdb["languages"], 247 | director = imdb["director"], 248 | writer = imdb["writer"], 249 | producer = imdb["producer"], 250 | composer = imdb["composer"], 251 | cinematographer = imdb["cinematographer"], 252 | music_team = imdb["music_team"], 253 | distributors = imdb["distributors"], 254 | release_date = imdb['release_date'], 255 | year = imdb['year'], 256 | genres = imdb['genres'], 257 | poster = imdb['poster'], 258 | plot = imdb['plot'], 259 | rating = imdb['rating'], 260 | url = imdb['url'], 261 | **locals() 262 | ) 263 | else: 264 | caption = "No Results" 265 | if imdb.get('poster'): 266 | try: 267 | await quer_y.message.reply_photo(photo=imdb['poster'], caption=caption, reply_markup=InlineKeyboardMarkup(btn)) 268 | except (MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty): 269 | pic = imdb.get('poster') 270 | poster = pic.replace('.jpg', "._V1_UX360.jpg") 271 | await quer_y.message.reply_photo(photo=poster, caption=caption, reply_markup=InlineKeyboardMarkup(btn)) 272 | except Exception as e: 273 | logger.exception(e) 274 | await quer_y.message.reply(caption, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=False) 275 | await quer_y.message.delete() 276 | else: 277 | await quer_y.message.edit(caption, reply_markup=InlineKeyboardMarkup(btn), disable_web_page_preview=False) 278 | await quer_y.answer() 279 | 280 | 281 | -------------------------------------------------------------------------------- /utils.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from pyrogram.errors import InputUserDeactivated, UserNotParticipant, FloodWait, UserIsBlocked, PeerIdInvalid 3 | from info import AUTH_CHANNEL, LONG_IMDB_DESCRIPTION, MAX_LIST_ELM 4 | from imdb import IMDb 5 | import asyncio 6 | from pyrogram.types import Message 7 | from typing import Union 8 | import re 9 | import os 10 | from datetime import datetime 11 | from typing import List 12 | from pyrogram.types import InlineKeyboardButton 13 | from database.users_chats_db import db 14 | from bs4 import BeautifulSoup 15 | import requests 16 | 17 | logger = logging.getLogger(__name__) 18 | logger.setLevel(logging.INFO) 19 | 20 | BTN_URL_REGEX = re.compile( 21 | r"(\[([^\[]+?)\]\((buttonurl|buttonalert):(?:/{0,2})(.+?)(:same)?\))" 22 | ) 23 | 24 | imdb = IMDb() 25 | 26 | BANNED = {} 27 | SMART_OPEN = '“' 28 | SMART_CLOSE = '”' 29 | START_CHAR = ('\'', '"', SMART_OPEN) 30 | 31 | # temp db for banned 32 | class temp(object): 33 | BANNED_USERS = [] 34 | BANNED_CHATS = [] 35 | ME = None 36 | CURRENT=int(os.environ.get("SKIP", 2)) 37 | CANCEL = False 38 | MELCOW = {} 39 | U_NAME = None 40 | B_NAME = None 41 | SETTINGS = {} 42 | 43 | async def is_subscribed(bot, query): 44 | try: 45 | user = await bot.get_chat_member(AUTH_CHANNEL, query.from_user.id) 46 | except UserNotParticipant: 47 | pass 48 | except Exception as e: 49 | logger.exception(e) 50 | else: 51 | if user.status != 'kicked': 52 | return True 53 | 54 | return False 55 | 56 | async def get_poster(query, bulk=False, id=False, file=None): 57 | if not id: 58 | # https://t.me/GetTGLink/4183 59 | query = (query.strip()).lower() 60 | title = query 61 | year = re.findall(r'[1-2]\d{3}$', query, re.IGNORECASE) 62 | if year: 63 | year = list_to_str(year[:1]) 64 | title = (query.replace(year, "")).strip() 65 | elif file is not None: 66 | year = re.findall(r'[1-2]\d{3}', file, re.IGNORECASE) 67 | if year: 68 | year = list_to_str(year[:1]) 69 | else: 70 | year = None 71 | movieid = imdb.search_movie(title.lower(), results=10) 72 | if not movieid: 73 | return None 74 | if year: 75 | filtered=list(filter(lambda k: str(k.get('year')) == str(year), movieid)) 76 | if not filtered: 77 | filtered = movieid 78 | else: 79 | filtered = movieid 80 | movieid=list(filter(lambda k: k.get('kind') in ['movie', 'tv series'], filtered)) 81 | if not movieid: 82 | movieid = filtered 83 | if bulk: 84 | return movieid 85 | movieid = movieid[0].movieID 86 | else: 87 | movieid = query 88 | movie = imdb.get_movie(movieid) 89 | if movie.get("original air date"): 90 | date = movie["original air date"] 91 | elif movie.get("year"): 92 | date = movie.get("year") 93 | else: 94 | date = "N/A" 95 | plot = "" 96 | if not LONG_IMDB_DESCRIPTION: 97 | plot = movie.get('plot') 98 | if plot and len(plot) > 0: 99 | plot = plot[0] 100 | else: 101 | plot = movie.get('plot outline') 102 | if plot and len(plot) > 800: 103 | plot = plot[0:800] + "..." 104 | 105 | return { 106 | 'title': movie.get('title'), 107 | 'votes': movie.get('votes'), 108 | "aka": list_to_str(movie.get("akas")), 109 | "seasons": movie.get("number of seasons"), 110 | "box_office": movie.get('box office'), 111 | 'localized_title': movie.get('localized title'), 112 | 'kind': movie.get("kind"), 113 | "imdb_id": f"tt{movie.get('imdbID')}", 114 | "cast": list_to_str(movie.get("cast")), 115 | "runtime": list_to_str(movie.get("runtimes")), 116 | "countries": list_to_str(movie.get("countries")), 117 | "certificates": list_to_str(movie.get("certificates")), 118 | "languages": list_to_str(movie.get("languages")), 119 | "director": list_to_str(movie.get("director")), 120 | "writer":list_to_str(movie.get("writer")), 121 | "producer":list_to_str(movie.get("producer")), 122 | "composer":list_to_str(movie.get("composer")) , 123 | "cinematographer":list_to_str(movie.get("cinematographer")), 124 | "music_team": list_to_str(movie.get("music department")), 125 | "distributors": list_to_str(movie.get("distributors")), 126 | 'release_date': date, 127 | 'year': movie.get('year'), 128 | 'genres': list_to_str(movie.get("genres")), 129 | 'poster': movie.get('full-size cover url'), 130 | 'plot': plot, 131 | 'rating': str(movie.get("rating")), 132 | 'url':f'https://www.imdb.com/title/tt{movieid}' 133 | } 134 | # https://github.com/odysseusmax/animated-lamp/blob/2ef4730eb2b5f0596ed6d03e7b05243d93e3415b/bot/utils/broadcast.py#L37 135 | 136 | async def broadcast_messages(user_id, message): 137 | try: 138 | await message.copy(chat_id=user_id) 139 | return True, "Success" 140 | except FloodWait as e: 141 | await asyncio.sleep(e.x) 142 | return await broadcast_messages(user_id, message) 143 | except InputUserDeactivated: 144 | await db.delete_user(int(user_id)) 145 | logging.info(f"{user_id}-Removed from Database, since deleted account.") 146 | return False, "Deleted" 147 | except UserIsBlocked: 148 | logging.info(f"{user_id} -Blocked the bot.") 149 | return False, "Blocked" 150 | except PeerIdInvalid: 151 | await db.delete_user(int(user_id)) 152 | logging.info(f"{user_id} - PeerIdInvalid") 153 | return False, "Error" 154 | except Exception as e: 155 | return False, "Error" 156 | 157 | async def search_gagala(text): 158 | usr_agent = { 159 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' 160 | 'Chrome/61.0.3163.100 Safari/537.36' 161 | } 162 | text = text.replace(" ", '+') 163 | url = f'https://www.google.com/search?q={text}' 164 | response = requests.get(url, headers=usr_agent) 165 | response.raise_for_status() 166 | soup = BeautifulSoup(response.text, 'html.parser') 167 | titles = soup.find_all( 'h3' ) 168 | return [title.getText() for title in titles] 169 | 170 | 171 | async def get_settings(group_id): 172 | settings = temp.SETTINGS.get(group_id) 173 | if not settings: 174 | settings = await db.get_settings(group_id) 175 | temp.SETTINGS[group_id] = settings 176 | return settings 177 | 178 | async def save_group_settings(group_id, key, value): 179 | current = await get_settings(group_id) 180 | current[key] = value 181 | temp.SETTINGS[group_id] = current 182 | await db.update_settings(group_id, current) 183 | 184 | def get_size(size): 185 | """Get size in readable format""" 186 | 187 | units = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB"] 188 | size = float(size) 189 | i = 0 190 | while size >= 1024.0 and i < len(units): 191 | i += 1 192 | size /= 1024.0 193 | return "%.2f %s" % (size, units[i]) 194 | 195 | def split_list(l, n): 196 | for i in range(0, len(l), n): 197 | yield l[i:i + n] 198 | 199 | def get_file_id(msg: Message): 200 | if msg.media: 201 | for message_type in ( 202 | "photo", 203 | "animation", 204 | "audio", 205 | "document", 206 | "video", 207 | "video_note", 208 | "voice", 209 | "sticker" 210 | ): 211 | obj = getattr(msg, message_type) 212 | if obj: 213 | setattr(obj, "message_type", message_type) 214 | return obj 215 | 216 | def extract_user(message: Message) -> Union[int, str]: 217 | """extracts the user from a message""" 218 | # https://github.com/SpEcHiDe/PyroGramBot/blob/f30e2cca12002121bad1982f68cd0ff9814ce027/pyrobot/helper_functions/extract_user.py#L7 219 | user_id = None 220 | user_first_name = None 221 | if message.reply_to_message: 222 | user_id = message.reply_to_message.from_user.id 223 | user_first_name = message.reply_to_message.from_user.first_name 224 | 225 | elif len(message.command) > 1: 226 | if ( 227 | len(message.entities) > 1 and 228 | message.entities[1].type == "text_mention" 229 | ): 230 | 231 | required_entity = message.entities[1] 232 | user_id = required_entity.user.id 233 | user_first_name = required_entity.user.first_name 234 | else: 235 | user_id = message.command[1] 236 | # don't want to make a request -_- 237 | user_first_name = user_id 238 | try: 239 | user_id = int(user_id) 240 | except ValueError: 241 | pass 242 | else: 243 | user_id = message.from_user.id 244 | user_first_name = message.from_user.first_name 245 | return (user_id, user_first_name) 246 | 247 | def list_to_str(k): 248 | if not k: 249 | return "N/A" 250 | elif len(k) == 1: 251 | return str(k[0]) 252 | elif MAX_LIST_ELM: 253 | k = k[:int(MAX_LIST_ELM)] 254 | return ' '.join(f'{elem}, ' for elem in k) 255 | else: 256 | return ' '.join(f'{elem}, ' for elem in k) 257 | 258 | def last_online(from_user): 259 | time = "" 260 | if from_user.is_bot: 261 | time += "🤖 Bot :(" 262 | elif from_user.status == 'recently': 263 | time += "Recently" 264 | elif from_user.status == 'within_week': 265 | time += "Within the last week" 266 | elif from_user.status == 'within_month': 267 | time += "Within the last month" 268 | elif from_user.status == 'long_time_ago': 269 | time += "A long time ago :(" 270 | elif from_user.status == 'online': 271 | time += "Currently Online" 272 | elif from_user.status == 'offline': 273 | time += datetime.fromtimestamp(from_user.last_online_date).strftime("%a, %d %b %Y, %H:%M:%S") 274 | return time 275 | 276 | 277 | def split_quotes(text: str) -> List: 278 | if not any(text.startswith(char) for char in START_CHAR): 279 | return text.split(None, 1) 280 | counter = 1 # ignore first char -> is some kind of quote 281 | while counter < len(text): 282 | if text[counter] == "\\": 283 | counter += 1 284 | elif text[counter] == text[0] or (text[0] == SMART_OPEN and text[counter] == SMART_CLOSE): 285 | break 286 | counter += 1 287 | else: 288 | return text.split(None, 1) 289 | 290 | # 1 to avoid starting quote, and counter is exclusive so avoids ending 291 | key = remove_escapes(text[1:counter].strip()) 292 | # index will be in range, or `else` would have been executed and returned 293 | rest = text[counter + 1:].strip() 294 | if not key: 295 | key = text[0] + text[0] 296 | return list(filter(None, [key, rest])) 297 | 298 | def parser(text, keyword): 299 | if "buttonalert" in text: 300 | text = (text.replace("\n", "\\n").replace("\t", "\\t")) 301 | buttons = [] 302 | note_data = "" 303 | prev = 0 304 | i = 0 305 | alerts = [] 306 | for match in BTN_URL_REGEX.finditer(text): 307 | # Check if btnurl is escaped 308 | n_escapes = 0 309 | to_check = match.start(1) - 1 310 | while to_check > 0 and text[to_check] == "\\": 311 | n_escapes += 1 312 | to_check -= 1 313 | 314 | # if even, not escaped -> create button 315 | if n_escapes % 2 == 0: 316 | note_data += text[prev:match.start(1)] 317 | prev = match.end(1) 318 | if match.group(3) == "buttonalert": 319 | # create a thruple with button label, url, and newline status 320 | if bool(match.group(5)) and buttons: 321 | buttons[-1].append(InlineKeyboardButton( 322 | text=match.group(2), 323 | callback_data=f"alertmessage:{i}:{keyword}" 324 | )) 325 | else: 326 | buttons.append([InlineKeyboardButton( 327 | text=match.group(2), 328 | callback_data=f"alertmessage:{i}:{keyword}" 329 | )]) 330 | i += 1 331 | alerts.append(match.group(4)) 332 | elif bool(match.group(5)) and buttons: 333 | buttons[-1].append(InlineKeyboardButton( 334 | text=match.group(2), 335 | url=match.group(4).replace(" ", "") 336 | )) 337 | else: 338 | buttons.append([InlineKeyboardButton( 339 | text=match.group(2), 340 | url=match.group(4).replace(" ", "") 341 | )]) 342 | 343 | else: 344 | note_data += text[prev:to_check] 345 | prev = match.start(1) - 1 346 | else: 347 | note_data += text[prev:] 348 | 349 | try: 350 | return note_data, buttons, alerts 351 | except: 352 | return note_data, buttons, None 353 | 354 | def remove_escapes(text: str) -> str: 355 | res = "" 356 | is_escaped = False 357 | for counter in range(len(text)): 358 | if is_escaped: 359 | res += text[counter] 360 | is_escaped = False 361 | elif text[counter] == "\\": 362 | is_escaped = True 363 | else: 364 | res += text[counter] 365 | return res 366 | 367 | 368 | def humanbytes(size): 369 | if not size: 370 | return "" 371 | power = 2**10 372 | n = 0 373 | Dic_powerN = {0: ' ', 1: 'Ki', 2: 'Mi', 3: 'Gi', 4: 'Ti'} 374 | while size > power: 375 | size /= power 376 | n += 1 377 | return str(round(size, 2)) + " " + Dic_powerN[n] + 'B' 378 | -------------------------------------------------------------------------------- /image/edit_2.py: -------------------------------------------------------------------------------- 1 | from PIL import Image, ImageEnhance, ImageDraw 2 | import numpy as np 3 | import os 4 | import cv2 5 | import shutil 6 | 7 | 8 | async def circle_with_bg(client, message): 9 | try: 10 | userid = str(message.chat.id) 11 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 12 | os.makedirs(f"./DOWNLOADS/{userid}") 13 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 14 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "circle.png" 15 | if not message.reply_to_message.empty: 16 | msg = await message.reply_to_message.reply_text( 17 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 18 | ) 19 | a = await client.download_media( 20 | message=message.reply_to_message, file_name=download_location 21 | ) 22 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 23 | img = Image.open(a).convert("RGB") 24 | npImage = np.array(img) 25 | h, w = img.size 26 | alpha = Image.new("L", img.size, 0) 27 | draw = ImageDraw.Draw(alpha) 28 | draw.pieslice([0, 0, h, w], 0, 360, fill=255) 29 | npAlpha = np.array(alpha) 30 | npImage = np.dstack((npImage, npAlpha)) 31 | Image.fromarray(npImage).save(edit_img_loc) 32 | await message.reply_chat_action("upload_photo") 33 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 34 | await msg.delete() 35 | else: 36 | await message.reply_text("Why did you delete that??") 37 | try: 38 | shutil.rmtree(f"./DOWNLOADS/{userid}") 39 | except Exception: 40 | pass 41 | except Exception as e: 42 | print("circle_with_bg-error - " + str(e)) 43 | if "USER_IS_BLOCKED" in str(e): 44 | return 45 | else: 46 | try: 47 | await message.reply_to_message.reply_text( 48 | "Something went wrong!", quote=True 49 | ) 50 | except Exception: 51 | return 52 | 53 | 54 | async def circle_without_bg(client, message): 55 | try: 56 | userid = str(message.chat.id) 57 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 58 | os.makedirs(f"./DOWNLOADS/{userid}") 59 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 60 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "circle.png" 61 | if not message.reply_to_message.empty: 62 | msg = await message.reply_to_message.reply_text( 63 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 64 | ) 65 | a = await client.download_media( 66 | message=message.reply_to_message, file_name=download_location 67 | ) 68 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 69 | img = Image.open(a).convert("RGB") 70 | npImage = np.array(img) 71 | h, w = img.size 72 | alpha = Image.new("L", img.size, 0) 73 | draw = ImageDraw.Draw(alpha) 74 | draw.pieslice([0, 0, h, w], 0, 360, fill=255) 75 | npAlpha = np.array(alpha) 76 | npImage = np.dstack((npImage, npAlpha)) 77 | Image.fromarray(npImage).save(edit_img_loc) 78 | await message.reply_chat_action("upload_document") 79 | await message.reply_to_message.reply_document(edit_img_loc, quote=True) 80 | await msg.delete() 81 | else: 82 | await message.reply_text("Why did you delete that??") 83 | try: 84 | shutil.rmtree(f"./DOWNLOADS/{userid}") 85 | except Exception: 86 | pass 87 | except Exception as e: 88 | print("circle_without_bg-error - " + str(e)) 89 | if "USER_IS_BLOCKED" in str(e): 90 | return 91 | else: 92 | try: 93 | await message.reply_to_message.reply_text( 94 | "Something went wrong!", quote=True 95 | ) 96 | except Exception: 97 | return 98 | 99 | 100 | async def sticker(client, message): 101 | try: 102 | userid = str(message.chat.id) 103 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 104 | os.makedirs(f"./DOWNLOADS/{userid}") 105 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 106 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "sticker.webp" 107 | if not message.reply_to_message.empty: 108 | msg = await message.reply_to_message.reply_text( 109 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 110 | ) 111 | a = await client.download_media( 112 | message=message.reply_to_message, file_name=download_location 113 | ) 114 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 115 | os.rename(a, edit_img_loc) 116 | await message.reply_to_message.reply_sticker(edit_img_loc, quote=True) 117 | await msg.delete() 118 | else: 119 | await message.reply_text("Why did you delete that??") 120 | try: 121 | shutil.rmtree(f"./DOWNLOADS/{userid}") 122 | except Exception: 123 | pass 124 | except Exception as e: 125 | print("sticker-error - " + str(e)) 126 | if "USER_IS_BLOCKED" in str(e): 127 | return 128 | else: 129 | try: 130 | await message.reply_to_message.reply_text( 131 | "Something went wrong!", quote=True 132 | ) 133 | except Exception: 134 | return 135 | 136 | 137 | def add_corners(im, rad): 138 | circle = Image.new("L", (rad * 2, rad * 2), 0) 139 | draw = ImageDraw.Draw(circle) 140 | draw.ellipse((0, 0, rad * 2, rad * 2), fill=255) 141 | alpha = Image.new("L", im.size, 255) 142 | w, h = im.size 143 | alpha.paste(circle.crop((0, 0, rad, rad)), (0, 0)) 144 | alpha.paste(circle.crop((0, rad, rad, rad * 2)), (0, h - rad)) 145 | alpha.paste(circle.crop((rad, 0, rad * 2, rad)), (w - rad, 0)) 146 | alpha.paste(circle.crop((rad, rad, rad * 2, rad * 2)), (w - rad, h - rad)) 147 | im.putalpha(alpha) 148 | return im 149 | 150 | 151 | async def edge_curved(client, message): 152 | try: 153 | userid = str(message.chat.id) 154 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 155 | os.makedirs(f"./DOWNLOADS/{userid}") 156 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 157 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "edge_curved.webp" 158 | if not message.reply_to_message.empty: 159 | msg = await message.reply_to_message.reply_text( 160 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 161 | ) 162 | a = await client.download_media( 163 | message=message.reply_to_message, file_name=download_location 164 | ) 165 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 166 | im = Image.open(a) 167 | im = add_corners(im, 100) 168 | im.save(edit_img_loc) 169 | await message.reply_chat_action("upload_photo") 170 | await message.reply_to_message.reply_sticker(edit_img_loc, quote=True) 171 | await msg.delete() 172 | else: 173 | await message.reply_text("Why did you delete that??") 174 | try: 175 | shutil.rmtree(f"./DOWNLOADS/{userid}") 176 | except Exception: 177 | pass 178 | except Exception as e: 179 | print("edge_curved-error - " + str(e)) 180 | if "USER_IS_BLOCKED" in str(e): 181 | return 182 | else: 183 | try: 184 | await message.reply_to_message.reply_text( 185 | "Something went wrong!", quote=True 186 | ) 187 | except Exception: 188 | return 189 | 190 | 191 | async def contrast(client, message): 192 | try: 193 | userid = str(message.chat.id) 194 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 195 | os.makedirs(f"./DOWNLOADS/{userid}") 196 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 197 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "contrast.jpg" 198 | if not message.reply_to_message.empty: 199 | msg = await message.reply_to_message.reply_text( 200 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 201 | ) 202 | a = await client.download_media( 203 | message=message.reply_to_message, file_name=download_location 204 | ) 205 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 206 | image = Image.open(a) 207 | contrast = ImageEnhance.Contrast(image) 208 | contrast.enhance(1.5).save(edit_img_loc) 209 | await message.reply_chat_action("upload_photo") 210 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 211 | await msg.delete() 212 | else: 213 | await message.reply_text("Why did you delete that??") 214 | try: 215 | shutil.rmtree(f"./DOWNLOADS/{userid}") 216 | except Exception: 217 | pass 218 | except Exception as e: 219 | print("contrast-error - " + str(e)) 220 | if "USER_IS_BLOCKED" in str(e): 221 | return 222 | else: 223 | try: 224 | await message.reply_to_message.reply_text( 225 | "Something went wrong!", quote=True 226 | ) 227 | except Exception: 228 | return 229 | 230 | 231 | def sepia(img): 232 | width, height = img.size 233 | new_img = img.copy() 234 | for x in range(width): 235 | for y in range(height): 236 | red, green, blue = img.getpixel((x, y)) 237 | new_val = 0.3 * red + 0.59 * green + 0.11 * blue 238 | new_red = int(new_val * 2) 239 | if new_red > 255: 240 | new_red = 255 241 | new_green = int(new_val * 1.5) 242 | if new_green > 255: 243 | new_green = 255 244 | new_blue = int(new_val) 245 | if new_blue > 255: 246 | new_blue = 255 247 | 248 | new_img.putpixel((x, y), (new_red, new_green, new_blue)) 249 | 250 | return new_img 251 | 252 | 253 | async def sepia_mode(client, message): 254 | try: 255 | userid = str(message.chat.id) 256 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 257 | os.makedirs(f"./DOWNLOADS/{userid}") 258 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 259 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "sepia.jpg" 260 | if not message.reply_to_message.empty: 261 | msg = await message.reply_to_message.reply_text( 262 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 263 | ) 264 | a = await client.download_media( 265 | message=message.reply_to_message, file_name=download_location 266 | ) 267 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 268 | image = Image.open(a) 269 | new_img = sepia(image) 270 | new_img.save(edit_img_loc) 271 | await message.reply_chat_action("upload_photo") 272 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 273 | await msg.delete() 274 | else: 275 | await message.reply_text("Why did you delete that??") 276 | try: 277 | shutil.rmtree(f"./DOWNLOADS/{userid}") 278 | except Exception: 279 | pass 280 | except Exception as e: 281 | print("sepia_mode-error - " + str(e)) 282 | if "USER_IS_BLOCKED" in str(e): 283 | return 284 | else: 285 | try: 286 | await message.reply_to_message.reply_text( 287 | "Something went wrong!", quote=True 288 | ) 289 | except Exception: 290 | return 291 | 292 | 293 | def dodgeV2(x, y): 294 | return cv2.divide(x, 255 - y, scale=256) 295 | 296 | 297 | async def pencil(client, message): 298 | try: 299 | userid = str(message.chat.id) 300 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 301 | os.makedirs(f"./DOWNLOADS/{userid}") 302 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 303 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "pencil.jpg" 304 | if not message.reply_to_message.empty: 305 | msg = await message.reply_to_message.reply_text( 306 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 307 | ) 308 | a = await client.download_media( 309 | message=message.reply_to_message, file_name=download_location 310 | ) 311 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 312 | img = cv2.imread(a) 313 | img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 314 | img_invert = cv2.bitwise_not(img_gray) 315 | img_smoothing = cv2.GaussianBlur(img_invert, (21, 21), sigmaX=0, sigmaY=0) 316 | final_img = dodgeV2(img_gray, img_smoothing) 317 | cv2.imwrite(edit_img_loc, final_img) 318 | await message.reply_chat_action("upload_photo") 319 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 320 | await msg.delete() 321 | else: 322 | await message.reply_text("Why did you delete that??") 323 | try: 324 | shutil.rmtree(f"./DOWNLOADS/{userid}") 325 | except Exception: 326 | pass 327 | except Exception as e: 328 | print("pencil-error - " + str(e)) 329 | if "USER_IS_BLOCKED" in str(e): 330 | return 331 | else: 332 | try: 333 | await message.reply_to_message.reply_text( 334 | "Something went wrong!", quote=True 335 | ) 336 | except Exception: 337 | return 338 | 339 | 340 | def color_quantization(img, k): 341 | data = np.float32(img).reshape((-1, 3)) 342 | criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 20, 1.0) 343 | _, label, center = cv2.kmeans( 344 | data, k, None, criteria, 10, cv2.KMEANS_RANDOM_CENTERS 345 | ) 346 | center = np.uint8(center) 347 | result = center[label.flatten()] 348 | result = result.reshape(img.shape) 349 | return result 350 | 351 | 352 | async def cartoon(client, message): 353 | try: 354 | userid = str(message.chat.id) 355 | if not os.path.isdir(f"./DOWNLOADS/{userid}"): 356 | os.makedirs(f"./DOWNLOADS/{userid}") 357 | download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" 358 | edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "kang.jpg" 359 | if not message.reply_to_message.empty: 360 | msg = await message.reply_to_message.reply_text( 361 | "𝙳𝙾𝚆𝙽𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....", quote=True 362 | ) 363 | a = await client.download_media( 364 | message=message.reply_to_message, file_name=download_location 365 | ) 366 | await msg.edit("𝚄𝙿𝙻𝙾𝙰𝙳𝙸𝙽𝙶 𝙸𝙼𝙰𝙶𝙴....") 367 | img = cv2.imread(a) 368 | edges = cv2.Canny(img, 100, 200) 369 | gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 370 | edges = cv2.adaptiveThreshold( 371 | gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 9, 5 372 | ) 373 | color = cv2.bilateralFilter(img, d=9, sigmaColor=200, sigmaSpace=200) 374 | 375 | cv2.bitwise_and(color, color, mask=edges) 376 | img_1 = color_quantization(img, 7) 377 | cv2.imwrite(edit_img_loc, img_1) 378 | await message.reply_chat_action("upload_photo") 379 | await message.reply_to_message.reply_photo(edit_img_loc, quote=True) 380 | await msg.delete() 381 | else: 382 | await message.reply_text("Why did you delete that??") 383 | try: 384 | shutil.rmtree(f"./DOWNLOADS/{userid}") 385 | except Exception: 386 | pass 387 | except Exception as e: 388 | print("cartoon-error - " + str(e)) 389 | if "USER_IS_BLOCKED" in str(e): 390 | return 391 | else: 392 | try: 393 | await message.reply_to_message.reply_text( 394 | "Something went wrong!", quote=True 395 | ) 396 | except Exception: 397 | return 398 | --------------------------------------------------------------------------------