def test_disabled(self): j0 = Job(self.job1, 0.1) j1 = Job(self.job1, 0.2) self.jq.put(j0) self.jq.put(Job(self.job1, 0.4)) self.jq.put(j1) j0.enabled = False j1.enabled = False sleep(1) self.assertEqual(2, self.result)
def caps(bot, update, args): text_caps = ' '.join(args).upper() bot.sendMessage(chat_id=update.message.chat_id, text=text_caps) def callback_minute(bot, job): bot.sendMessage(chat_id='99601112', text='One message every minute') job_minute = Job(callback_minute, 60.0) j.put(job_minute, next_t=0.0) def callback_30(bot, job): bot.sendMessage(chat_id='99601112', text='A single message with 30s delay') j.put(Job(callback_30, 30.0, repeat=False)) job_minute.enabled = False # Temporarily disable this job job_minute.schedule_removal() # Remove this job completely caps_handler = CommandHandler('caps', caps, pass_args=True) dispatcher.add_handler(caps_handler) echo_handler = MessageHandler(Filters.text, echo) dispatcher.add_handler(echo_handler) start_handler = CommandHandler('start', start) dispatcher.add_handler(start_handler) updater.start_polling()