Spaces:
Running
Running
BinaryONe
commited on
Commit
·
0b8a548
1
Parent(s):
6028c68
Changes in Database
Browse files
FileStream/Database/database.py
CHANGED
@@ -132,7 +132,7 @@ class Database:
|
|
132 |
except InvalidId:
|
133 |
raise FileNotFound
|
134 |
|
135 |
-
async def
|
136 |
if privacy_type == "PUBLIC":
|
137 |
try:
|
138 |
file_info = await self.files.find_one({"_id": ObjectId(_id)})
|
@@ -345,7 +345,7 @@ class Database:
|
|
345 |
async def get_search_results(self,query=None, file_type=None, max_results=10, offset=0):
|
346 |
|
347 |
regex = re.compile(re.escape(query), re.IGNORECASE)
|
348 |
-
filter = {'$or': [{'file.file_name': {"$regex": regex}}, {'file.caption': {"$regex": regex}}]}
|
349 |
|
350 |
if file_type:
|
351 |
filter['mime_type'] = file_type
|
|
|
132 |
except InvalidId:
|
133 |
raise FileNotFound
|
134 |
|
135 |
+
async def GetFileByDBName(self, _id, privacy_type:str ):
|
136 |
if privacy_type == "PUBLIC":
|
137 |
try:
|
138 |
file_info = await self.files.find_one({"_id": ObjectId(_id)})
|
|
|
345 |
async def get_search_results(self,query=None, file_type=None, max_results=10, offset=0):
|
346 |
|
347 |
regex = re.compile(re.escape(query), re.IGNORECASE)
|
348 |
+
filter = {'$or': [{'file.file_name': {"$regex": regex}}, {'file.caption': {"$regex": regex}}, {'title': {"$regex": regex}}, {'release_date': {"$regex": regex}}]}
|
349 |
|
350 |
if file_type:
|
351 |
filter['mime_type'] = file_type
|
FileStream/bot/plugins/Admin/admin.py
CHANGED
@@ -25,7 +25,7 @@ async def iamadmin(c: Client, m: Message):
|
|
25 |
if await db.is_admin(m.from_user.id):
|
26 |
await m.reply_text(
|
27 |
text=LANG.ADMIN_GUIDELINES_TEXT_Y.format("/add_user <UserID>","/add_admin <UserID>"),
|
28 |
-
parse_mode=ParseMode.
|
29 |
quote=True)
|
30 |
|
31 |
|
@@ -49,7 +49,7 @@ async def add_user(c: Client, m: Message):
|
|
49 |
except ValueError or UnboundLocalError:
|
50 |
return await m.reply_text(f"**Usage:**\n <code> /add_admin <{user_id}> </code> ")
|
51 |
details= await FileStream.get_users(user_id)
|
52 |
-
print("Details :",details)
|
53 |
await db.add_user(user_id, details)
|
54 |
await m.reply_text(f"**User[{m.from_user.first_name} {m.from_user.last_name}] \n User ID : {user_id} Added Successfully**")
|
55 |
else:
|
@@ -65,7 +65,28 @@ async def add_user(c: Client, m: Message):
|
|
65 |
except ValueError or UnboundLocalError:
|
66 |
return await m.reply_text(f"**Usage:**\n <code> /add_admin <{user_id}> </code>")
|
67 |
details= await FileStream.get_users(user_id)
|
68 |
-
print("Details :",details)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
await db.add_admin(user_id, details )
|
70 |
await m.reply_text(f"**Admin [{m.from_user.first_name} {m.from_user.last_name}]\n {user_id} Added Successfully**")
|
71 |
else:
|
|
|
25 |
if await db.is_admin(m.from_user.id):
|
26 |
await m.reply_text(
|
27 |
text=LANG.ADMIN_GUIDELINES_TEXT_Y.format("/add_user <UserID>","/add_admin <UserID>"),
|
28 |
+
parse_mode=ParseMode.HTML,
|
29 |
quote=True)
|
30 |
|
31 |
|
|
|
49 |
except ValueError or UnboundLocalError:
|
50 |
return await m.reply_text(f"**Usage:**\n <code> /add_admin <{user_id}> </code> ")
|
51 |
details= await FileStream.get_users(user_id)
|
52 |
+
#print("Details :",details)
|
53 |
await db.add_user(user_id, details)
|
54 |
await m.reply_text(f"**User[{m.from_user.first_name} {m.from_user.last_name}] \n User ID : {user_id} Added Successfully**")
|
55 |
else:
|
|
|
65 |
except ValueError or UnboundLocalError:
|
66 |
return await m.reply_text(f"**Usage:**\n <code> /add_admin <{user_id}> </code>")
|
67 |
details= await FileStream.get_users(user_id)
|
68 |
+
#print("Details :",details)
|
69 |
+
"""Details : {
|
70 |
+
"_": "User",
|
71 |
+
"id": ,
|
72 |
+
"is_self": false,
|
73 |
+
"is_contact": false,
|
74 |
+
"is_mutual_contact": false,
|
75 |
+
"is_deleted": false,
|
76 |
+
"is_bot": false,
|
77 |
+
"is_verified": false,
|
78 |
+
"is_restricted": false,
|
79 |
+
"is_scam": false,
|
80 |
+
"is_fake": false,
|
81 |
+
"is_support": false,
|
82 |
+
"is_premium": false,
|
83 |
+
"is_contacts_only": false,
|
84 |
+
"first_name": "",
|
85 |
+
"last_name": "",
|
86 |
+
"status": "UserStatus.RECENTLY",
|
87 |
+
"username": "",
|
88 |
+
"language_code": "en"
|
89 |
+
}"""
|
90 |
await db.add_admin(user_id, details )
|
91 |
await m.reply_text(f"**Admin [{m.from_user.first_name} {m.from_user.last_name}]\n {user_id} Added Successfully**")
|
92 |
else:
|
FileStream/bot/plugins/FileHandlers/callback.py
CHANGED
@@ -266,10 +266,10 @@ async def cb_data(bot: Client, update: CallbackQuery):
|
|
266 |
}
|
267 |
file_info = get_file_info(message, instruction)
|
268 |
# Here we are Adding the File Into the database First
|
269 |
-
db_id = await db.add_file(file_info=file_info, db_type="
|
270 |
await get_file_ids(False, db_id, message)
|
271 |
if True:
|
272 |
-
file_info = await db.
|
273 |
reply_markup, stream_text = await priv_func(file_info['file']['file_name'], file_info['file']['file_size'])
|
274 |
await update.message.edit_text(
|
275 |
text=stream_text,
|
@@ -472,8 +472,7 @@ async def gen_privfile_menu(_id, file_list_no, update: CallbackQuery):
|
|
472 |
file_type = "Image"
|
473 |
elif file_id.file_type == FileType.VOICE:
|
474 |
file_type = "Voice"
|
475 |
-
elif file_id.file_type in (FileType.VIDEO, FileType.ANIMATION,
|
476 |
-
FileType.VIDEO_NOTE):
|
477 |
file_type = "Video"
|
478 |
elif file_id.file_type == FileType.DOCUMENT:
|
479 |
file_type = "Document"
|
@@ -533,21 +532,17 @@ async def gen_allfile_list_button(file_list_no: int, user_id: int):
|
|
533 |
file_list = []
|
534 |
async for x in user_files:
|
535 |
file_list.append([
|
536 |
-
InlineKeyboardButton(
|
537 |
-
f"📦 {x['file']['caption']}",
|
538 |
-
callback_data=f"allfile_{x['_id']}_{file_list_no}")
|
539 |
])
|
540 |
if total_files > 10:
|
541 |
file_list.append([
|
542 |
-
InlineKeyboardButton(
|
543 |
-
"◄",
|
544 |
callback_data="{}".format("userallfiles_" +
|
545 |
str(file_list_no -
|
546 |
1) if file_list_no > 1 else 'N/A')),
|
547 |
InlineKeyboardButton(f"{file_list_no}/{math.ceil(total_files/10)}",
|
548 |
callback_data="N/A"),
|
549 |
-
InlineKeyboardButton(
|
550 |
-
"►",
|
551 |
callback_data="{}".format("userallfiles_" +
|
552 |
str(file_list_no +
|
553 |
1) if total_files > file_list_no *
|
@@ -572,8 +567,7 @@ async def gen_allfile_menu(_id, file_list_no, update: CallbackQuery):
|
|
572 |
file_type = "Image"
|
573 |
elif file_id.file_type == FileType.VOICE:
|
574 |
file_type = "Voice"
|
575 |
-
elif file_id.file_type in (FileType.VIDEO, FileType.ANIMATION,
|
576 |
-
FileType.VIDEO_NOTE):
|
577 |
file_type = "Video"
|
578 |
elif file_id.file_type == FileType.DOCUMENT:
|
579 |
file_type = "Document"
|
@@ -589,34 +583,26 @@ async def gen_allfile_menu(_id, file_list_no, update: CallbackQuery):
|
|
589 |
if "video" in file_type.lower():
|
590 |
MYFILES_BUTTONS = InlineKeyboardMarkup([
|
591 |
[
|
592 |
-
|
593 |
-
|
594 |
],
|
595 |
-
[
|
596 |
-
|
597 |
-
|
598 |
-
InlineKeyboardButton(
|
599 |
-
"ʀᴇᴠᴏᴋᴇ ғɪʟᴇ",
|
600 |
-
callback_data=f"msgdelete_{myfile_info['_id']}_{file_list_no}")
|
601 |
],
|
602 |
[
|
603 |
-
|
604 |
-
"ʙᴀᴄᴋ", callback_data="userfiles_{}".format(file_list_no))
|
605 |
]
|
606 |
])
|
607 |
else:
|
608 |
MYFILES_BUTTONS = InlineKeyboardMarkup([
|
609 |
[InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)],
|
610 |
[
|
611 |
-
|
612 |
-
|
613 |
-
InlineKeyboardButton(
|
614 |
-
"ʀᴇᴠᴏᴋᴇ ғɪʟᴇ",
|
615 |
-
callback_data=f"msgdelete_{myfile_info['_id']}_{file_list_no}")
|
616 |
],
|
617 |
[
|
618 |
-
|
619 |
-
"ʙᴀᴄᴋ", callback_data="userfiles_{}".format(file_list_no))
|
620 |
]
|
621 |
])
|
622 |
|
@@ -642,20 +628,15 @@ async def delete_user_file(_id, file_list_no: int, update: CallbackQuery):
|
|
642 |
await db.delete_one_privfile(myfile_info['_id'])
|
643 |
#await db.count_links(update.from_user.id, "-")
|
644 |
await update.message.edit_caption(
|
645 |
-
caption="**Fɪʟᴇ Dᴇʟᴇᴛᴇᴅ Sᴜᴄᴄᴇssғᴜʟʟʏ !**" +
|
646 |
-
|
647 |
-
""),
|
648 |
-
reply_markup=InlineKeyboardMarkup(
|
649 |
-
[[InlineKeyboardButton("ʙᴀᴄᴋ", callback_data=f"userfiles_1")]]))
|
650 |
else:
|
651 |
await db.delete_one_file(myfile_info['_id'])
|
652 |
await db.count_links(update.from_user.id, "-")
|
653 |
await update.message.edit_caption(
|
654 |
-
caption="**Fɪʟᴇ Dᴇʟᴇᴛᴇᴅ Sᴜᴄᴄᴇssғᴜʟʟʏ !**" +
|
655 |
-
|
656 |
-
|
657 |
-
reply_markup=InlineKeyboardMarkup(
|
658 |
-
[[InlineKeyboardButton("ʙᴀᴄᴋ", callback_data=f"userfiles_1")]]))
|
659 |
|
660 |
except FileNotFound:
|
661 |
await update.answer("File Already Deleted")
|
|
|
266 |
}
|
267 |
file_info = get_file_info(message, instruction)
|
268 |
# Here we are Adding the File Into the database First
|
269 |
+
db_id = await db.add_file(file_info=file_info, db_type="TEMPORARY")
|
270 |
await get_file_ids(False, db_id, message)
|
271 |
if True:
|
272 |
+
file_info = await db.GetFileByDBName(db_id, privacy_type="TEMPORARY")
|
273 |
reply_markup, stream_text = await priv_func(file_info['file']['file_name'], file_info['file']['file_size'])
|
274 |
await update.message.edit_text(
|
275 |
text=stream_text,
|
|
|
472 |
file_type = "Image"
|
473 |
elif file_id.file_type == FileType.VOICE:
|
474 |
file_type = "Voice"
|
475 |
+
elif file_id.file_type in (FileType.VIDEO, FileType.ANIMATION,FileType.VIDEO_NOTE):
|
|
|
476 |
file_type = "Video"
|
477 |
elif file_id.file_type == FileType.DOCUMENT:
|
478 |
file_type = "Document"
|
|
|
532 |
file_list = []
|
533 |
async for x in user_files:
|
534 |
file_list.append([
|
535 |
+
InlineKeyboardButton(f"📦 {x['file']['caption']}", callback_data=f"allfile_{x['_id']}_{file_list_no}")
|
|
|
|
|
536 |
])
|
537 |
if total_files > 10:
|
538 |
file_list.append([
|
539 |
+
InlineKeyboardButton( "◄",
|
|
|
540 |
callback_data="{}".format("userallfiles_" +
|
541 |
str(file_list_no -
|
542 |
1) if file_list_no > 1 else 'N/A')),
|
543 |
InlineKeyboardButton(f"{file_list_no}/{math.ceil(total_files/10)}",
|
544 |
callback_data="N/A"),
|
545 |
+
InlineKeyboardButton("►",
|
|
|
546 |
callback_data="{}".format("userallfiles_" +
|
547 |
str(file_list_no +
|
548 |
1) if total_files > file_list_no *
|
|
|
567 |
file_type = "Image"
|
568 |
elif file_id.file_type == FileType.VOICE:
|
569 |
file_type = "Voice"
|
570 |
+
elif file_id.file_type in (FileType.VIDEO, FileType.ANIMATION,FileType.VIDEO_NOTE):
|
|
|
571 |
file_type = "Video"
|
572 |
elif file_id.file_type == FileType.DOCUMENT:
|
573 |
file_type = "Document"
|
|
|
583 |
if "video" in file_type.lower():
|
584 |
MYFILES_BUTTONS = InlineKeyboardMarkup([
|
585 |
[
|
586 |
+
InlineKeyboardButton("sᴛʀᴇᴀᴍ", url=page_link),
|
587 |
+
InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)
|
588 |
],
|
589 |
+
[
|
590 |
+
InlineKeyboardButton("ɢᴇᴛ ғɪʟᴇ", callback_data=f"sendfile_{myfile_info['_id']}"),
|
591 |
+
InlineKeyboardButton("ʀᴇᴠᴏᴋᴇ ғɪʟᴇ",callback_data=f"msgdelete_{myfile_info['_id']}_{file_list_no}")
|
|
|
|
|
|
|
592 |
],
|
593 |
[
|
594 |
+
InlineKeyboardButton("ʙᴀᴄᴋ", callback_data="userfiles_{}".format(file_list_no))
|
|
|
595 |
]
|
596 |
])
|
597 |
else:
|
598 |
MYFILES_BUTTONS = InlineKeyboardMarkup([
|
599 |
[InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)],
|
600 |
[
|
601 |
+
InlineKeyboardButton("ɢᴇᴛ ғɪʟᴇ", callback_data=f"sendfile_{myfile_info['_id']}"),
|
602 |
+
InlineKeyboardButton("ʀᴇᴠᴏᴋᴇ ғɪʟᴇ",callback_data=f"msgdelete_{myfile_info['_id']}_{file_list_no}")
|
|
|
|
|
|
|
603 |
],
|
604 |
[
|
605 |
+
InlineKeyboardButton("ʙᴀᴄᴋ", callback_data="userfiles_{}".format(file_list_no))
|
|
|
606 |
]
|
607 |
])
|
608 |
|
|
|
628 |
await db.delete_one_privfile(myfile_info['_id'])
|
629 |
#await db.count_links(update.from_user.id, "-")
|
630 |
await update.message.edit_caption(
|
631 |
+
caption="**Fɪʟᴇ Dᴇʟᴇᴛᴇᴅ Sᴜᴄᴄᴇssғᴜʟʟʏ !**" + update.message.caption.replace("Cᴏɴғɪʀᴍ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴅᴇʟᴇᴛᴇ ᴛʜᴇ Fɪʟᴇ",""),
|
632 |
+
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("ʙᴀᴄᴋ", callback_data=f"userfiles_1")]]))
|
|
|
|
|
|
|
633 |
else:
|
634 |
await db.delete_one_file(myfile_info['_id'])
|
635 |
await db.count_links(update.from_user.id, "-")
|
636 |
await update.message.edit_caption(
|
637 |
+
caption="**Fɪʟᴇ Dᴇʟᴇᴛᴇᴅ Sᴜᴄᴄᴇssғᴜʟʟʏ !**" + update.message.caption.replace("Cᴏɴғɪʀᴍ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴅᴇʟᴇᴛᴇ ᴛʜᴇ Fɪʟᴇ", ""),
|
638 |
+
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("ʙᴀᴄᴋ", callback_data=f"userfiles_1")]])
|
639 |
+
)
|
|
|
|
|
640 |
|
641 |
except FileNotFound:
|
642 |
await update.answer("File Already Deleted")
|
FileStream/bot/plugins/FileHandlers/files.py
CHANGED
@@ -149,12 +149,10 @@ async def handle_inline_query(client, query):
|
|
149 |
title=file['file']['file_name'],
|
150 |
document_file_id=file['file']['file_id'],
|
151 |
caption=file['file']['file_name'] or "",
|
152 |
-
description=
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
switch_inline_query_current_chat='')
|
157 |
-
]])))
|
158 |
if results:
|
159 |
switch_pm_text = f"Results"
|
160 |
if text:
|
|
|
149 |
title=file['file']['file_name'],
|
150 |
document_file_id=file['file']['file_id'],
|
151 |
caption=file['file']['file_name'] or "",
|
152 |
+
description=f"Size: {humanbytes(file['file']['file_size'])}\nType:{file['file']['mime_type']} ",
|
153 |
+
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton('Search',switch_inline_query_current_chat='')]])
|
154 |
+
)
|
155 |
+
)
|
|
|
|
|
156 |
if results:
|
157 |
switch_pm_text = f"Results"
|
158 |
if text:
|
FileStream/utils/FileProcessors/bot_utils.py
CHANGED
@@ -171,13 +171,16 @@ async def gen_link(_id):
|
|
171 |
file_name = file_info['file']['file_name']
|
172 |
file_size = humanbytes(file_info['file']['file_size'])
|
173 |
mime_type = file_info['file']['mime_type']
|
174 |
-
|
|
|
|
|
|
|
175 |
page_link = f"{Server.URL}app/watch/{_id}"
|
176 |
stream_link = f"{Server.URL}api/dl/{_id}"
|
177 |
file_link = f"https://t.me/{FileStream.username}?start=file_{_id}"
|
178 |
|
179 |
if "video" in mime_type:
|
180 |
-
stream_text = LANG.STREAM_TEXT.format(file_name, file_size, stream_link, page_link, file_link)
|
181 |
reply_markup = InlineKeyboardMarkup(
|
182 |
[[
|
183 |
InlineKeyboardButton("sᴛʀᴇᴀᴍ", url=page_link),
|
|
|
171 |
file_name = file_info['file']['file_name']
|
172 |
file_size = humanbytes(file_info['file']['file_size'])
|
173 |
mime_type = file_info['file']['mime_type']
|
174 |
+
poster = file_info['poster']
|
175 |
+
title=file_info["title"]
|
176 |
+
description=file_info['description']
|
177 |
+
release_date=file_info["release_date"],
|
178 |
page_link = f"{Server.URL}app/watch/{_id}"
|
179 |
stream_link = f"{Server.URL}api/dl/{_id}"
|
180 |
file_link = f"https://t.me/{FileStream.username}?start=file_{_id}"
|
181 |
|
182 |
if "video" in mime_type:
|
183 |
+
stream_text = LANG.STREAM_TEXT.format(poster,description,title,release_date,file_name, file_size, stream_link, page_link, file_link)
|
184 |
reply_markup = InlineKeyboardMarkup(
|
185 |
[[
|
186 |
InlineKeyboardButton("sᴛʀᴇᴀᴍ", url=page_link),
|
FileStream/utils/FileProcessors/translation.py
CHANGED
@@ -35,6 +35,9 @@ class LANG(object):
|
|
35 |
|
36 |
STREAM_TEXT = """
|
37 |
<i><u>𝗬𝗼𝘂𝗿 𝗟𝗶𝗻𝗸 𝗚𝗲𝗻𝗲𝗿𝗮𝘁𝗲𝗱 !</u></i>\n
|
|
|
|
|
|
|
38 |
<b>📂 Fɪʟᴇ ɴᴀᴍᴇ :</b> <b><code>{}</code></b>\n
|
39 |
<b>📦 Fɪʟᴇ ꜱɪᴢᴇ :</b> <code>{}</code>\n
|
40 |
<b>📥 Dᴏᴡɴʟᴏᴀᴅ :</b> <code>{}</code>\n
|
@@ -48,7 +51,7 @@ class LANG(object):
|
|
48 |
<b>📦 Fɪʟᴇ ꜱɪᴢᴇ :</b> <code>{}</code>\n
|
49 |
"""
|
50 |
ADMIN_GUIDELINES_TEXT_Y = """
|
51 |
-
<b>🪂
|
52 |
<b>🔗 ᴄᴏᴍᴍᴀɴᴅ 1:</b> <b>{}</b>\n
|
53 |
<b>🔗 ᴄᴏᴍᴍᴀɴᴅ 2 :</b> <b>{}</b>\n
|
54 |
"""
|
|
|
35 |
|
36 |
STREAM_TEXT = """
|
37 |
<i><u>𝗬𝗼𝘂𝗿 𝗟𝗶𝗻𝗸 𝗚𝗲𝗻𝗲𝗿𝗮𝘁𝗲𝗱 !</u></i>\n
|
38 |
+
<img src="{}" width="150" height="300">\n
|
39 |
+
<b>📣 ᴅᴇꜱᴄʀɪᴘᴛɪᴏɴ :</b> {} \n
|
40 |
+
<b>📊 ⒾⓂⒹⒷ :</b> {} 📦 રειελȘε {} \n
|
41 |
<b>📂 Fɪʟᴇ ɴᴀᴍᴇ :</b> <b><code>{}</code></b>\n
|
42 |
<b>📦 Fɪʟᴇ ꜱɪᴢᴇ :</b> <code>{}</code>\n
|
43 |
<b>📥 Dᴏᴡɴʟᴏᴀᴅ :</b> <code>{}</code>\n
|
|
|
51 |
<b>📦 Fɪʟᴇ ꜱɪᴢᴇ :</b> <code>{}</code>\n
|
52 |
"""
|
53 |
ADMIN_GUIDELINES_TEXT_Y = """
|
54 |
+
<b>🪂 ✩🅰🅳🅼🅸🅽 🅶🆄🅸🅳🅴🅻🅸🅽🅴🆂✩ 🪂</b>\n
|
55 |
<b>🔗 ᴄᴏᴍᴍᴀɴᴅ 1:</b> <b>{}</b>\n
|
56 |
<b>🔗 ᴄᴏᴍᴍᴀɴᴅ 2 :</b> <b>{}</b>\n
|
57 |
"""
|