LCMbot.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # -*- coding: utf-8 -*-
  2. from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters,
  3. CallbackQueryHandler)
  4. import handlers as hnd
  5. from tale_handler import TaleHandler
  6. def main():
  7. # create LCMbot
  8. updater = Updater('TOKEN')
  9. dp = updater.dispatcher
  10. # register handlers
  11. dp.add_handler(CommandHandler('pinglcm', hnd.ping))
  12. dp.add_handler(CommandHandler('checkwebsite', hnd.is_web_up))
  13. dp.add_handler(CommandHandler('vietnam', hnd.vietnam))
  14. dp.add_handler(CommandHandler('sellyourmother', hnd.sell_your_mother))
  15. dp.add_handler(CommandHandler('abuse150', hnd.abuse_150))
  16. dp.add_handler(CommandHandler('rndwisdom', hnd.speak, pass_args=True))
  17. tale_handler = TaleHandler()
  18. dp.add_handler(CommandHandler('addatale', tale_handler.prompt_user))
  19. dp.add_handler(MessageHandler([Filters.text], tale_handler.handle_new_tale))
  20. dp.add_handler(CallbackQueryHandler(tale_handler.save_tale))
  21. dp.add_handler(CommandHandler('tellatale', tale_handler.tell_a_tale))
  22. dp.add_error_handler(hnd.error)
  23. # dp.add_handler(MessageHandler([], hnd.print_msg_info))
  24. # start LCMbot
  25. updater.start_polling()
  26. # run until the process receives SIGINT, SIGTERM or SIGABRT
  27. updater.idle()
  28. if __name__ == '__main__':
  29. main()