File size: 5,756 Bytes
e566133 cbf6107 e566133 6028c68 e566133 6028c68 e566133 6028c68 e566133 |
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 |
import math
import logging
import asyncio
import traceback
from pyrogram import filters, Client
from pyrogram.enums.parse_mode import ParseMode
from pyrogram.types import BotCommand, Message, ReplyKeyboardMarkup, InlineKeyboardMarkup, InlineKeyboardButton
from FileStream import __version__
from FileStream.bot import FileStream
from FileStream.Exceptions import FileNotFound
from FileStream.utils.FileProcessors.bot_utils import gen_linkx, verify_user, verify_users
from FileStream.config import Telegram
from FileStream.Database import Database
from FileStream.utils.FileProcessors.translation import LANG, BUTTON
db = Database(Telegram.DATABASE_URL, Telegram.SESSION_NAME)
async def menu(bot, message):
await bot.send_message(
chat_id=message.from_user.id,
text="ꜱᴇʟᴇᴄᴛ ꜰʀᴏᴍ ᴍᴇɴᴜ",
reply_markup=ReplyKeyboardMarkup(
[[("ꜰɪʟᴇ ʙᴀɴᴋ"),("ꜱᴇᴀʀᴄʜ")], [("ᴍʏ ᴘʀɪᴠᴀᴛᴇ ꜱᴘᴀᴄᴇ"), ("ᴍʏ ᴘᴜʙʟɪᴄ ꜰɪʟᴇꜱ")]],
one_time_keyboard=False,
resize_keyboard=True,
placeholder="🄼🄰🄸🄽 🄼🄴🄽🅄 👉"))
@FileStream.on_message(filters.command('start') & filters.private)
@verify_users
async def start(bot: Client, message: Message, response):
if response['status'] == "AUTHORIZED":
usr_cmd = message.text.split("_")[-1]
if usr_cmd == "/start":
await bot.set_bot_commands([
BotCommand("start", "ꜱᴛᴀʀᴛ ᴛʜᴇ ʙᴏᴛ"),
BotCommand("help", "ʙᴏᴛ ꜱᴇᴛᴛɪɴɢꜱ"),
BotCommand("about", "ᴀʙᴏᴜᴛ ᴛʜᴇ ʙᴏᴛ"),
BotCommand("search", "ꜱᴇᴀʀᴄʜ ɪɴ ᴘᴜʙʟɪᴄ ꜰɪʟᴇꜱ"),
BotCommand("filebank", "ꜰɪʟᴇ ʙᴀɴᴋ"),
BotCommand("files", "ᴍʏ ᴘᴜʙʟɪᴄ ꜰɪʟᴇꜱ"),
BotCommand("myfiles", "ᴍʏ ᴘʀɪᴠᴀᴛᴇ ꜱᴘᴀᴄᴇ"),
BotCommand("admin", "ɪ ᴀᴍ ᴀᴅᴍɪɴ")
])
await menu(bot, message)
if Telegram.START_PIC:
await message.reply_photo(photo=Telegram.START_PIC,
caption=LANG.START_TEXT.format(
message.from_user.mention,
FileStream.username),
parse_mode=ParseMode.HTML,
reply_markup=BUTTON.START_BUTTONS)
else:
await message.reply_text(text=LANG.START_TEXT.format(
message.from_user.mention, FileStream.username),
parse_mode=ParseMode.HTML,
disable_web_page_preview=True,
reply_markup=BUTTON.START_BUTTONS)
else:
if "stream_" in message.text:
try:
file_check = await db.get_file(usr_cmd)
file_id = str(file_check['_id'])
if file_id == usr_cmd:
reply_markup, stream_text = await gen_linkx(
m=message,
_id=file_id,
name=[FileStream.username, FileStream.fname])
await message.reply_text(text=stream_text,
parse_mode=ParseMode.HTML,
disable_web_page_preview=True,
reply_markup=reply_markup,
quote=True)
except FIleNotFound as e:
await message.reply_text("File Not Found")
except Exception as e:
await message.reply_text("Something Went Wrong")
logging.error(e)
elif "file_" in message.text:
try:
file_check = await db.get_file(usr_cmd)
db_id = str(file_check['_id'])
file_id = file_check['file']['file_id']
file_name = file_check['file']['file_name']
if db_id == usr_cmd:
filex = await message.reply_cached_media(
file_id=file_id, caption=f'**{file_name}**')
await asyncio.sleep(3600)
try:
await filex.delete()
await message.delete()
except Exception:
pass
except FIleNotFound as e:
await message.reply_text("**File Not Found**")
except Exception as e:
await message.reply_text("Something Went Wrong")
logging.error(e)
else:
await message.reply_text(f"**Invalid Command**")
@FileStream.on_message(filters.private & filters.command(["about"]))
async def about_handler(bot, message):
if Telegram.START_PIC:
await message.reply_photo(photo=Telegram.START_PIC,
caption=LANG.ABOUT_TEXT.format(FileStream.fname, __version__),
parse_mode=ParseMode.HTML,
reply_markup=BUTTON.ABOUT_BUTTONS)
else:
await message.reply_text(text=LANG.ABOUT_TEXT.format(FileStream.fname, __version__),
disable_web_page_preview=True,
reply_markup=BUTTON.ABOUT_BUTTONS)
@FileStream.on_message((filters.command('help')) & filters.private)
async def help_handler(bot, message):
if Telegram.START_PIC:
await message.reply_photo(photo=Telegram.START_PIC,
caption=LANG.HELP_TEXT.format(Telegram.OWNER_ID),
parse_mode=ParseMode.HTML,
reply_markup=BUTTON.HELP_BUTTONS)
else:
await message.reply_text(text=LANG.HELP_TEXT.format(Telegram.OWNER_ID),
parse_mode=ParseMode.HTML,
disable_web_page_preview=True,
reply_markup=BUTTON.HELP_BUTTONS)
|