mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-02-16 18:31:45 +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!')
|
update.message.reply_text('Sorry we can not go back to future!')
|
||||||
return
|
return
|
||||||
|
|
||||||
# Add job to queue
|
# Add job to queue and stop current one if there is a timer already
|
||||||
job = context.job_queue.run_once(alarm, due, context=chat_id)
|
if 'job' in context.chat_data:
|
||||||
context.chat_data['job'] = job
|
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!')
|
update.message.reply_text('Timer successfully set!')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue