Advertisement
awsmpshk

Untitled

Apr 7th, 2020
181
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import logging
  2.  
  3. from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
  4. from settings import*
  5.  
  6. # Enable logging
  7. logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
  8.                     level=logging.INFO)
  9.  
  10. logger = logging.getLogger(__name__)
  11.  
  12. def start(update, context):
  13.     update.message.reply_text('Hi!')
  14.  
  15.  
  16. def help(update, context):
  17.     update.message.reply_text('Help!')
  18.  
  19.  
  20. def echo(update, context):
  21.     update.message.reply_text(update.message.text)
  22.  
  23.  
  24. def error(update, context):
  25.     logger.warning('Update "%s" caused error "%s"', update, context.error)
  26.  
  27.  
  28. def main():
  29.     updater = Updater(BOT_TOKEN, use_context=True)
  30.     dp = updater.dispatcher
  31.     dp.add_handler(CommandHandler("start", start))
  32.     dp.add_handler(CommandHandler("help", help))
  33.     dp.add_handler(MessageHandler(Filters.text, echo))
  34.     dp.add_error_handler(error)
  35.     updater.start_polling()
  36.     updater.idle()
  37.  
  38.  
  39. if __name__ == '__main__':
  40.     main()
Advertisement
RAW Paste Data Copied
Advertisement