for key, keyinfo in keys.items(): if 'redeemed' in keyinfo and keyinfo['redeemed']:…
- User
for key, key_info in keys.items(): if 'redeemed' in key_info and key_info['redeemed']: expiry_date = datetime.fromisoformat(key_info['expires_at']) if current_time <= expiry_date and not key_info.get('expired', False): active_users_count += 1 return active_users_count @bot.message_handler(commands=['status']) def status_command(message): user_id = str(message.from_user.id) if not is_user_authorized(user_id): bot.send_message(message.chat.id, "⛔ Access Forbidden\n\n" "Please redeem a key first using /redeem\n" "Need a key? Contact @anetjaka" ) return keys = load_keys() users = load_users() user_info = users.get(user_id, {}) if not user_info or 'redeemed_key' not in user_info: bot.send_message(message.chat.id, "❌ No active key found.") return redeemed_key = user_info['redeemed_key'] key_info = keys.get(redeemed_key, {}) now = datetime.now() if 'expires_at' in key_info: try: expiry_date = datetime.fromisoformat(key_info['expires_at']) if now > expiry_date: bot.send_message(message.chat.id, "🚨 KEY EXPIRED 🚨\n\n" f"📇 User ID: {user_id}\n" f"⏰ Expiration: {key_info['expires_at']}\n\n" "🔑 Your key has expired\n" "💡 DM @anetjaka to renew your access", parse_mode='Markdown' ) return time_remaining = expiry_date - now days = time_remaining.days hours, remainder = divmod(time_remaining.seconds, 3600) minutes, seconds = divmod(remainder, 60) search_count_data = load_search_count() total_searches = search_count_data.get('total_searches', 0) total_active_users = count_active_users() bot.send_message(message.chat.id, "📊 Status Information\n" "━━━━━━━━━━━━━━━\n\n" f"👤 User ID: {user_id}\n\n" "⏳ Time Remaining:\n" f" • {days} days\n" f" • {hours} hours\n" f" • {minutes} minutes\n\n" f"🔎 Total Searches: {total_searches}\n" f"👥 Active Users: {total_active_users}\n" # New line showing active users f"📅 Key Redeemed: {user_info.get('redeemed_at', 'N/A')}\n" f"⌛ Expires: {key_info['expires_at']}\n\n" "⚠️ Renew your key before expiration\n" "💡 Contact @anetjaka for renewal", parse_mode='Markdown' ) except ValueError: bot.send_message(message.chat.id, "❌ Error: Invalid expiration date. Contact support.") else: bot.send_message(message.chat.id, "❌ Error: No expiration information found. Contact support.") @bot.message_handler(commands=['redeem']) def redeem_command(message): bot.send_message(message.chat.id, "🎫 Key Redemption\n" "━━━━━━━━━━━━\n\n" "Please send your redemption key\n\n" "💡 Don't have a key?\n" "Contact @anetjaka to purchase one" ) bot.register_next_step_handler(message, process_key_redemption) def process_key_redemption(message): user_id = str(message.from_user.id) key = message.text.strip() success, response_message = redeem_key(user_id, key) if success: bot.send_message(message.chat.id, "✅ Key Redemption Successful!\n" "━━━━━━━━━━━━━━━━━━━━\n\n" "🔑 Your key has been activated\n" "📝 You now have access to the database\n\n" "Available Commands:\n"
- Assistant