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 takebot, job
as parameters, wherejob
is thetelegram.ext.Job
instance. It can be used to access it’scontext
or change it to a repeating job. - interval (
int
|float
|datetime.timedelta
, optional) – The interval in which the job will run. If it is anint
or afloat
, it will be interpreted as seconds. If you don’t set this value, you must setrepeat
toFalse
and specifynext_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 toTrue
. - context (
object
, optional) – Additional data needed for the callback function. Can be accessed throughjob.context
in the callback. Defaults toNone
. - name (
str
, optional) – The name of the new job. Defaults tocallback.__name__
. - days (Tuple[
int
], optional) – Defines on which days of the week the job should run. Defaults toDays.EVERY_DAY
- job_queue (
telegram.ext.JobQueue
, optional) – TheJobQueue
this job belongs to. Only optional for backward compatibility withJobQueue.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.
-