Seraph19 commited on
Commit
d6cafb6
·
verified ·
1 Parent(s): 272ca01

Update bot.py

Browse files
Files changed (1) hide show
  1. bot.py +29 -19
bot.py CHANGED
@@ -1,37 +1,47 @@
1
- from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
 
2
 
3
- # Your token from BotFather
4
- TELEGRAM_TOKEN = ' 7322594950:AAFS4FOOYCdDnJy6VZUM4-6T86_mA18pxjQ '
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  def start(update, context):
7
- """Send a message when the command /start is issued."""
8
- update.message.reply_text('Welcome! to santim .')
9
 
10
  def help_command(update, context):
11
- """Send a message when the command /help is issued."""
12
- update.message.reply_text('Send /distribute to receive your token.')
13
-
14
- def distribute(update, context):
15
- """Simulate token distribution (you'll add your logic here)."""
16
- # Add logic to distribute tokens to the user here
17
- update.message.reply_text('Token distribution in progress!')
18
 
19
  def main():
20
- """Start the bot."""
21
  updater = Updater(TELEGRAM_TOKEN, use_context=True)
22
-
23
- # Get the dispatcher to register handlers
24
  dp = updater.dispatcher
25
 
26
- # Register handlers for commands
27
  dp.add_handler(CommandHandler("start", start))
28
  dp.add_handler(CommandHandler("help", help_command))
29
  dp.add_handler(CommandHandler("distribute", distribute))
30
 
31
- # Start the Bot
32
  updater.start_polling()
33
-
34
- # Run the bot until you press Ctrl+C
35
  updater.idle()
36
 
37
  if __name__ == '__main__':
 
1
+ import requests
2
+ from telegram.ext import Updater, CommandHandler
3
 
4
+ # Replace with your Telegram Bot Token
5
+ TELEGRAM_TOKEN = '7303664934:AAEpvcGiCJLApkSPag6JQZcQ5ZnWVYT058E'
6
+
7
+ # Hugging Face Space API URL
8
+ HF_SPACE_URL = 'https://seraph19-santim.hf.space/token'
9
+
10
+ def distribute(update, context):
11
+ # Get the user's Telegram ID
12
+ user_id = update.message.chat_id
13
+
14
+ # Set token amount (you can adjust this)
15
+ token_amount = 10
16
+
17
+ # Send POST request to Hugging Face Space API
18
+ response = requests.post(HF_SPACE_URL, json={'user_id': user_id, 'amount': token_amount})
19
+
20
+ # Check the response from the Hugging Face Space
21
+ if response.status_code == 200:
22
+ result = response.json()
23
+ update.message.reply_text(result.get('message'))
24
+ else:
25
+ update.message.reply_text("Failed to distribute tokens. Try again later.")
26
 
27
  def start(update, context):
28
+ update.message.reply_text("Welcome! Use /distribute to receive tokens.")
 
29
 
30
  def help_command(update, context):
31
+ update.message.reply_text("Use /distribute to get tokens.")
 
 
 
 
 
 
32
 
33
  def main():
34
+ # Create Updater object and attach the bot's token
35
  updater = Updater(TELEGRAM_TOKEN, use_context=True)
 
 
36
  dp = updater.dispatcher
37
 
38
+ # Register command handlers
39
  dp.add_handler(CommandHandler("start", start))
40
  dp.add_handler(CommandHandler("help", help_command))
41
  dp.add_handler(CommandHandler("distribute", distribute))
42
 
43
+ # Start polling updates from Telegram
44
  updater.start_polling()
 
 
45
  updater.idle()
46
 
47
  if __name__ == '__main__':