mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-25 08:37:07 +01:00
parent
179cf14bd8
commit
3afb0ae6c3
1 changed files with 6 additions and 3 deletions
|
@ -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!')
|
||||
|
||||
|
|
Loading…
Reference in a new issue