import logging
from telegram import Update, ReplyKeyboardMarkup
from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler, MessageHandler, filters
import requests

# আপনার এপিআই কীগুলো
API_KEYS = {
    "GrizzlySMS": "812901ff8d5f280fcd4d123421d47a23",
    "HeroSMS": "e90A2dAc004e0541bf47A9e8b6855265",
    "SMSBower": "RyPhDKLxqsL8Pk8dhnQkDiI8nujxaaYj"
}

# লগিং সেটআপ
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)

# শুরুর মেনু
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
    reply_keyboard = [['GrizzlySMS', 'HeroSMS', 'SMSBower']]
    await update.message.reply_text(
        'স্বাগতম! আপনি কোন সার্ভিসটি ব্যবহার করতে চান?',
        reply_markup=ReplyKeyboardMarkup(reply_keyboard, one_time_keyboard=True)
    )

# সার্ভিস হ্যান্ডলার
async def handle_service(update: Update, context: ContextTypes.DEFAULT_TYPE):
    service = update.message.text
    if service in API_KEYS:
        context.user_data['selected_service'] = service
        await update.message.reply_text(f"{service} সিলেক্ট হয়েছে। এখন আপনার কমান্ড দিন (যেমন: /getnumber বা /getotp)")
    else:
        await update.message.reply_text("দয়া করে মেনু থেকে একটি সার্ভিস সিলেক্ট করুন।")

# নাম্বার নেওয়ার ফাংশন
async def get_number(update: Update, context: ContextTypes.DEFAULT_TYPE):
    service = context.user_data.get('selected_service')
    api_key = API_KEYS.get(service)
    
    # এখানে আপনার সাইটের নির্দিষ্ট এন্ডপয়েন্ট বসবে (উদাহরণস্বরূপ)
    # response = requests.get(f"https://{service.lower()}.com/api?key={api_key}&action=get_number")
    
    await update.message.reply_text(f"{service} থেকে নাম্বার নেওয়ার রিকোয়েস্ট পাঠানো হয়েছে (এপিআই এন্ডপয়েন্ট অনুযায়ী ইউআরএল সেট করতে হবে)।")

if __name__ == '__main__':
    application = ApplicationBuilder().token('8834393357:AAHwGJHz-qNZznxd0gikxpe8B_cfwpXFqVE').build()
    
    application.add_handler(CommandHandler("start", start))
    application.add_handler(CommandHandler("getnumber", get_number))
    application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_service))
    
    application.run_polling()