diff --git a/examples/timerbot.py b/examples/timerbot.py index c296b57a5..3c3ab3199 100644 --- a/examples/timerbot.py +++ b/examples/timerbot.py @@ -55,9 +55,12 @@ def set_timer(update, context): update.message.reply_text('Sorry we can not go back to future!') return - # Add job to queue - job = context.job_queue.run_once(alarm, due, context=chat_id) - context.chat_data['job'] = job + # Add job to queue and stop current one if there is a timer already + if 'job' in context.chat_data: + old_job = context.chat_data['job'] + old_job.schedule_removal() + new_job = context.job_queue.run_once(alarm, due, context=chat_id) + context.chat_data['job'] = new_job update.message.reply_text('Timer successfully set!')