if update.callback_query: await update.callback_query.edit_message_text(help_text, parse_mode='Markdown') else: await update.message.reply_text(help_text, parse_mode='Markdown') async def add_xtream(update: Update, context: ContextTypes.DEFAULT_TYPE): """Admin: Add new Xtream code (format: /add_xtream url username password days)""" if update.effective_user.id not in ADMIN_IDS: await update.message.reply_text("⛔ Admin only command!") return
code_id, mac_address, server_url, portal_name, expiry = code
# Xtream Codes methods def add_xtream_code(self, server_url, username, password, max_conn=1, expiry_days=30): expiry = datetime.now() + timedelta(days=expiry_days) cursor = self.conn.cursor() cursor.execute(''' INSERT INTO xtream_codes (server_url, username, password, max_connections, expiry_date) VALUES (?, ?, ?, ?, ?) ''', (server_url, username, password, max_conn, expiry)) self.conn.commit() return cursor.lastrowid Stbemu Codes and Xtream Codes - Telegram channel
# Get available STBEmu code code = db.get_active_stbemu_code() if not code: await update.callback_query.edit_message_text( "❌ No STBEmu codes available at the moment." ) return
Commands: /start - Start the bot /mycodes - Check your active codes /help - Show this help if update
# Start bot print("🤖 Bot is running...") application.run_polling(allowed_updates=Update.ALL_TYPES) if == ' main ': main() 3. Requirements File # requirements.txt python-telegram-bot==20.7 python-dotenv==1.0.0 4. Environment Configuration # .env file TELEGRAM_BOT_TOKEN=your_bot_token_here ADMIN_IDS=123456789,987654321 5. Docker Setup (Optional) # Dockerfile FROM python:3.9-slim WORKDIR /app
COPY . .
# Admin commands application.add_handler(CommandHandler("add_xtream", add_xtream)) application.add_handler(CommandHandler("add_stbemu", add_stbemu)) application.add_handler(CommandHandler("stats", stats))