From 76caf627abfa22432076db2d85a28da101614316 Mon Sep 17 00:00:00 2001
From: Avi Patil <67785446+avipatilpro@users.noreply.github.com>
Date: Sun, 2 May 2021 21:44:27 +0530
Subject: [PATCH] Initial Commit
---
WebStreamer/bot/plugins/start.py | 190 +++++++++++++++++++++++++++++++
1 file changed, 190 insertions(+)
create mode 100644 WebStreamer/bot/plugins/start.py
diff --git a/WebStreamer/bot/plugins/start.py b/WebStreamer/bot/plugins/start.py
new file mode 100644
index 00000000..3c4527bd
--- /dev/null
+++ b/WebStreamer/bot/plugins/start.py
@@ -0,0 +1,190 @@
+
+
+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="""Cᴏɴᴛᴀᴄᴛ ᴅᴇᴠᴇʟᴏᴘᴇʀ (ᴏʀ) ʀᴇᴘᴏʀᴛ ʙᴜɢꜱ : [ ᴄʟɪᴄᴋ ʜᴇʀᴇ ]""",
+ parse_mode="html",
+ disable_web_page_preview=True)
+ return
+ await message.reply_text(
+ text="""
+Sᴇɴᴅ ᴍᴇ ᴀɴʏ ꜰɪʟᴇ (ᴏʀ) ᴍᴇᴅɪᴀ ꜰʀᴏᴍ ᴛᴇʟᴇɢʀᴀᴍ.\n
+I ᴡɪʟʟ ᴘʀᴏᴠɪᴅᴇ ᴇxᴛᴇʀɴᴀʟ ᴅɪʀᴇᴄᴛ ᴅᴏᴡɴʟᴏᴀᴅ ʟɪɴᴋ !.\n
+𝗪𝗔𝗥𝗡𝗜𝗡𝗚 🚸\n
+Pʀᴏɴ ᴄᴏɴᴛᴇɴᴛꜱ ʟᴇᴀᴅꜱ ᴛᴏ ᴘᴇʀᴍᴀɴᴇɴᴛ ʙᴀɴ ʏᴏᴜ.\n
+Cᴏɴᴛᴀᴄᴛ ᴅᴇᴠᴇʟᴏᴘᴇʀ (ᴏʀ) ʀᴇᴘᴏʀᴛ ʙᴜɢꜱ : [ ᴄʟɪᴄᴋ ʜᴇʀᴇ ]""",
+
+ 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")]
+ ]
+ )
+ )