Files
FileStreamBot/WebStreamer/bot/plugins/start.py
2021-05-02 20:49:13 +05:30

191 lines
8.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from WebStreamer.bot import StreamBot
from WebStreamer.vars import Var
from WebStreamer.utils.human_readable import humanbytes
from WebStreamer.utils.database import Database
from pyrogram import filters
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from pyrogram.errors import UserNotParticipant
db = Database(Var.DATABASE_URL, Var.SESSION_NAME)
@StreamBot.on_message(filters.command('start') & filters.private & ~filters.edited)
async def start(b, m):
if not await db.is_user_exist(m.from_user.id):
await db.add_user(m.from_user.id)
await b.send_message(
Var.BIN_CHANNEL,
f"New User : [{m.from_user.first_name}](tg://user?id={m.from_user.id}) Started !!"
)
usr_cmd = m.text.split("_")[-1]
if usr_cmd == "/start":
if Var.UPDATES_CHANNEL is not None:
try:
user = await b.get_chat_member(Var.UPDATES_CHANNEL, m.chat.id)
if user.status == "kicked":
await b.send_message(
chat_id=m.chat.id,
text="**Sorry Sir, You are Banned to use me. Contact the Developer**",
parse_mode="markdown",
disable_web_page_preview=True
)
return
except UserNotParticipant:
await b.send_message(
chat_id=m.chat.id,
text="**Please Join My Updates Channel to use this Bot!**\n\nDue to Overload, Only Channel Subscribers can use the Bot!",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("🤖 Join Updates Channel", url=f"https://t.me/{Var.UPDATES_CHANNEL}")
]
]
),
parse_mode="markdown"
)
return
except Exception:
await b.send_message(
chat_id=m.chat.id,
text="**Something went Wrong. Contact me [Avishkar Patil](https://t.me/Avishkarpatil).**",
parse_mode="markdown",
disable_web_page_preview=True)
return
await m.reply_text(
text=f"🙋🏻‍♀ Hey **[{m.from_user.first_name}](tg://user?id={m.from_user.id})** Bruh!!\n\n**I am Instant😋 Telegram File to Link Generator Bot.**\n\n**Send me any file & see the magic!** \n\n**🔞 Pornogrphy Strictly Not Allowed** \n\nFor Help Just send /help to me 🙂",
reply_markup=InlineKeyboardMarkup(
[
[InlineKeyboardButton('😎 Developer', url='https://t.me/Avishkarpatil'), InlineKeyboardButton('😴 Profile', url='https://avipatilweb.me')]
]
),
disable_web_page_preview=True
)
else:
if Var.UPDATES_CHANNEL is not None:
try:
user = await b.get_chat_member(Var.UPDATES_CHANNEL, m.chat.id)
if user.status == "kicked":
await b.send_message(
chat_id=m.chat.id,
text="*Sorry Sir, You are Banned to use me. Quickly contact @Avishkarpatil*",
parse_mode="markdown",
disable_web_page_preview=True
)
return
except UserNotParticipant:
await b.send_message(
chat_id=m.chat.id,
text="**Please Join My Updates Channel to use this Bot!**\n\n*Due to Overload, Only Channel Subscribers can use the Bot!*",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("🤖 Join Updates Channel", url=f"https://t.me/{Var.UPDATES_CHANNEL}")
],
[
InlineKeyboardButton("🔄 Refresh / Try Again",
url=f"https://t.me/avifilestreambot/{usr_cmd}")
]
]
),
parse_mode="markdown"
)
return
except Exception:
await b.send_message(
chat_id=m.chat.id,
text="**Something went Wrong. Contact me [Avishkar Patil](https://t.me/Avishkarpatil).**",
parse_mode="markdown",
disable_web_page_preview=True)
return
get_msg = await b.get_messages(chat_id=Var.BIN_CHANNEL, message_ids=int(usr_cmd))
file_size = None
if get_msg.video:
file_size = f"{humanbytes(get_msg.video.file_size)}"
elif get_msg.document:
file_size = f"{humanbytes(get_msg.document.file_size)}"
elif get_msg.audio:
file_size = f"{humanbytes(get_msg.audio.file_size)}"
file_name = None
if get_msg.video:
file_name = f"{get_msg.video.file_name}"
elif get_msg.document:
file_name = f"{get_msg.document.file_name}"
elif get_msg.audio:
file_name = f"{get_msg.audio.file_name}"
stream_link = "https://{}/{}".format(Var.FQDN, get_msg.message_id) if Var.ON_HEROKU or Var.NO_PORT else \
"http://{}:{}/{}".format(Var.FQDN,
Var.PORT,
get_msg.message_id)
msg_text = "Bruh! 😁\n*Your Link Generated!* 🤓\n\n**📂 Fɪʟᴇ ɴᴀᴍᴇ :** `{}`\n**📦 Fɪʟᴇ ꜱɪᴢᴇ :** `{}`\n**📥 Dɴʟᴀᴅ :** {}\n🚸 **Nᴛᴇ : Lɪɴᴋ ᴇxᴘɪʀᴇᴅ ɪɴ 24 ʜᴏᴜʀꜱ**"
await m.reply_text(
text=msg_text.format(file_name, file_size, stream_link),
parse_mode="Markdown",
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Dɴʟᴀᴅ ɴᴏᴡ 📥", url=stream_link)]])
)
@StreamBot.on_message(filters.command('help') & filters.private & ~filters.edited)
async def help_handler(bot, message):
if not await db.is_user_exist(message.from_user.id):
await db.add_user(message.from_user.id)
await bot.send_message(
Var.BIN_CHANNEL,
f"New User : [{m.from_user.first_name}](tg://user?id={m.from_user.id}) Started !!"
)
if Var.UPDATES_CHANNEL is not None:
try:
user = await bot.get_chat_member(Var.UPDATES_CHANNEL, message.chat.id)
if user.status == "kicked":
await bot.send_message(
chat_id=message.chat.id,
text="Sorry Sir, You are Banned to use me.",
parse_mode="markdown",
disable_web_page_preview=True
)
return
except UserNotParticipant:
await bot.send_message(
chat_id=message.chat.id,
text="**Please Join My Updates Channel to use this Bot!**\n\nDue to Overload, Only Channel Subscribers can use the Bot!",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("🤖 Join Updates Channel", url=f"https://t.me/{Var.UPDATES_CHANNEL}")
]
]
),
parse_mode="markdown"
)
return
except Exception:
await bot.send_message(
chat_id=message.chat.id,
text="""<i>Cɴᴛᴀᴛ ᴅᴇᴠᴇʟᴏᴘᴇʀ (ᴏʀ) ʀᴇᴘᴏʀᴛ ʙᴜɢꜱ</i> <b>: <a href='https://t.me/Avishkarpatil'>[ ᴄʟɪᴄᴋ ʜᴇʀᴇ ]</a></b>""",
parse_mode="html",
disable_web_page_preview=True)
return
await message.reply_text(
text="""
<i>Sᴇɴᴅ ᴍᴇ ᴀɴʏ ꜰɪʟᴇ (ᴏʀ) ᴍᴇᴅɪᴀ ꜰʀᴏᴍ ᴛᴇʟᴇɢʀᴀᴍ.</i>\n
<i>I ᴡɪʟʟ ᴘʀᴏᴠɪᴅᴇ ᴇxᴛᴇʀɴᴀʟ ᴅɪʀᴇᴄᴛ ᴅᴏᴡɴʟᴏᴀᴅ ʟɪɴᴋ !.</i>\n
<u>𝗪𝗔𝗥𝗡𝗜𝗡𝗚 🚸</u>\n
<b>Pʀɴ ᴄᴏɴᴛᴇɴᴛꜱ ʟᴇᴀᴅꜱ ᴛᴏ ᴘᴇʀᴍᴀɴᴇɴᴛ ʙᴀɴ ʏ.</b>\n
<i>Cɴᴛᴀᴛ ᴅᴇᴠᴇʟᴏᴘᴇʀ (ᴏʀ) ʀᴇᴘᴏʀᴛ ʙᴜɢꜱ</i> <b>: <a href='https://t.me/Avishkarpatil'>[ ᴄʟɪᴄᴋ ʜᴇʀᴇ ]</a></b>""",
parse_mode="html",
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[InlineKeyboardButton("😍 GitHub", url="https://GitHub.com/avipatilpro")],
[InlineKeyboardButton("😎 Developer", url="https://t.me/Avishkarpatil")]
]
)
)