import requests from telegram.ext import Updater, CommandHandler # Replace with your Telegram Bot Token TELEGRAM_TOKEN = '7303664934:AAEpvcGiCJLApkSPag6JQZcQ5ZnWVYT058E' # Hugging Face Space API URL HF_SPACE_URL = 'https://seraph19-santim.hf.space/token' def distribute(update, context): # Get the user's Telegram ID user_id = update.message.chat_id # Set token amount (you can adjust this) token_amount = 10 # Send POST request to Hugging Face Space API response = requests.post(HF_SPACE_URL, json={'user_id': user_id, 'amount': token_amount}) # Check the response from the Hugging Face Space if response.status_code == 200: result = response.json() update.message.reply_text(result.get('message')) else: update.message.reply_text("Failed to distribute tokens. Try again later.") def start(update, context): update.message.reply_text("Welcome! Use /distribute to receive tokens.") def help_command(update, context): update.message.reply_text("Use /distribute to get tokens.") def main(): # Create Updater object and attach the bot's token updater = Updater(TELEGRAM_TOKEN, use_context=True) dp = updater.dispatcher # Register command handlers dp.add_handler(CommandHandler("start", start)) dp.add_handler(CommandHandler("help", help_command)) dp.add_handler(CommandHandler("distribute", distribute)) # Start polling updates from Telegram updater.start_polling() updater.idle() if __name__ == '__main__': main()