├── Dockerfile ├── LICENSE ├── Procfile ├── README.md ├── Script.py ├── app.json ├── assets ├── AJAX.png ├── New Project 48 [C6E5D45].png ├── Picsart_22-02-20_13-02-59-464.jpg ├── Tedt └── logo.jpg ├── bot.py ├── database ├── connections_mdb.py ├── filters_mdb.py ├── gtrans_mdb.py ├── ia_filterdb.py └── users_chats_db.py ├── helper_func.py ├── heroku.yml ├── image ├── edit_1.py ├── edit_2.py ├── edit_3.py ├── edit_4.py └── edit_5.py ├── info.py ├── logging.conf ├── plugins ├── Don │ ├── Report_User.py │ ├── audiobook.py │ ├── covid.py │ ├── gtranslator.py │ ├── sticker.py │ ├── url_shortner.py │ └── yt_thumb_dl.py ├── Restrictions │ ├── @ │ ├── Ban.py │ ├── Restrict.py │ └── Unban.py ├── admemes │ ├── in_kick.py │ ├── list.py │ ├── paste.py │ ├── pin_message.py │ ├── ping.py │ ├── purge.py │ ├── song.py │ ├── telegraph.py │ └── tts.py ├── banned.py ├── broadcast.py ├── channel.py ├── commands.py ├── connection.py ├── filters.py ├── genlink.py ├── helper_functions │ ├── @ │ ├── admin_check.py │ ├── cust_p_filters.py │ ├── extract_user.py │ ├── get_file_id.py │ ├── last_online_hlpr.py │ └── string_handling.py ├── index.py ├── inline.py ├── lallu_tg │ ├── arrow.py │ ├── dice.py │ ├── goal.py │ ├── json.py │ ├── luck.py │ ├── runs.py │ └── whois.py ├── misc.py ├── p_ttishow.py ├── photo.py └── pm_filter.py ├── requirements.txt ├── runtime.txt ├── sample_config.py ├── sample_info.py ├── start.sh └── utils.py /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 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | worker: python3 bot.py -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 |
63 |
64 |
65 |
66 |
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 |
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/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/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/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/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/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/helper_functions/@:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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/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/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/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 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/runtime.txt:
--------------------------------------------------------------------------------
1 | python-3.10.2
2 |
--------------------------------------------------------------------------------
/sample_config.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 |
4 | class Config(object):
5 | RemoveBG_API = os.environ.get("RemoveBG_API", "")
6 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------