File size: 1,536 Bytes
d6cafb6
 
cf8b9d7
d6cafb6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cf8b9d7
 
d6cafb6
cf8b9d7
 
d6cafb6
cf8b9d7
 
d6cafb6
cf8b9d7
 
 
d6cafb6
cf8b9d7
 
 
 
d6cafb6
cf8b9d7
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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()