diff --git a/AUTHORS.rst b/AUTHORS.rst index 5dcf398d76f..bd08ff7313b 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -59,6 +59,7 @@ The following wonderful people contributed directly or indirectly to this projec - `Paul Larsen `_ - `Pieter Schutz `_ - `Rahiel Kasim `_ +- `Rick van Schijndel `_ - `Sascha `_ - `Shelomentsev D `_ - `Simon Schürrle `_ diff --git a/examples/timerbot.py b/examples/timerbot.py old mode 100644 new mode 100755 index c21563a55d7..1bbb711b7c0 --- a/examples/timerbot.py +++ b/examples/timerbot.py @@ -32,29 +32,28 @@ # Define a few command handlers. These usually take the two arguments bot and # update. Error handlers also receive the raised TelegramError object in error. -def start(update, context): +def start(bot, update): update.message.reply_text('Hi! Use /set to set a timer') -def alarm(context): +def alarm(bot, job): """Send the alarm message.""" - job = context.job - context.bot.send_message(job.context, text='Beep!') + bot.send_message(job.context, text='Beep!') -def set_timer(update, context): +def set_timer(bot, update, args, job_queue, chat_data): """Add a job to the queue.""" chat_id = update.message.chat_id try: # args[0] should contain the time for the timer in seconds - due = int(context.args[0]) + due = int(args[0]) if due < 0: 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 + job = job_queue.run_once(alarm, due, context=chat_id) + chat_data['job'] = job update.message.reply_text('Timer successfully set!') @@ -62,15 +61,15 @@ def set_timer(update, context): update.message.reply_text('Usage: /set ') -def unset(update, context): +def unset(bot, update, chat_data): """Remove the job if the user changed their mind.""" - if 'job' not in context.chat_data: + if 'job' not in chat_data: update.message.reply_text('You have no active timer') return - job = context.chat_data['job'] + job = chat_data['job'] job.schedule_removal() - del context.chat_data['job'] + del chat_data['job'] update.message.reply_text('Timer successfully unset!') @@ -83,9 +82,7 @@ def error(update, context): def main(): """Run bot.""" # Create the Updater and pass it your bot's token. - # Make sure to set use_context=True to use the new context based callbacks - # Post version 12 this will no longer be necessary - updater = Updater("TOKEN", use_context=True) + updater = Updater("TOKEN") # Get the dispatcher to register handlers dp = updater.dispatcher pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy