bot.reply_to(message, "⛔ This command is restricted to admin use only.")
        return
    keys = load_keys()
    users = load_users()
    if not keys:
        bot.reply_to(message, "No keys found in the database.")
        return
    response = "🔑 Keys Status:\n\n"
    for key, info in keys.items():
        expiry_date = datetime.fromisoformat(info['expires_at'])
        is_expired = datetime.now() > expiry_date
        is_redeemed = info.get('redeemed', False)
        redeemed_by = info.get('redeemed_by', 'None')
        status = "🔴 Expired" if is_expired else "🟢 Active"
        if is_redeemed:
            status += " (Redeemed)"
        response += f"Key: {key}\n"
        response += f"Status: {status}\n"
        response += f"Expires: {info['expires_at']}\n"
        response += f"Redeemed: {'Yes' if is_redeemed else 'No'}\n"
        if is_redeemed and redeemed_by in users:
            user_info = users[redeemed_by]
            response += f"Redeemed By: {redeemed_by}\n"
            response += f"Redeemed At: {user_info.get('redeemed_at', 'Unknown')}\n"
        response += "\n"
        if len(response) > 3500:
            bot.reply_to(message, response, parse_mode='Markdown')
            response = "Continuing...\n\n"
    if response:
        bot.reply_to(message, response, parse_mode='Markdown')
@bot.message_handler(commands=['delete'])
def delete_key_command(message):
    if message.from_user.username != 'anetjaka':
        bot.reply_to(message, "⛔ This command is restricted to admin use only.")
        return
    params = message.text.split()
    if len(params) != 2:
        bot.reply_to(message, "Usage: /delkey <key>")
        return
    key_to_delete = params[1]
    keys = load_keys()
    if key_to_delete in keys:
        del keys[key_to_delete]
        save_keys(keys)
        bot.reply_to(message, f"✅ Key {key_to_delete} has been deleted.", parse_mode='Markdown')
    else:
        bot.reply_to(message, "❌ Key not found.")
def generate_keys(num_keys, validity_days):
    keys = {}
    for _ in range(num_keys):
        key = secrets.token_urlsafe(16)
        keys[key] = {
            "created_at": datetime.now().isoformat(),
            "redeemed": False,
            "expires_at": (datetime.now() + timedelta(days=validity_days)).isoformat(),
            "validity_days": validity_days
        }
    return keys
@bot.message_handler(commands=['search'])
def search_command(message):
    user_id = str(message.from_user.id)
    if not is_user_authorized(user_id):
        bot.send_message(message.chat.id, 
            "⛔ Access Denied\n"
            "━━━━━━━━━━\n\n"
            "🔐 You need an active key to search\n"
            "📝 Use /redeem to activate your access\n\n"
            "💡 Need a key? Contact @anetjaka"
        )
        return
    search_message = (
        "🔍 Database Search\n"
        "━━━━━━━━━━━━\n\n"
        "Enter what you want to search:\n\n"
        "📌 Examples:\n"
        "• garena.com,\n"
        "• mobilelegends\n"
        "• roblox.com\n"
        "• and many more paldo sites\n\n"
        "💡 Tip: More specific = better results"
    )
    bot.send_message(message.chat.id, search_message)
    bot.register_next_step_handler(message, handle_search)
def handle_search(message):
    track_user(message)
    user_id = str(message.from_user.id)
    search_query = message.text.strip()
    if len(search_query) < 3:
        bot.reply_to(message, 
            "❌ Query Too Short\n"
            "━━━━━━━━━━━━\n\n"
            "🔍 Please enter at least 3 characters\n"
            "💡 Example: 'facebook.com' or 'gmail.com'"
        )
        return