telegram.ext.Job

class telegram.ext.Job(callback, interval=None, repeat=True, context=None, days=(0, 1, 2, 3, 4, 5, 6), name=None, job_queue=None)

Bases: object

This class encapsulates a Job.

callback

callable – The callback function that should be executed by the new job.

context

object – Optional. Additional data needed for the callback function.

name

str – Optional. The name of the new job.

Parameters:
  • callback (callable) – The callback function that should be executed by the new job. It should take bot, job as parameters, where job is the telegram.ext.Job instance. It can be used to access it’s context or change it to a repeating job.
  • interval (int | float | datetime.timedelta, optional) – The interval in which the job will run. If it is an int or a float, it will be interpreted as seconds. If you don’t set this value, you must set repeat to False and specify next_t when you put the job into the job queue.
  • repeat (bool, optional) – If this job should be periodically execute its callback function (True) or only once (False). Defaults to True.
  • context (object, optional) – Additional data needed for the callback function. Can be accessed through job.context in the callback. Defaults to None.
  • name (str, optional) – The name of the new job. Defaults to callback.__name__.
  • days (Tuple[int], optional) – Defines on which days of the week the job should run. Defaults to Days.EVERY_DAY
  • job_queue (telegram.ext.JobQueue, optional) – The JobQueue this job belongs to. Only optional for backward compatibility with JobQueue.put().
days

Tuple[int] – Optional. Defines on which days of the week the job should run.

enabled

bool – Whether this job is enabled.

interval

int | float | datetime.timedelta – Optional. The interval in which the job will run.

interval_seconds

int – The interval for this job in seconds.

job_queue

telegram.ext.JobQueue – Optional. The JobQueue this job belongs to.

removed

bool – Whether this job is due to be removed.

repeat

bool – Optional. If this job should periodically execute its callback function.

run(bot)

Executes the callback function.

schedule_removal()

Schedules this job for removal from the JobQueue. It will be removed without executing its callback function again.