Initial Commit

This commit is contained in:
Avi Patil
2024-01-06 22:31:43 +05:30
parent 7b35887bc3
commit d6ec5ff4d6
6 changed files with 75 additions and 32 deletions

View File

@@ -10,6 +10,7 @@ from FileStream.utils.translation import LANG, BUTTON
from pyrogram import filters, Client
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message
from pyrogram.enums.parse_mode import ParseMode
import asyncio
db = Database(Telegram.DATABASE_URL, Telegram.SESSION_NAME)
@@ -63,7 +64,14 @@ async def start(bot: Client, message: Message):
file_id = file_check['file_id']
file_name = file_check['file_name']
if db_id == usr_cmd:
await message.reply_cached_media(file_id=file_id, caption=f'**{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**")

View File

@@ -31,7 +31,7 @@ async def private_receive_handler(bot: Client, message: Message):
return
await is_user_exist(bot, message)
if Telegram.FORCE_UPDATES_CHANNEL:
if Telegram.FORCE_SUB:
if not await is_user_joined(bot, message):
return
try:

View File

@@ -12,8 +12,9 @@ class Telegram:
DATABASE_URL = str(env.get('DATABASE_URL'))
UPDATES_CHANNEL = str(env.get('UPDATES_CHANNEL', "Telegram"))
SESSION_NAME = str(env.get('SESSION_NAME', 'FileStream'))
FORCE_UPDATES_CHANNEL = env.get('FORCE_UPDATES_CHANNEL', False)
FORCE_UPDATES_CHANNEL = True if str(FORCE_UPDATES_CHANNEL).lower() == "true" else False
FORCE_SUB_ID = env.get('FORCE_SUB_ID', None)
FORCE_SUB = env.get('FORCE_UPDATES_CHANNEL', False)
FORCE_SUB = True if str(FORCE_SUB).lower() == "true" else False
SLEEP_THRESHOLD = int(env.get("SLEEP_THRESHOLD", "60"))
FILE_PIC = env.get('FILE_PIC', "https://graph.org/file/5bb9935be0229adf98b73.jpg")
START_PIC = env.get('START_PIC', "https://graph.org/file/290af25276fa34fa8f0aa.jpg")

View File

@@ -1,4 +1,4 @@
from pyrogram.errors import UserNotParticipant
from pyrogram.errors import UserNotParticipant, FloodWait
from pyrogram.enums.parse_mode import ParseMode
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message
from FileStream.utils.translation import LANG
@@ -6,12 +6,32 @@ from FileStream.utils.database import Database
from FileStream.utils.human_readable import humanbytes
from FileStream.config import Telegram, Server
from FileStream.bot import FileStream
import asyncio
from typing import (
Union
)
db = Database(Telegram.DATABASE_URL, Telegram.SESSION_NAME)
async def is_user_joined(bot, message: Message):
async def get_invite_link(bot, chat_id: Union[str, int]):
try:
user = await bot.get_chat_member(Telegram.UPDATES_CHANNEL, message.chat.id)
invite_link = await bot.create_chat_invite_link(chat_id=chat_id)
return invite_link
except FloodWait as e:
print(f"Sleep of {e.value}s caused by FloodWait ...")
await asyncio.sleep(e.value)
return await get_invite_link(bot, chat_id)
async def is_user_joined(bot, message: Message):
if Telegram.FORCE_SUB_ID and Telegram.FORCE_SUB_ID.startswith("-100"):
channel_chat_id = int(Telegram.FORCE_SUB_ID) # When id startswith with -100
elif Telegram.FORCE_SUB_ID and (not Telegram.FORCE_SUB_ID.startswith("-100")):
channel_chat_id = Telegram.FORCE_SUB_ID # When id not startswith -100
else:
return 200
try:
user = await bot.get_chat_member(chat_id=channel_chat_id, user_id=message.from_user.id)
if user.status == "BANNED":
await message.reply_text(
text=LANG.BAN_TEXT.format(Telegram.OWNER_ID),
@@ -20,27 +40,34 @@ async def is_user_joined(bot, message: Message):
)
return False
except UserNotParticipant:
invite_link = await get_invite_link(bot, chat_id=channel_chat_id)
if Telegram.VERIFY_PIC:
await message.reply_photo(
ver = await message.reply_photo(
photo=Telegram.VERIFY_PIC,
caption="<i>Jɪɴ ᴍʏ ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ ᴛᴏ sᴇ ᴍᴇ 🔐</i>",
parse_mode=ParseMode.HTML,
reply_markup=InlineKeyboardMarkup(
[[
InlineKeyboardButton("Jɪɴ ɴᴏᴡ 🔓", url=f"https://t.me/{Telegram.UPDATES_CHANNEL}")
]]
[[
InlineKeyboardButton("Jɪɴ Oʀ Cʜᴀɴɴᴇʟ ❆", url=invite_link.invite_link)
]]
)
)
else:
await message.reply_text(
text="<i>Jɪɴ ᴍʏ ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ ᴛᴏ sᴇ ᴍᴇ 🔐</i>",
ver = await message.reply_text(
text = "<i>Jɪɴ ᴍʏ ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ ᴛᴏ sᴇ ᴍᴇ 🔐</i>",
reply_markup=InlineKeyboardMarkup(
[[
InlineKeyboardButton("Jɪɴ ɴᴏᴡ 🔓", url=f"https://t.me/{Telegram.UPDATES_CHANNEL}")
InlineKeyboardButton("Jɪɴ Oʀ Cʜᴀɴɴᴇʟ ❆", url=invite_link.invite_link)
]]
),
parse_mode=ParseMode.HTML
)
await asyncio.sleep(30)
try:
await ver.delete()
await message.delete()
except Exception:
pass
return False
except Exception:
await message.reply_text(
@@ -182,7 +209,7 @@ async def verify_user(bot, message):
await is_user_exist(bot, message)
if Telegram.FORCE_UPDATES_CHANNEL:
if Telegram.FORCE_SUB:
if not await is_user_joined(bot, message):
return False