Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Constants as keys
- from telegram.ext import *
- import DiceRoller
- import Responses as R
- #import DiceRoller as D
- global player_credits
- player_credits = 5000
- print("Bot Start.....")
- def start_command(update, context):
- update.message.reply_text('Type something random to get started!')
- def help_command(update, context):
- update.message.reply_text('If you need help then you should use Google')
- def handle_message(update, context):
- text = str(update.message.text).lower() # receives the text from user
- response = R.sample_responses(text) # processes the text from the user
- update.message.reply_text(response) # puts text back out based on text input
- def error(update, context):
- print(f"Update {update} caused error {context.error}")
- def main():
- updater = Updater(keys.API_KEY, use_context=True) # starts the program
- dp = updater.dispatcher
- dp.add_handler(CommandHandler("start", start_command))
- dp.add_handler(CommandHandler("help", help_command))
- dp.add_handler(MessageHandler(Filters.text, handle_message))
- dp.add_error_handler(error)
- updater.start_polling() # starts the bot
- updater.idle() # sets the bot to idle (prevents it from turning itself off)
- main()
Add Comment
Please, Sign In to add comment