Placido_GDD

Bot_Mainfile

Jul 23rd, 2022 (edited)
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. import Constants as keys
  2. from telegram.ext import *
  3.  
  4. import DiceRoller
  5. import Responses as R
  6. #import DiceRoller as D
  7.  
  8. global player_credits
  9. player_credits = 5000
  10. print("Bot Start.....")
  11.  
  12.  
  13. def start_command(update, context):
  14.     update.message.reply_text('Type something random to get started!')
  15.  
  16.  
  17. def help_command(update, context):
  18.     update.message.reply_text('If you need help then you should use Google')
  19.  
  20.  
  21. def handle_message(update, context):
  22.     text = str(update.message.text).lower()  # receives the text from user
  23.     response = R.sample_responses(text)  # processes the text from the user
  24.     update.message.reply_text(response)  # puts text back out based on text input
  25.  
  26.  
  27. def error(update, context):
  28.     print(f"Update {update} caused error {context.error}")
  29.  
  30.  
  31. def main():
  32.     updater = Updater(keys.API_KEY, use_context=True)  # starts the program
  33.     dp = updater.dispatcher
  34.  
  35.     dp.add_handler(CommandHandler("start", start_command))
  36.     dp.add_handler(CommandHandler("help", help_command))
  37.     dp.add_handler(MessageHandler(Filters.text, handle_message))
  38.     dp.add_error_handler(error)
  39.     updater.start_polling()  # starts the bot
  40.     updater.idle()  # sets the bot to idle (prevents it from turning itself off)
  41.  
  42.  
  43. main()
  44.  
Add Comment
Please, Sign In to add comment