L iFhdZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z  ddlmZddlmZdZddlmZmZdd lmZdd lmZdd lmZdd lmZdd lm Z m!Z!erddl"m#Z#erddl$m%Z&ddl'm(Z(e)e*dZ+ee,dZ-Gdde e Z.Gdde e Z%y#e$rdZY|wxYw)z2This module contains the classes JobQueue and Job.N) TYPE_CHECKINGAnyGenericOptionalUnioncastoverload)AsyncIOExecutor)AsyncIOSchedulerTF)UTClocalize) get_logger)build_repr_with_selected_attrs)JSONDict)ExtBot)CCT JobCallback)Iterable)Job) ApplicationJobQueue) class_nameceZdZdZdZdZd,dZdefdZe d-dZ e de fd Z de jfd Zed.d dd eddfd Ze d.d eee j*e je j,fd ede jfdZ d.d eee j*e je j,dfd edee jfdZ d/dZed0dZ d1deedeee j*e je j,fdeedeedeedeedee ddfdZ d2deedeee j*fdeeee j*e je j,fdeeee j*e je j,fdeedeedeedeedee ddfdZ d1deede j,dedeedeedeedeedee ddfd Z!e"dddddfdeed e j,d!e#ed"fdeedeedeedeedee ddfd#Z$ d3deede deedeedeedeeddfd$Z%d,d%Z&d4d&eddfd'Z'd5d(eee(jRedfde#d)fd*Z*dede#d)fd+Z+y)6raThis class allows you to periodically perform tasks with the bot. It is a convenience wrapper for the APScheduler library. This class is a :class:`~typing.Generic` class and accepts one type variable that specifies the type of the argument ``context`` of the job callbacks (:paramref:`~run_once.callback`) of :meth:`run_once` and the other scheduling methods. Important: If you want to use this class, you must install PTB with the optional requirement ``job-queue``, i.e. .. code-block:: bash pip install "python-telegram-bot[job-queue]" Examples: :any:`Timer Bot ` .. seealso:: :wiki:`Architecture Overview `, :wiki:`Job Queue ` .. versionchanged:: 20.0 To use this class, PTB must be installed via ``pip install "python-telegram-bot[job-queue]"``. Attributes: scheduler (:class:`apscheduler.schedulers.asyncio.AsyncIOScheduler`): The scheduler. Warning: This scheduler is configured by :meth:`set_application`. Additional configuration settings can be made by users. However, calling :meth:`~apscheduler.schedulers.base.BaseScheduler.configure` will delete any previous configuration settings. Therefore, please make sure to pass the values returned by :attr:`scheduler_configuration` to the method call in addition to your custom values. Alternatively, you can also use methods like :meth:`~apscheduler.schedulers.base.BaseScheduler.add_jobstore` to avoid using :meth:`~apscheduler.schedulers.base.BaseScheduler.configure` altogether. .. versionchanged:: 20.0 Uses :class:`~apscheduler.schedulers.asyncio.AsyncIOScheduler` instead of :class:`~apscheduler.schedulers.background.BackgroundScheduler` ) _application _executor scheduler)sunmontuewedthufrisatreturnNcts tdd|_t|_t di|j |_y)Nz\To use `JobQueue`, PTB must be installed via `pip install "python-telegram-bot[job-queue]"`.) APS_AVAILABLE RuntimeErrorrr rr scheduler_configurationrselfs \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/telegram/ext/_jobqueue.py__init__zJobQueue.__init__hsG5  KO(*-=. **. c0t||jS)a$Give a string representation of the JobQueue in the form ``JobQueue[application=...]``. As this class doesn't implement :meth:`object.__str__`, the default implementation will be used, which is equivalent to :meth:`__repr__`. Returns: :obj:`str` ) application)rr1r+s r-__repr__zJobQueue.__repr__us.d@P@PQQr/cn|j td|j}||Std)z1The application this JobQueue is associated with.z)No application was set for this JobQueue.z,The application instance is no longer alive.)rr)r,r1s r-r1zJobQueue.applicationsB    $JK K'')  " IJJr/c4t}|jrvt|jjt rR|jjj r2|jjj jxst}|d|jidS)a_Provides configuration values that are used by :class:`JobQueue` for :attr:`scheduler`. Tip: Since calling :meth:`scheduler.configure() ` deletes any previous setting, please make sure to pass these values to the method call in addition to your custom values: .. code-block:: python scheduler.configure(..., **job_queue.scheduler_configuration) Alternatively, you can also use methods like :meth:`~apscheduler.schedulers.base.BaseScheduler.add_jobstore` to avoid using :meth:`~apscheduler.schedulers.base.BaseScheduler.configure` altogether. .. versionadded:: 20.7 Returns: dict[:obj:`str`, :obj:`object`]: The configuration values as dictionary. default)timezone executors) r r isinstancer1botrdefaultstzinfor)r,r7s r-r*z JobQueue.scheduler_configurationsz0 #   4++//8  $$--''++44;;BsH!#T^^4  r/chtjj|jjSN)dtmdatetimenowrr7r+s r-_tz_nowzJobQueue._tz_nows!|| 7 788r/time shift_daycyr>r'r,rCrDs r-_parse_time_inputzJobQueue._parse_time_inputsNQr/cyr>r'rFs r-rGzJobQueue._parse_time_inputs r/c|yt|ttfr'|jt j |zSt|tj r|j|zSt|tj rtjjtjj|jxs|jjj|}|j t||jj}|r?|tjjtkr|t j dz }|S|S)N)seconds)tz)days)r9intfloatrBr? timedeltarCr@combinerAr<rr7dater r )r,rCrD date_times r-rGzJobQueue._parse_time_inputs < dS%L )<<>CMM$$?? ? dCMM *<<>D( ( dCHH % ,,   DKK$J4>>3J3J KPPRTXI'%Y0G0GH Y#,,*:*:3*??S]]22   r/ctj||_|jjdi|j y)zSet the application to be used by this JobQueue. Args: application (:class:`telegram.ext.Application`): The application. Nr')weakrefrefrr configurer*r4s r-set_applicationzJobQueue.set_applications2$KK 4   @4#?#?@r/Job[CCT]cVK|j|jd{y7w)aThis method is used as a callback for the APScheduler jobs. More precisely, the ``func`` argument of :class:`apscheduler.job.Job` is set to this method and the ``arg`` argument (representing positional arguments to ``func``) is set to a tuple containing the :class:`JobQueue` itself and the :class:`~telegram.ext.Job` instance. Tip: This method is a static method rather than a bound method. This makes the arguments more transparent and allows for easier handling of PTBs integration of APScheduler when utilizing advanced features of APScheduler. Hint: This method is effectively a wrapper for :meth:`telegram.ext.Job.run`. .. versionadded:: 20.4 Args: job_queue (:class:`JobQueue`): The job queue that created the job. job (:class:`~telegram.ext.Job`): The job to run. N)runr1) job_queuejobs r- job_callbackzJobQueue.job_callbacks ,ggi++,,,s )')callbackwhendatanamechat_iduser_id job_kwargsc $|si}|xs |j}t|||||}|j|d} |jj|j f|d| ||f| j xs|jjd|} | |_|S)a Creates a new :class:`Job` instance that runs once and adds it to the queue. Args: callback (:term:`coroutine function`): The callback function that should be executed by the new job. Callback signature:: async def callback(context: CallbackContext) when (:obj:`int` | :obj:`float` | :obj:`datetime.timedelta` | :obj:`datetime.datetime` | :obj:`datetime.time`): Time in or at which the job should run. This parameter will be interpreted depending on its type. * :obj:`int` or :obj:`float` will be interpreted as "seconds from now" in which the job should run. * :obj:`datetime.timedelta` will be interpreted as "time from now" in which the job should run. * :obj:`datetime.datetime` will be interpreted as a specific date and time at which the job should run. If the timezone (:attr:`datetime.datetime.tzinfo`) is :obj:`None`, the default timezone of the bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is used. * :obj:`datetime.time` will be interpreted as a specific time of day at which the job should run. This could be either today or, if the time has already passed, tomorrow. If the timezone (:attr:`datetime.time.tzinfo`) is :obj:`None`, the default timezone of the bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is used. chat_id (:obj:`int`, optional): Chat id of the chat associated with this job. If passed, the corresponding :attr:`~telegram.ext.CallbackContext.chat_data` will be available in the callback. .. versionadded:: 20.0 user_id (:obj:`int`, optional): User id of the user associated with this job. If passed, the corresponding :attr:`~telegram.ext.CallbackContext.user_data` will be available in the callback. .. versionadded:: 20.0 data (:obj:`object`, optional): Additional data needed for the callback function. Can be accessed through :attr:`Job.data` in the callback. Defaults to :obj:`None`. .. versionchanged:: 20.0 Renamed the parameter ``context`` to :paramref:`data`. name (:obj:`str`, optional): The name of the new job. Defaults to :external:attr:`callback.__name__ `. job_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments to pass to the :meth:`apscheduler.schedulers.base.BaseScheduler.add_job()`. Returns: :class:`telegram.ext.Job`: The new :class:`Job` instance that has been added to the job queue. r_rarbrcrdT)rDrR)rbtriggerrun_dateargsr7) __name__rrGradd_jobr^r<r7_job) r,r_r`rarbrcrdrer]rSjs r-run_oncezJobQueue.run_onces@J(x((8$T7T[\**44*@ "DNN " "    %%@)@)@    r/intervalfirstlastc || si} |xs |j}t|||||} |j|} |j|} | r| r| | kr tdt |t j r|j}|jj|jfd|| f| | ||d| } | | _ | S)a~Creates a new :class:`Job` instance that runs at specified intervals and adds it to the queue. Note: For a note about DST, please see the documentation of `APScheduler`_. .. _`APScheduler`: https://apscheduler.readthedocs.io/en/stable/modules/triggers/cron.html #daylight-saving-time-behavior Args: callback (:term:`coroutine function`): The callback function that should be executed by the new job. Callback signature:: async def callback(context: CallbackContext) interval (:obj:`int` | :obj:`float` | :obj:`datetime.timedelta`): The interval in which the job will run. If it is an :obj:`int` or a :obj:`float`, it will be interpreted as seconds. first (:obj:`int` | :obj:`float` | :obj:`datetime.timedelta` | :obj:`datetime.datetime` | :obj:`datetime.time`, optional): Time in or at which the job should run. This parameter will be interpreted depending on its type. * :obj:`int` or :obj:`float` will be interpreted as "seconds from now" in which the job should run. * :obj:`datetime.timedelta` will be interpreted as "time from now" in which the job should run. * :obj:`datetime.datetime` will be interpreted as a specific date and time at which the job should run. If the timezone (:attr:`datetime.datetime.tzinfo`) is :obj:`None`, the default timezone of the bot will be used. * :obj:`datetime.time` will be interpreted as a specific time of day at which the job should run. This could be either today or, if the time has already passed, tomorrow. If the timezone (:attr:`datetime.time.tzinfo`) is :obj:`None`, the default timezone of the bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is used. Defaults to :paramref:`interval` Note: Setting :paramref:`first` to ``0``, ``datetime.datetime.now()`` or another value that indicates that the job should run immediately will not work due to how the APScheduler library works. If you want to run a job immediately, we recommend to use an approach along the lines of:: job = context.job_queue.run_repeating(callback, interval=5) await job.run(context.application) .. seealso:: :meth:`telegram.ext.Job.run` last (:obj:`int` | :obj:`float` | :obj:`datetime.timedelta` | :obj:`datetime.datetime` | :obj:`datetime.time`, optional): Latest possible time for the job to run. This parameter will be interpreted depending on its type. See :paramref:`first` for details. If :paramref:`last` is :obj:`datetime.datetime` or :obj:`datetime.time` type and ``last.tzinfo`` is :obj:`None`, the default timezone of the bot will be assumed, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is used. Defaults to :obj:`None`. data (:obj:`object`, optional): Additional data needed for the callback function. Can be accessed through :attr:`Job.data` in the callback. Defaults to :obj:`None`. .. versionchanged:: 20.0 Renamed the parameter ``context`` to :paramref:`data`. name (:obj:`str`, optional): The name of the new job. Defaults to :external:attr:`callback.__name__ `. chat_id (:obj:`int`, optional): Chat id of the chat associated with this job. If passed, the corresponding :attr:`~telegram.ext.CallbackContext.chat_data` will be available in the callback. .. versionadded:: 20.0 user_id (:obj:`int`, optional): User id of the user associated with this job. If passed, the corresponding :attr:`~telegram.ext.CallbackContext.user_data` will be available in the callback. .. versionadded:: 20.0 job_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments to pass to the :meth:`apscheduler.schedulers.base.BaseScheduler.add_job()`. Returns: :class:`telegram.ext.Job`: The new :class:`Job` instance that has been added to the job queue. rgz"'last' must not be before 'first'!rp)rhrj start_dateend_daterJrb) rkrrG ValueErrorr9r?rP total_secondsrrlr^rm)r,r_rprqrrrarbrcrdrer]dt_firstdt_lastrns r- run_repeatingzJobQueue.run_repeatingLsDJ(x((8$T7T[\))%0((. xGh$6AB B h .--/H "DNN " "       r/dayc N|si}|xs |j}t|||||} |jj|jfd|| f||dk(rdn||j |j |j|jxs|jjd|} | | _ | S)a Creates a new :class:`Job` that runs on a monthly basis and adds it to the queue. .. versionchanged:: 20.0 The ``day_is_strict`` argument was removed. Instead one can now pass ``-1`` to the :paramref:`day` parameter to have the job run on the last day of the month. Args: callback (:term:`coroutine function`): The callback function that should be executed by the new job. Callback signature:: async def callback(context: CallbackContext) when (:obj:`datetime.time`): Time of day at which the job should run. If the timezone (``when.tzinfo``) is :obj:`None`, the default timezone of the bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is used. day (:obj:`int`): Defines the day of the month whereby the job would run. It should be within the range of ``1`` and ``31``, inclusive. If a month has fewer days than this number, the job will not run in this month. Passing ``-1`` leads to the job running on the last day of the month. data (:obj:`object`, optional): Additional data needed for the callback function. Can be accessed through :attr:`Job.data` in the callback. Defaults to :obj:`None`. .. versionchanged:: 20.0 Renamed the parameter ``context`` to :paramref:`data`. name (:obj:`str`, optional): The name of the new job. Defaults to :external:attr:`callback.__name__ `. chat_id (:obj:`int`, optional): Chat id of the chat associated with this job. If passed, the corresponding :attr:`~telegram.ext.CallbackContext.chat_data` will be available in the callback. .. versionadded:: 20.0 user_id (:obj:`int`, optional): User id of the user associated with this job. If passed, the corresponding :attr:`~telegram.ext.CallbackContext.user_data` will be available in the callback. .. versionadded:: 20.0 job_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments to pass to the :meth:`apscheduler.schedulers.base.BaseScheduler.add_job()`. Returns: :class:`telegram.ext.Job`: The new :class:`Job` instance that has been added to the job queue. rgcronrr)rhrjrbr{hourminutesecondr7) rkrrrlr^rrrr<r7rm) r,r_r`r{rarbrcrdrer]rns r- run_monthlyzJobQueue.run_monthlysrJ(x((8$T7T[\ "DNN " "    );;;;[[;DNN$;$;   r/rM.c |si}|xs |j}t|||||} |jj|jf||| fddj |D cgc]} |j | c} |j|j|j|jxs|jjd|} | | _ | Scc} w)a Creates a new :class:`Job` that runs on a daily basis and adds it to the queue. Note: For a note about DST, please see the documentation of `APScheduler`_. .. _`APScheduler`: https://apscheduler.readthedocs.io/en/stable/modules/triggers/cron.html #daylight-saving-time-behavior Args: callback (:term:`coroutine function`): The callback function that should be executed by the new job. Callback signature:: async def callback(context: CallbackContext) time (:obj:`datetime.time`): Time of day at which the job should run. If the timezone (:obj:`datetime.time.tzinfo`) is :obj:`None`, the default timezone of the bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is used. days (tuple[:obj:`int`], optional): Defines on which days of the week the job should run (where ``0-6`` correspond to sunday - saturday). By default, the job will run every day. .. versionchanged:: 20.0 Changed day of the week mapping of 0-6 from monday-sunday to sunday-saturday. data (:obj:`object`, optional): Additional data needed for the callback function. Can be accessed through :attr:`Job.data` in the callback. Defaults to :obj:`None`. .. versionchanged:: 20.0 Renamed the parameter ``context`` to :paramref:`data`. name (:obj:`str`, optional): The name of the new job. Defaults to :external:attr:`callback.__name__ `. chat_id (:obj:`int`, optional): Chat id of the chat associated with this job. If passed, the corresponding :attr:`~telegram.ext.CallbackContext.chat_data` will be available in the callback. .. versionadded:: 20.0 user_id (:obj:`int`, optional): User id of the user associated with this job. If passed, the corresponding :attr:`~telegram.ext.CallbackContext.user_data` will be available in the callback. .. versionadded:: 20.0 job_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments to pass to the :meth:`apscheduler.schedulers.base.BaseScheduler.add_job()`. Returns: :class:`telegram.ext.Job`: The new :class:`Job` instance that has been added to the job queue. rgr},)rbrjrh day_of_weekrrrr7) rkrrrlr^join _CRON_MAPPINGrrrr<r7rm) r,r_rCrMrarbrcrdrer]drns r- run_dailyzJobQueue.run_dailys|J(x((8$T7T[\ "DNN " "    !FA$"4"4Q"7!FG;;;;[[;DNN$;$;   "GsC c|xs |j}t|||||}|jj|jf||f|d|}||_|S)aLCreates a new custom defined :class:`Job`. Args: callback (:term:`coroutine function`): The callback function that should be executed by the new job. Callback signature:: async def callback(context: CallbackContext) job_kwargs (:obj:`dict`): Arbitrary keyword arguments. Used as arguments for :meth:`apscheduler.schedulers.base.BaseScheduler.add_job`. data (:obj:`object`, optional): Additional data needed for the callback function. Can be accessed through :attr:`Job.data` in the callback. Defaults to :obj:`None`. .. versionchanged:: 20.0 Renamed the parameter ``context`` to :paramref:`data`. name (:obj:`str`, optional): The name of the new job. Defaults to :external:attr:`callback.__name__ `. chat_id (:obj:`int`, optional): Chat id of the chat associated with this job. If passed, the corresponding :attr:`~telegram.ext.CallbackContext.chat_data` will be available in the callback. .. versionadded:: 20.0 user_id (:obj:`int`, optional): User id of the user associated with this job. If passed, the corresponding :attr:`~telegram.ext.CallbackContext.user_data` will be available in the callback. .. versionadded:: 20.0 Returns: :class:`telegram.ext.Job`: The new :class:`Job` instance that has been added to the job queue. rg)rjrb)rkrrrlr^rm) r,r_rerarbrcrdr]rns r- run_customzJobQueue.run_custommsaX(x((8$T7T[\ "DNN " "4#4#4 `D#;T `U_ ` r/cnK|jjs|jjyyw)z+Starts the :class:`~telegram.ext.JobQueue`.N)rrunningstartr+s r-rzJobQueue.starts*~~%% NN "&s35waitcK|r1tj|jjddid{|jj r:|jj |tjdd{yy7U7w)zShuts down the :class:`~telegram.ext.JobQueue`. Args: wait (:obj:`bool`, optional): Whether to wait until all currently running jobs have finished. Defaults to :obj:`True`. return_exceptionsTN)rg{Gz?)asynciogatherr_pending_futuresrrshutdownsleep)r,rs r-stopz JobQueue.stops~ ..00"&   >> ! ! NN # # # .--% % % "   &s"/B BAB B B  B pattern)rY.cd|jjD} t|Stfd|DS)a%Returns a tuple of all *scheduled* jobs that are currently in the :class:`JobQueue`. Args: pattern (:obj:`str` | :obj:`re.Pattern`, optional): A regular expression pattern. If passed, only jobs whose name matches the pattern will be returned. Defaults to :obj:`None`. Hint: This uses :func:`re.search` and not :func:`re.match`. .. versionadded:: 21.10 Returns: tuple[:class:`Job`]: Tuple of all *scheduled* jobs. c3FK|]}tj|ywr>)r from_aps_job).0r]s r- z JobQueue.jobs..s ) &)C  S !) s!c3K|]B}|jstjj|js?|Dywr>)rbrecompilesearch)rr]rs r-rz JobQueue.jobs..s9 chh2::g;N;U;UVYV^V^;_C sA .A A )rget_jobstuple)r,rjobs_generators ` r-jobsz JobQueue.jobssK ) -1^^-D-D-F)  ?( ( )   r/cR|jdtj|dS)afReturns a tuple of all *scheduled* jobs with the given name that are currently in the :class:`JobQueue`. Hint: This method is a convenience wrapper for :meth:`jobs` with a pattern that matches the given name. Returns: tuple[:class:`Job`]: Tuple of all *scheduled* jobs matching the name. ^$)rrescape)r,rbs r-get_jobs_by_namezJobQueue.get_jobs_by_names%yy1RYYt_-Q/00r/r%N)r%3Application[Any, CCT, Any, Any, Any, JobQueue[CCT]])Fr1rr%N)r\z JobQueue[CCT]r]rYr%N)NNNNN)NNNNNNNNNNN)Tr>),rk __module__ __qualname____doc__ __slots__rr.strr2propertyr1rr*r?r@rBr boolrGrrOrPrCrrX staticmethodr^rrobjectrNrorzr _ALL_DAYSrrrrrrPatternrrr'r/r-rr7s+Z;IEM   R# RKK" " " H99QdQtQQQ  E3==#,,@A   E3==#,,$FG #,,  0 AP A  A--6"&"!%!%)-Rc"RE3==#,,@ARv R sm R # R#RX&R RpPTNR!%"!%!%)-}c"}s}},-}eS]]CLL#((JKL } uUCMM3<<IJK } v }sm}#}#}X&} }H"&"!%!%)-Lc"LhhL L v L sm L#L#LX&L Ld!*!%"!%!%)-Rc"RhhRCHo R v R sm R#R#RX&R Rp"&"!%!%2c"22v 2 sm 2 # 2#2 2h# &t&t&. E#rzz#"<= I_ 2 1S 1U?-C 1r/c feZdZdZdZ ddeedeedee dee dee f d Z d e d efd Z d ed e fdZd e fdZd e fdZeddZed e fdZed e fdZej*de d dfdZed eej.fdZeddZ ddZ ddZddZy) ra This class is a convenience wrapper for the jobs held in a :class:`telegram.ext.JobQueue`. With the current backend APScheduler, :attr:`job` holds a :class:`apscheduler.job.Job` instance. Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their :class:`id ` is equal. This class is a :class:`~typing.Generic` class and accepts one type variable that specifies the type of the argument ``context`` of :paramref:`callback`. Important: If you want to use this class, you must install PTB with the optional requirement ``job-queue``, i.e. .. code-block:: bash pip install "python-telegram-bot[job-queue]" Note: All attributes and instance methods of :attr:`job` are also directly available as attributes/methods of the corresponding :class:`telegram.ext.Job` object. Warning: This class should not be instantiated manually. Use the methods of :class:`telegram.ext.JobQueue` to schedule jobs. .. seealso:: :wiki:`Job Queue ` .. versionchanged:: 20.0 * Removed argument and attribute ``job_queue``. * Renamed ``Job.context`` to :attr:`Job.data`. * Removed argument ``job`` * To use this class, PTB must be installed via ``pip install "python-telegram-bot[job-queue]"``. Args: callback (:term:`coroutine function`): The callback function that should be executed by the new job. Callback signature:: async def callback(context: CallbackContext) data (:obj:`object`, optional): Additional data needed for the :paramref:`callback` function. Can be accessed through :attr:`Job.data` in the callback. Defaults to :obj:`None`. name (:obj:`str`, optional): The name of the new job. Defaults to :external:obj:`callback.__name__ `. chat_id (:obj:`int`, optional): Chat id of the chat that this job is associated with. .. versionadded:: 20.0 user_id (:obj:`int`, optional): User id of the user that this job is associated with. .. versionadded:: 20.0 Attributes: callback (:term:`coroutine function`): The callback function that should be executed by the new job. data (:obj:`object`): Optional. Additional data needed for the :attr:`callback` function. name (:obj:`str`): Optional. The name of the new job. chat_id (:obj:`int`): Optional. Chat id of the chat that this job is associated with. .. versionadded:: 20.0 user_id (:obj:`int`): Optional. User id of the user that this job is associated with. .. versionadded:: 20.0 )_enabledrm_removedr_rcrarbrdNr_rarbrcrdcts td||_||_|xs |j|_||_||_d|_d|_ tdd|_ y)NzWTo use `Job`, PTB must be installed via `pip install "python-telegram-bot[job-queue]"`.FAPSJob) r(r)r_rarkrbrcrdrrrrm)r,r_rarbrcrds r-r.z Job.__init__3se5  +3 &* #'#<8+<+< &- &-   4( r/itemr%cr t|j|S#t$r}td|d|d}~wwxYw)aOverrides :py:meth:`object.__getattr__` to get specific attribute of the :class:`telegram.ext.Job` object or of its attribute :class:`apscheduler.job.Job`, if exists. Args: item (:obj:`str`): The name of the attribute. Returns: :object: The value of the attribute. Raises: :exc:`AttributeError`: If the attribute does not exist in both :class:`telegram.ext.Job` and :class:`apscheduler.job.Job` objects. zDNeither 'telegram.ext.Job' nor 'apscheduler.job.Job' has attribute ''N)getattrr]AttributeError)r,rexcs r- __getattr__zJob.__getattr__LsG 488T* *  VW[V\\]^  s 616othercbt||jr|j|jk(Sy)aPDefines equality condition for the :class:`telegram.ext.Job` object. Two objects of this class are considered to be equal if their :class:`id ` are equal. Returns: :obj:`True` if both objects have :paramref:`id` parameters identical. :obj:`False` otherwise. F)r9 __class__id)r,rs r-__eq__z Job.__eq__bs( eT^^ ,77ehh& &r/c,t|jS)zBuilds a hash value for this object such that the hash of two objects is equal if and only if the objects are equal in terms of :meth:`__eq__`. Returns: :obj:`int`: The hash value of the object. )hashrr+s r-__hash__z Job.__hash__osDGG}r/ct||jj|j|jj |jj S)a>Give a string representation of the job in the form ``Job[id=..., name=..., callback=..., trigger=...]``. As this class doesn't implement :meth:`object.__str__`, the default implementation will be used, which is equivalent to :meth:`__repr__`. Returns: :obj:`str` )rrbr_rh)rr]rrbr_rkrhr+s r-r2z Job.__repr__xs@. xx{{]]++HH$$   r/c|jS)z:class:`apscheduler.job.Job`: The APS Job this job is a wrapper for. .. versionchanged:: 20.0 This property is now read-only. )rmr+s r-r]zJob.jobsyyr/c|jS)z3:obj:`bool`: Whether this job is due to be removed.)rr+s r-removedz Job.removed}}r/c|jS)z):obj:`bool`: Whether this job is enabled.)rr+s r-enabledz Job.enabledrr/statusc|r"|jj||_y|jj||_yr>)r]resumepauser)r,rs r-rz Job.enableds3  HHOO   HHNN  r/c.|jjS)a :class:`datetime.datetime`: Datetime for the next job execution. Datetime is localized according to :attr:`datetime.datetime.tzinfo`. If job is removed or already ran it equals to :obj:`None`. Warning: This attribute is only available, if the :class:`telegram.ext.JobQueue` this job belongs to is already started. Otherwise APScheduler raises an :exc:`AttributeError`. )r] next_run_timer+s r-next_tz Job.next_tsxx%%%r/c2|jd}||_|S)aProvides the :class:`telegram.ext.Job` that is associated with the given APScheduler job. Tip: This method can be useful when using advanced APScheduler features along with :class:`telegram.ext.JobQueue`. .. versionadded:: 20.4 Args: aps_job (:class:`apscheduler.job.Job`): The APScheduler job Returns: :class:`telegram.ext.Job` rL)rjrm)clsaps_jobext_jobs r-rzJob.from_aps_jobs",,q/ r/chKtj|j|d{y7w)aExecutes the callback function independently of the jobs schedule. Also calls :meth:`telegram.ext.Application.update_persistence`. .. versionchanged:: 20.0 Calls :meth:`telegram.ext.Application.update_persistence`. Args: application (:class:`telegram.ext.Application`): The application this job is associated with. N)rshield_runr4s r-r[zJob.runs#nnTYY{3444s (202cPK |jjj||}|jd{|j|d{|j|y#t$r>}tj d|j |Yd}~|j|yd}~wwxYw7z7c#t$rF}|j|jd||d|jdd{7Yd}~d}~wwxYw#|j|wxYww)NzEError while building CallbackContext for job %s. Job will not be run.)exc_info)r]zJob:z:run:process_error)rb) context_typescontextfrom_job Exception_LOGGERcriticalrm_mark_for_persistence_update refresh_datar_ create_task process_errorr)r,r1rrs r-rzJob._runs  ? %33;;DDT;W&&( ( (--( ( (  4 4 4 >#   [II !   4 4 4 >#  ) ( ))))$)>DGG9$67*     4 4 4 >sD&&A/B=B9B=B;B=D&/ B68"B1B=D&1B66B=;B== D 6D<C?=DDD  DD##D&cF|jjd|_y)z Schedules this job for removal from the :class:`JobQueue`. It will be removed without executing its callback function again. TN)r]removerr+s r-schedule_removalzJob.schedule_removals  r/r)r%r)rrr%rYrr)rkrrrrrrrrrrNr.rrrrr2rr]rrsetterr?r@r classmethodrr[rrr'r/r-rrs~@D I"&"!%!% )c")v)sm ) # ) # )2, F t # # $ ^^dt &. & &(5P5 5 ?P? ?2r/r)/rrr@r?rrUtypingrrrrrrr apscheduler.executors.asyncior apscheduler.schedulers.asyncior r( ImportErrortelegram._utils.datetimer r telegram._utils.loggingrtelegram._utils.reprrtelegram._utils.typesrtelegram.ext._extbotrtelegram.ext._utils.typesrrcollections.abcrapscheduler.jobrr telegram.extrrrangerrkrrr'r/r-rs&9 OOO=?M3.?*'6(1( %(O X* 5k 1ws|k 1\Q'#,QKMsB''B10B1