Untitled
from telegram import Update, ReplyKeyboardMarkup from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext # Liste des commandes (numéro, type de commande, montant) commands = { "12345": {"type": "Commande A", "amount": 100}, "67890": {"type": "Commande B", "amount": 200} } # Fonction pour démarrer le bot def start(update: Update, context: CallbackContext): keyboard = [ ['Mes commandes', 'Payer une commande'] ] reply_markup = ReplyKeyboardMarkup(keyboard, one_time_keyboard=True) update.message.reply_text("Bienvenue ! Choisissez une option :", reply_markup=reply_markup) # Fonction pour afficher les commandes def my_orders(update: Update, context: CallbackContext): update.message.reply_text("Aucune commande trouvée.") # Fonction pour payer une commande def pay_order(update: Update, context: CallbackContext): update.message.reply_text("Veuillez entrer votre numéro de commande:") # Fonction pour vérifier la commande def check_order(update: Update, context: CallbackContext): order_id = update.message.text if order_id in commands: order = commands[order_id] keyboard = [ ['Confirmer', 'Annuler'] ] reply_markup = ReplyKeyboardMarkup(keyboard, one_time_keyboard=True) response = f"Commande: {order_id}\nType: {order['type']}\nMontant: {order['amount']} EUR" update.message.reply_text(response, reply_markup=reply_markup) else: update.message.reply_text("Numéro de commande introuvable.") # Fonction pour confirmer la commande def confirm_order(update: Update, context: CallbackContext): keyboard = [ ['Bitcoin', 'Litecoin', 'Ethereum'] ] reply_markup = ReplyKeyboardMarkup(keyboard, one_time_keyboard=True) update.message.reply_text("Choisissez votre moyen de paiement :", reply_markup=reply_markup) # Fonction pour gérer les paiements def handle_payment(update: Update, context: CallbackContext): payment_method = update.message.text if payment_method == 'Bitcoin': update.message.reply_text("Adresse Bitcoin: 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa\nTransaction en attente...") elif payment_method == 'Litecoin': update.message.reply_text("Adresse Litecoin: LfRaFXs5fLxX4bRqq2t47ACVHDkr5oQ2X5\nTransaction en attente...") elif payment_method == 'Ethereum': update.message.reply_text("Adresse Ethereum: 0x6cB2A0e27fA8Ff2148C6b42C7e4406F49BCfdce8\nTransaction en attente...") else: update.message.reply_text("Moyen de paiement non reconnu.") # Fonction pour annuler l'action def cancel(update: Update, context: CallbackContext): start(update, context) # Configuration des handlers def main(): token = 'TON_TOKEN' # Remplace par le token de ton bot updater = Updater(token) dispatcher = updater.dispatcher # Commandes dispatcher.add_handler(CommandHandler('start', start)) # Réponses aux messages dispatcher.add_handler(MessageHandler(Filters.regex('^Mes commandes$'), my_orders)) dispatcher.add_handler(MessageHandler(Filters.regex('^Payer une commande$'), pay_order)) # Gestion de la commande dispatcher.add_handler(MessageHandler(Filters.text & ~Filters.command, check_order)) # Confirmation ou annulation dispatcher.add_handler(MessageHandler(Filters.regex('^Confirmer$'), confirm_order)) dispatcher.add_handler(MessageHandler(Filters.regex('^Annuler$'), cancel)) # Paiement dispatcher.add_handler(MessageHandler(Filters.regex('^(Bitcoin|Litecoin|Ethereum)$'), handle_payment)) # Lancer le bot updater.start_polling() updater.idle() if __name__ == '__main__': main()
Leave a Comment