Exemple #1
0
 def run(self, dispatcher: 'Dispatcher') -> None:
     """Executes the callback function independently of the jobs schedule."""
     try:
         if dispatcher.use_context:
             self.callback(CallbackContext.from_job(self, dispatcher))
         else:
             self.callback(dispatcher.bot, self)  # type: ignore[arg-type,call-arg]
     except Exception as e:
         try:
             dispatcher.dispatch_error(None, e)
         # Errors should not stop the thread.
         except Exception:
             dispatcher.logger.exception('An error was raised while processing the job and an '
                                         'uncaught error was raised while handling the error '
                                         'with an error_handler.')
Exemple #2
0
 def _build_args(self, job: 'Job') -> List[Union[CallbackContext, 'Bot', 'Job']]:
     if self._dispatcher.use_context:
         return [CallbackContext.from_job(job, self._dispatcher)]
     return [self._dispatcher.bot, job]
Exemple #3
0
 def run(self, dispatcher):
     """Executes the callback function."""
     if dispatcher.use_context:
         self.callback(CallbackContext.from_job(self, dispatcher))
     else:
         self.callback(dispatcher.bot, self)