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

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

Type:callable
context

Optional. Additional data needed for the callback function.

Type:object
name

Optional. The name of the new job.

Type:str
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

Optional. Defines on which days of the week the job should run.

Type:Tuple[int]
enabled

Whether this job is enabled.

Type:bool
interval

Optional. The interval in which the job will run.

Type:int | float | datetime.timedelta
interval_seconds

The interval for this job in seconds.

Type:int
job_queue

Optional. The JobQueue this job belongs to.

Type:telegram.ext.JobQueue
removed

Whether this job is due to be removed.

Type:bool
repeat

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

Type:bool
run(dispatcher)

Executes the callback function.

schedule_removal()

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