Skip to content

Commit e7f4a07

Browse files
committed
update timerbot example with pass_job_queue
1 parent bb165b6 commit e7f4a07

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

examples/timerbot.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
level=logging.DEBUG)
2626

2727
logger = logging.getLogger(__name__)
28-
job_queue = None
2928
timers = dict()
3029

3130

@@ -35,7 +34,7 @@ def start(bot, update):
3534
bot.sendMessage(update.message.chat_id, text='Hi! Use /set <seconds> to ' 'set a timer')
3635

3736

38-
def set(bot, update, args):
37+
def set(bot, update, args, job_queue):
3938
"""Adds a job to the queue"""
4039
chat_id = update.message.chat_id
4140
try:
@@ -77,18 +76,15 @@ def error(bot, update, error):
7776

7877

7978
def main():
80-
global job_queue
81-
8279
updater = Updater("TOKEN")
83-
job_queue = updater.job_queue
8480

8581
# Get the dispatcher to register handlers
8682
dp = updater.dispatcher
8783

8884
# on different commands - answer in Telegram
8985
dp.add_handler(CommandHandler("start", start))
9086
dp.add_handler(CommandHandler("help", start))
91-
dp.add_handler(CommandHandler("set", set, pass_args=True))
87+
dp.add_handler(CommandHandler("set", set, pass_args=True, pass_job_queue=True))
9288
dp.add_handler(CommandHandler("unset", unset))
9389

9490
# log all errors

0 commit comments

Comments
 (0)