From e7f4a07b7af79959708e4b19f8a4a3c83e7a64b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Thu, 26 May 2016 14:48:50 +0200 Subject: [PATCH] update timerbot example with pass_job_queue --- examples/timerbot.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/examples/timerbot.py b/examples/timerbot.py index c40205982..8473a543a 100644 --- a/examples/timerbot.py +++ b/examples/timerbot.py @@ -25,7 +25,6 @@ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s level=logging.DEBUG) logger = logging.getLogger(__name__) -job_queue = None timers = dict() @@ -35,7 +34,7 @@ def start(bot, update): bot.sendMessage(update.message.chat_id, text='Hi! Use /set to ' 'set a timer') -def set(bot, update, args): +def set(bot, update, args, job_queue): """Adds a job to the queue""" chat_id = update.message.chat_id try: @@ -77,10 +76,7 @@ def error(bot, update, error): def main(): - global job_queue - updater = Updater("TOKEN") - job_queue = updater.job_queue # Get the dispatcher to register handlers dp = updater.dispatcher @@ -88,7 +84,7 @@ def main(): # on different commands - answer in Telegram dp.add_handler(CommandHandler("start", start)) dp.add_handler(CommandHandler("help", start)) - dp.add_handler(CommandHandler("set", set, pass_args=True)) + dp.add_handler(CommandHandler("set", set, pass_args=True, pass_job_queue=True)) dp.add_handler(CommandHandler("unset", unset)) # log all errors