forked from VJBots/VJ-FILTER-BOT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.py
242 lines (232 loc) · 12.1 KB
/
commands.py
1
2
3
4
5
6
7
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# Don't Remove Credit @VJ_Botz
# Subscribe YouTube Channel For Amazing Bot @Tech_VJ
# Ask Doubt on telegram @KingVJ01
# Clone Code Credit : YT - @Tech_VJ / TG - @VJ_Bots / GitHub - @VJBots
import os, string, logging, random, asyncio, time, datetime, re, sys, json, base64
from Script import script
from pyrogram import Client, filters, enums
from pyrogram.errors import ChatAdminRequired, FloodWait
from pyrogram.types import *
from database.ia_filterdb import col, sec_col, get_file_details, unpack_new_file_id, get_bad_files
from database.users_chats_db import db
from CloneTechVJ.database.clone_bot_userdb import clonedb
from info import *
from shortzy import Shortzy
from utils import get_size, temp, get_seconds, get_clone_shortlink
logger = logging.getLogger(__name__)
@Client.on_message(filters.command("start") & filters.incoming)
async def start(client, message):
me = await client.get_me()
cd = await db.get_bot(me.id)
if message.chat.type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
buttons = [[
InlineKeyboardButton('⤬ ᴀᴅᴅ ᴍᴇ ᴛᴏ ʏᴏᴜʀ ɢʀᴏᴜᴘ ⤬', url=f'http://t.me/{me.username}?startgroup=true')
]]
if cd["update_channel_link"] != None:
up = cd["update_channel_link"]
buttons.append([InlineKeyboardButton('🍿 ᴊᴏɪɴ ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ 🍿', url=up)])
reply_markup = InlineKeyboardMarkup(buttons)
await message.reply(script.CLONE_START_TXT.format(message.from_user.mention if message.from_user else message.chat.title, me.username, me.first_name), reply_markup=reply_markup)
return
if not await clonedb.is_user_exist(me.id, message.from_user.id):
await clonedb.add_user(me.id, message.from_user.id)
if len(message.command) != 2:
buttons = [[
InlineKeyboardButton('⤬ ᴀᴅᴅ ᴍᴇ ᴛᴏ ʏᴏᴜʀ ɢʀᴏᴜᴘ ⤬', url=f'http://t.me/{me.username}?startgroup=true')
],[
InlineKeyboardButton('🕵️ ʜᴇʟᴘ', callback_data='help'),
InlineKeyboardButton('🔍 ᴀʙᴏᴜᴛ', callback_data='about')
]]
if cd["update_channel_link"] != None:
up = cd["update_channel_link"]
buttons.append([InlineKeyboardButton('🍿 ᴊᴏɪɴ ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ 🍿', url=up)])
reply_markup = InlineKeyboardMarkup(buttons)
m=await message.reply_sticker("CAACAgUAAxkBAAEKVaxlCWGs1Ri6ti45xliLiUeweCnu4AACBAADwSQxMYnlHW4Ls8gQMAQ")
await asyncio.sleep(1)
await m.delete()
await message.reply_text(
text=script.CLONE_START_TXT.format(message.from_user.mention, me.username, me.first_name),
reply_markup=reply_markup,
parse_mode=enums.ParseMode.HTML
)
return
data = message.command[1]
try:
pre, file_id = data.split('_', 1)
except:
file_id = data
pre = ""
if data.startswith("sendfiles"):
chat_id = int("-" + file_id.split("-")[1])
userid = message.from_user.id if message.from_user else None
g = await get_clone_shortlink(f"https://telegram.me/{me.username}?start=allfiles_{file_id}", cd["url"], cd["api"])
t = cd["tutorial"]
btn = [[
InlineKeyboardButton('📂 Dᴏᴡɴʟᴏᴀᴅ Nᴏᴡ 📂', url=g)
],[
InlineKeyboardButton('⁉️ Hᴏᴡ Tᴏ Dᴏᴡɴʟᴏᴀᴅ ⁉️', url=t)
]]
k = await client.send_message(chat_id=message.from_user.id,text=f"<b>Get All Files in a Single Click!!!\n\n📂 ʟɪɴᴋ ➠ : {g}\n\n<i>Note: This message is deleted in 5 mins to avoid copyrights. Save the link to Somewhere else</i></b>", reply_markup=InlineKeyboardMarkup(btn))
await asyncio.sleep(300)
await k.edit("<b>Your message is successfully deleted!!!</b>")
return
elif data.startswith("short"):
user = message.from_user.id
files_ = await get_file_details(file_id)
files = files_
g = await get_clone_shortlink(f"https://telegram.me/{me.username}?start=file_{file_id}", cd["url"], cd["api"])
t = cd["tutorial"]
btn = [[
InlineKeyboardButton('📂 Dᴏᴡɴʟᴏᴀᴅ Nᴏᴡ 📂', url=g)
],[
InlineKeyboardButton('⁉️ Hᴏᴡ Tᴏ Dᴏᴡɴʟᴏᴀᴅ ⁉️', url=t)
]]
k = await client.send_message(chat_id=user,text=f"<b>📕Nᴀᴍᴇ ➠ : <code>{files['file_name']}</code> \n\n🔗Sɪᴢᴇ ➠ : {get_size(files['file_size'])}\n\n📂Fɪʟᴇ ʟɪɴᴋ ➠ : {g}\n\n<i>Note: This message is deleted in 20 mins to avoid copyrights. Save the link to Somewhere else</i></b>", reply_markup=InlineKeyboardMarkup(btn))
await asyncio.sleep(1200)
await k.edit("<b>Your message is successfully deleted!!!</b>")
return
elif data.startswith("all"):
files = temp.GETALL.get(file_id)
if not files:
return await message.reply('<b><i>No such file exist.</b></i>')
filesarr = []
for file in files:
vj_file_id = file['file_id']
k = await temp.BOT.send_cached_media(chat_id=PUBLIC_FILE_CHANNEL, file_id=vj_file_id)
vj = await client.get_messages(PUBLIC_FILE_CHANNEL, k.id)
mg = getattr(vj, vj.media.value)
file_id = mg.file_id
files_ = await get_file_details(vj_file_id)
files1 = files_
title = ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files1['file_name'].split()))
size=get_size(files1['file_size'])
f_caption=files1['caption']
if f_caption is None:
f_caption = f"{' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files1['file_name'].split()))}"
if cd["update_channel_link"] != None:
up = cd["update_channel_link"]
button = [[
InlineKeyboardButton('🍿 ᴊᴏɪɴ ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ 🍿', url=up)
]]
reply_markup=InlineKeyboardMarkup(button)
else:
reply_markup=None
msg = await client.send_cached_media(
chat_id=message.from_user.id,
file_id=file_id,
caption=f_caption,
protect_content=False,
reply_markup=reply_markup
)
filesarr.append(msg)
k = await client.send_message(chat_id = message.from_user.id, text=f"<b><u>❗️❗️❗️IMPORTANT❗️️❗️❗️</u></b>\n\nThis Movie Files/Videos will be deleted in <b><u>10 mins</u> 🫥 <i></b>(Due to Copyright Issues)</i>.\n\n<b><i>Please forward this ALL Files/Videos to your Saved Messages and Start Download there</i></b>")
await asyncio.sleep(600)
for x in filesarr:
await x.delete()
await k.edit_text("<b>Your All Files/Videos is successfully deleted!!!</b>")
return
elif data.startswith("files"):
if cd['url']:
files_ = await get_file_details(file_id)
files = files_
g = await get_clone_shortlink(f"https://telegram.me/{me.username}?start=file_{file_id}", cd["url"], cd["api"])
t = cd["tutorial"]
btn = [[
InlineKeyboardButton('📂 Dᴏᴡɴʟᴏᴀᴅ Nᴏᴡ 📂', url=g)
],[
InlineKeyboardButton('⁉️ Hᴏᴡ Tᴏ Dᴏᴡɴʟᴏᴀᴅ ⁉️', url=t)
]]
k = await client.send_message(chat_id=message.from_user.id,text=f"<b>📕Nᴀᴍᴇ ➠ : <code>{files['file_name']}</code> \n\n🔗Sɪᴢᴇ ➠ : {get_size(files['file_size'])}\n\n📂Fɪʟᴇ ʟɪɴᴋ ➠ : {g}\n\n<i>Note: This message is deleted in 20 mins to avoid copyrights. Save the link to Somewhere else</i></b>", reply_markup=InlineKeyboardMarkup(btn))
await asyncio.sleep(1200)
await k.edit("<b>Your message is successfully deleted!!!</b>")
return
user = message.from_user.id
files_ = await get_file_details(file_id)
if not files_:
return await message.reply('**No such file exist.**')
files = files_
title = ' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files['file_name'].split()))
size=get_size(files['file_size'])
f_caption=files['caption']
if f_caption is None:
f_caption = f"{' '.join(filter(lambda x: not x.startswith('[') and not x.startswith('@'), files['file_name'].split()))}"
if cd["update_channel_link"] != None:
up = cd["update_channel_link"]
button = [[
InlineKeyboardButton('🍿 ᴊᴏɪɴ ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ 🍿', url=up)
]]
reply_markup=InlineKeyboardMarkup(button)
else:
reply_markup=None
k = await temp.BOT.send_cached_media(chat_id=PUBLIC_FILE_CHANNEL, file_id=file_id)
vj = await client.get_messages(PUBLIC_FILE_CHANNEL, k.id)
m = getattr(vj, vj.media.value)
file_id = m.file_id
msg = await client.send_cached_media(
chat_id=message.from_user.id,
file_id=file_id,
caption=f_caption,
protect_content=False,
reply_markup=reply_markup
)
k = await msg.reply("<b><u>❗️❗️❗️IMPORTANT❗️️❗️❗️</u></b>\n\nThis Movie File/Video will be deleted in <b><u>10 mins</u> 🫥 <i></b>(Due to Copyright Issues)</i>.\n\n<b><i>Please forward this File/Video to your Saved Messages and Start Download there</i></b>",quote=True)
await asyncio.sleep(600)
await msg.delete()
await k.edit_text("<b>Your File/Video is successfully deleted!!!</b>")
return
@Client.on_message(filters.command("settings") & filters.private)
async def settings(client, message):
me = await client.get_me()
owner = await db.get_bot(me.id)
if owner["user_id"] != message.from_user.id:
return
url = await client.ask(message.chat.id, "<b>Now Send Me Your Shortlink Site Domain Or Url Without https://</b>")
api = await client.ask(message.chat.id, "<b>Now Send Your Api</b>")
try:
shortzy = Shortzy(api_key=api.text, base_site=url.text)
link = 'https://t.me/VJ_Botz'
await shortzy.convert(link)
except Exception as e:
await message.reply(f"**Error In Converting Link**\n\n<code>{e}</code>\n\n**Start The Process Again By - /settings**", reply_markup=InlineKeyboardMarkup(btn))
return
tutorial = await client.ask(message.chat.id, "<b>Now Send Me Your How To Open Link means Tutorial Link.</b>")
if not tutorial.text.startswith(('https://', 'http://')):
await message.reply("**Invalid Link. Start The Process Again By - /settings**")
return
link = await client.ask(message.chat.id, "<b>Now Send Me Your Update Channel Link Which Is Shown In Your Start Button And Below File Button.</b>")
if not link.text.startswith(('https://', 'http://')):
await message.reply("**Invalid Link. Start The Process Again By - /settings**")
return
data = {
'url': url.text,
'api': api.text,
'tutorial': tutorial.text,
'update_channel_link': link.text
}
await db.update_bot(me.id, data)
await message.reply("**Successfully Added All Settings**")
@Client.on_message(filters.command("reset") & filters.private)
async def reset_settings(client, message):
me = await client.get_me()
owner = await db.get_bot(me.id)
if owner["user_id"] != message.from_user.id:
return
if owner["url"] == None:
await message.reply("**No Settings Found.**")
else:
data = {
'url': None,
'api': None,
'tutorial': None,
'update_channel_link': None
}
await db.update_bot(me.id, data)
await message.reply("**Successfully Reset All Settings To Default.**")
@Client.on_message(filters.command("stats") & filters.private)
async def stats(client, message):
me = await client.get_me()
total_users = await clonedb.total_users_count(me.id)
filesp = col.count_documents({})
totalsec = sec_col.count_documents({})
total = int(filesp) + int(totalsec)
await message.reply(f"**Total Files : {total}\n\nTotal Users : {total_users}**")