# Jishu Developer # Don't Remove Credit 🄺 # Telegram Channel @Madflix_Bots # Backup Channel @JishuBotz # Developer @JishuDeveloper import os import asyncio from pyrogram import Client, filters, __version__ from pyrogram.enums import ParseMode from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery from pyrogram.errors import FloodWait, UserIsBlocked, InputUserDeactivated from bot import Bot from config import ADMINS, FORCE_MSG, START_MSG, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, PROTECT_CONTENT from helper_func import subscribed, encode, decode, get_messages from database.database import add_user, del_user, full_userbase, present_user # add time im seconds for waitingwaiting before delete # 1 minutes = 60, 2 minutes = 60Ɨ2=120, 5 minutes = 60Ɨ5=300 SECONDS = int(os.getenv("SECONDS", "600")) @Bot.on_message(filters.command('start') & filters.private & subscribed) async def start_command(client: Client, message: Message): id = message.from_user.id if not await present_user(id): try: await add_user(id) except: pass text = message.text if len(text)>7: try: base64_string = text.split(" ", 1)[1] except: return string = await decode(base64_string) argument = string.split("-") if len(argument) == 3: try: start = int(int(argument[1]) / abs(client.db_channel.id)) end = int(int(argument[2]) / abs(client.db_channel.id)) except: return if start <= end: ids = range(start,end+1) else: ids = [] i = start while True: ids.append(i) i -= 1 if i < end: break elif len(argument) == 2: try: ids = [int(int(argument[1]) / abs(client.db_channel.id))] except: return temp_msg = await message.reply("Please wait...") try: messages = await get_messages(client, ids) except: await message.reply_text("Something went wrong..!") return await temp_msg.delete() for msg in messages: if bool(CUSTOM_CAPTION) & bool(msg.document): caption = CUSTOM_CAPTION.format(previouscaption = "" if not msg.caption else msg.caption.html, filename = msg.document.file_name) else: caption = "" if not msg.caption else msg.caption.html if DISABLE_CHANNEL_BUTTON: reply_markup = msg.reply_markup else: reply_markup = None try: f = await msg.copy(chat_id=message.from_user.id, caption = caption, parse_mode = ParseMode.HTML, reply_markup = reply_markup, protect_content=PROTECT_CONTENT) except FloodWait as e: await asyncio.sleep(e.x) f = await msg.copy(chat_id=message.from_user.id, caption = caption, parse_mode = ParseMode.HTML, reply_markup = reply_markup, protect_content=PROTECT_CONTENT) except: pass k = await client.send_message(chat_id = message.from_user.id, text=f"ā—ļø IMPORTANT ā—ļø\n\nThis video / file will be deleted in 10 minutes (Due to copyright issues).\n\nšŸ“Œ Please forward this video / file to somewhere else and start downloading there.") await asyncio.sleep(SECONDS) await f.delete() await k.edit_text("Your video / file is successfully deleted !") return else: reply_markup = InlineKeyboardMarkup( [ [ InlineKeyboardButton("😊 About Me", callback_data = "about"), InlineKeyboardButton("šŸ”’ Close", callback_data = "close") ] ] ) await message.reply_text( text = START_MSG.format( first = message.from_user.first_name, last = message.from_user.last_name, username = None if not message.from_user.username else '@' + message.from_user.username, mention = message.from_user.mention, id = message.from_user.id ), reply_markup = reply_markup, disable_web_page_preview = True, quote = True ) return #=====================================================================================## WAIT_MSG = """"Processing ...""" REPLY_ERROR = """Use this command as a replay to any telegram message with out any spaces.""" #=====================================================================================## @Bot.on_message(filters.command('start') & filters.private) async def not_joined(client: Client, message: Message): buttons = [ [ InlineKeyboardButton(text="Join Channel", url=client.invitelink) ] ] try: buttons.append( [ InlineKeyboardButton( text = 'Try Again', url = f"https://t.me/{client.username}?start={message.command[1]}" ) ] ) except IndexError: pass await message.reply( text = FORCE_MSG.format( first = message.from_user.first_name, last = message.from_user.last_name, username = None if not message.from_user.username else '@' + message.from_user.username, mention = message.from_user.mention, id = message.from_user.id ), reply_markup = InlineKeyboardMarkup(buttons), quote = True, disable_web_page_preview = True ) @Bot.on_message(filters.command('users') & filters.private & filters.user(ADMINS)) async def get_users(client: Bot, message: Message): msg = await client.send_message(chat_id=message.chat.id, text=WAIT_MSG) users = await full_userbase() await msg.edit(f"{len(users)} users are using this bot") @Bot.on_message(filters.private & filters.command('broadcast') & filters.user(ADMINS)) async def send_text(client: Bot, message: Message): if message.reply_to_message: query = await full_userbase() broadcast_msg = message.reply_to_message total = 0 successful = 0 blocked = 0 deleted = 0 unsuccessful = 0 pls_wait = await message.reply("Broadcasting Message.. This will Take Some Time") for chat_id in query: try: await broadcast_msg.copy(chat_id) successful += 1 except FloodWait as e: await asyncio.sleep(e.x) await broadcast_msg.copy(chat_id) successful += 1 except UserIsBlocked: await del_user(chat_id) blocked += 1 except InputUserDeactivated: await del_user(chat_id) deleted += 1 except: unsuccessful += 1 pass total += 1 status = f"""Broadcast Completed Total Users: {total} Successful: {successful} Blocked Users: {blocked} Deleted Accounts: {deleted} Unsuccessful: {unsuccessful}""" return await pls_wait.edit(status) else: msg = await message.reply(REPLY_ERROR) await asyncio.sleep(8) await msg.delete() # Jishu Developer # Don't Remove Credit 🄺 # Telegram Channel @Madflix_Bots # Backup Channel @JishuBotz # Developer @JishuDeveloper