From 6beb8f61375b146b4ee8dcb3af580628ade33d8a Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Wed, 8 Feb 2017 14:46:59 +0100 Subject: [PATCH] Implemented tweet handler, shorter reply call --- bot.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bot.py b/bot.py index 99975bd..3511a7e 100755 --- a/bot.py +++ b/bot.py @@ -7,22 +7,26 @@ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s updater = telegram.ext.Updater(token=setuptools.token()) def start(bot, update): - bot.sendMessage(chat_id=update.message.chat_id, text=strings.start % (setuptools.botname(), setuptools.botname())) + update.message.reply_text(strings.start % (setuptools.botname(), setuptools.botname())) def auth(bot, update): - bot.sendMessage(chat_id=update.message.chat_id, text="Ooops. Not implemented yet.") + update.message.reply_text("Ooops. Not implemented yet.") def unauth(bot, update): dbtools.dbHelper().deleteUser(update.message.chat_id) - bot.sendMessage(chat_id=update.message.chat_id, text=strings.unauth % setuptools.url()) + update.message.reply_text(strings.unauth % setuptools.url()) def fish(bot, update): - bot.sendMessage(chat_id=update.message.chat_id, text="Yummy! Thanks! :3") + update.message.reply_text("Yummy! Thanks! :3") + +def tweet(bot, update): + update.message.reply_text("Ooops. Not implemented yet.") updater.dispatcher.add_handler(telegram.ext.CommandHandler("start", start)) updater.dispatcher.add_handler(telegram.ext.CommandHandler("auth", auth)) updater.dispatcher.add_handler(telegram.ext.CommandHandler("unauth", unauth)) updater.dispatcher.add_handler(telegram.ext.CommandHandler("fish", fish)) +updater.dispatcher.add_handler(telegram.ext.MessageHandler(telegram.ext.Filters.text, tweet)) updater.start_polling() updater.idle()