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:
objectThis 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 takebot, jobas parameters, wherejobis thetelegram.ext.Jobinstance. It can be used to access it’scontextor change it to a repeating job. - interval (
int|float|datetime.timedelta, optional) – The interval in which the job will run. If it is anintor afloat, it will be interpreted as seconds. If you don’t set this value, you must setrepeattoFalseand specifynext_twhen 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.contextin 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) – TheJobQueuethis job belongs to. Only optional for backward compatibility withJobQueue.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. TheJobQueuethis 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.
-