from datetime import date as date_ import os, re, datetime, random, asyncio, time, humanize from script import * from pyrogram.errors import UserNotParticipant from pyrogram import Client, filters, enums from pyrogram.types import (InlineKeyboardButton, InlineKeyboardMarkup) from helper.progress import humanbytes from helper.database import botdata, find_one, total_user from helper.database import insert, find_one, used_limit, usertype, uploadlimit, addpredata, total_rename, total_size from pyrogram.file_id import FileId from helper.database import daily as daily_ from helper.date import check_expi from config import * token = BOT_TOKEN botid = token.split(':')[0] @Client.on_message(filters.private & filters.command(["start"])) async def start(client, message): user_id = message.chat.id old = insert(int(user_id)) if old != True: try: user = find_one(user_id) user_plan = user.get("usertype", "Free") await client.send_message(LOG_CHANNEL, f"💌 New User Started The Bot!\n\nUser ID : {user_id}\nFirst Name : {message.from_user.first_name}\nLast Name : {message.from_user.last_name or 'None'}\nUser Name : @{message.from_user.username or 'None'}\nUser Mention : {message.from_user.mention}\nUser Link : Click Here\nUser Plan : {user_plan}") except Exception as e: print(f"Logging Error: {e}") try: id = message.text.split(' ')[1] except IndexError: id = None loading_sticker_message = await message.reply_sticker("CAACAgIAAxkBAALmzGXSSt3ppnOsSl_spnAP8wHC26jpAAJEGQACCOHZSVKp6_XqghKoHgQ") await asyncio.sleep(2) await loading_sticker_message.delete() if FORCE_SUBS: try: user = await client.get_chat_member(FORCE_SUBS, user_id) if user.status == enums.ChatMemberStatus.BANNED: await message.reply_text("Sorry, You Are Banned To Use Me.") return except UserNotParticipant: await message.reply_text( text="""💌 Access Denied!\n\nTo maintain our High-Speed Renaming infrastructure, we require all users to be part of our community.\n\n⚡️ Kindly Join @dragbotsupport to unlock all features.""", reply_markup=InlineKeyboardMarkup([ [InlineKeyboardButton("🔺 Join Update Channel 🔺", url=f"https://t.me/{FORCE_SUBS}")] ]) ) return text = f"""💌 Welcome, {message.from_user.mention}!\n\n🚀 Experience the next level of Auto Renaming with unmatched speed and precision.\n\n📁 High-End Features:\n • Renaming with custom metadata.\n • Thumbnail management with ease.\n • Convert between Files and Videos.\n • Fast & Secure processing.\n\n⚡️ Built for efficiency, designed for you.\n\nBot Managed By @dragbotsupport""" buttons = [ [InlineKeyboardButton("Updates", url="https://t.me/dragbots", icon_custom_emoji_id=5443038326535759644), InlineKeyboardButton("Support", url="https://t.me/dragbotsupport", icon_custom_emoji_id=5462921117423384478)], [InlineKeyboardButton("Help", callback_data='help', icon_custom_emoji_id=5375074927252621134), InlineKeyboardButton("About", callback_data='about', icon_custom_emoji_id=5224607267797606837)], [InlineKeyboardButton("Stats", callback_data="stats", icon_custom_emoji_id=5042290883949495533)], [InlineKeyboardButton("Developer", url="https://t.me/lungiiman", icon_custom_emoji_id=5150078684585002132)] ] await message.reply_photo( photo=START_PIC, caption=text, reply_markup=InlineKeyboardMarkup(buttons), quote=True ) return @Client.on_message((filters.private & (filters.document | filters.audio | filters.video)) | filters.channel & (filters.document | filters.audio | filters.video)) async def send_doc(client, message): user_id = message.chat.id old = insert(int(user_id)) user_id = message.from_user.id if FORCE_SUBS: try: await client.get_chat_member(FORCE_SUBS, user_id) except UserNotParticipant: _newus = find_one(message.from_user.id) user = _newus["usertype"] await message.reply_text("Hello Dear \n\nYou Need To Join In My Channel To Use Me\n\nKindly Please Join Channel", reply_to_message_id=message.id, reply_markup=InlineKeyboardMarkup([ [InlineKeyboardButton("🔺 Update Channel 🔺", url=f"https://t.me/{FORCE_SUBS}")] ])) await client.send_message(LOG_CHANNEL, f"New User Started The Bot \n\nUser ID : {user_id} \nFirst Name : {message.from_user.first_name} \nLast Name : {message.from_user.last_name} \nUser Name : @{message.from_user.username} \nUser Mention : {message.from_user.mention} \nUser Link : Click Here \nUser Plan : {user}") return botdata(int(botid)) user_deta = find_one(user_id) daily = user_deta.get("daily", 0) c_time = time.time() LIMIT = 10 # Standard limit or remove if not needed, keeping it simple for now used_date = user_deta.get("date", 0) then = used_date + LIMIT left = round(then - c_time) conversion = datetime.timedelta(seconds=left) ltime = str(conversion) if left > 0: await message.reply_text(f"Sorry Dude I Am Not Only For You \n\nFlood Control Is Active So Please Wait For {ltime} ", reply_to_message_id=message.id) else: # Forward a single message media = await client.get_messages(message.chat.id, message.id) file = media.document or media.video or media.audio dcid = FileId.decode(file.file_id).dc_id filename = file.file_name file_id = file.file_id used_ = find_one(message.from_user.id) used = used_.get("used_limit", 0) limit = used_.get("uploadlimit", 5368709120) # Default to 5GB or similar expi = daily - int(time.mktime(time.strptime(str(date_.today()), '%Y-%m-%d'))) if expi != 0: today = date_.today() pattern = '%Y-%m-%d' epcho = int(time.mktime(time.strptime(str(today), pattern))) daily_(message.from_user.id, epcho) used_limit(message.from_user.id, 0) used = 0 remain = limit - used if remain < int(file.file_size): await message.reply_text(f"100% Of Daily {humanbytes(limit)} Data Quota Exhausted.\n\nFile Size Detected : {humanbytes(file.file_size)}\nUsed Daily Limit : {humanbytes(used)}\n\nYou Have Only {humanbytes(remain)} Left On Your Account.") return filesize = humanize.naturalsize(file.file_size) await message.reply_text(f"""__What Do You Want Me To Do With This File ?__\n\n**File Name :** `{filename}`\n**File Size :** {filesize}\n**DC ID :** {dcid}""", reply_to_message_id=message.id, reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("Rename", callback_data="rename", icon_custom_emoji_id=5985386442824619877), InlineKeyboardButton("Set Caption", callback_data="instant_caption", icon_custom_emoji_id=5316994101688677895)], [InlineKeyboardButton("Cancel", callback_data="cancel")]]))