Ë
    †j�£  ã                   óp  — d Z ddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZ 	 ddlmZ ddlmZ dZddlmZmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZmZ erddl m!Z! erddl"m#Z$ ddl%m&Z&  e' e(d«      «      Z) ee*d¬«      Z+de,de-fd„Z. G d„ de	e   «      Z/ G d„ de	e   «      Z#y# e$ r dZY Œ„w xY w)z2This module contains the classes JobQueue and Job.é    N)ÚTYPE_CHECKINGÚAnyÚGenericÚcastÚoverload)ÚAsyncIOExecutor)ÚAsyncIOSchedulerTF)ÚUTCÚlocalize)Ú
get_logger)Úbuild_repr_with_selected_attrs)ÚJSONDict)ÚExtBot)ÚCCTÚJobCallback)ÚIterable)ÚJob)ÚApplicationé   ÚJobQueue)Ú
class_nameÚcallbackÚreturnc                 óL   — t        | dd«      xs | j                  j                  S )a  Get the name of a callback function or callable object.

    Args:
        callback: A callable object (function, method, or callable class instance)

    Returns:
        The name of the callback, using __name__ if available, otherwise the class name.
    Ú__name__N)ÚgetattrÚ	__class__r   )r   s    úU/var/www/html/datingFans/myenv/lib/python3.12/site-packages/telegram/ext/_jobqueue.pyÚ_get_callback_namer   7   s$   € ô �8˜Z¨Ó.ÒM°(×2DÑ2D×2MÑ2MÐMó    c                   ó2  — e Zd ZdZdZdZd,d„Zdefd„Ze	d-d„«       Z
e	defd	„«       Zdej                  fd
„Zed.dddeddfd„«       Ze	 d.deej(                  z  ej                  z  ej*                  z  dedej                  fd„«       Z	 d.deej(                  z  ej                  z  ej*                  z  dz  dedej                  dz  fd„Z	 	 	 	 d/d„Zed0d„«       Z	 	 	 	 	 d1dee   deej(                  z  ej                  z  ej*                  z  dedz  dedz  dedz  dedz  dedz  ddfd„Z	 	 	 	 	 	 	 d2dee   deej(                  z  deej(                  z  ej                  z  ej*                  z  dz  deej(                  z  ej                  z  ej*                  z  dz  dedz  dedz  dedz  dedz  dedz  ddfd„Z	 	 	 	 	 d1dee   dej*                  dededz  dedz  dedz  dedz  dedz  ddfd „Ze dddddfdee   dej*                  d!e!ed"f   dedz  dedz  dedz  dedz  dedz  ddfd#„Z"	 	 	 	 d3dee   dededz  dedz  dedz  dedz  ddfd$„Z#d,d%„Z$d4d&eddfd'„Z%d5d(ee&jN                  e   z  dz  de!d)   fd*„Z(dede!d)   fd+„Z)y)6r   aÀ  This 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 <examples.timerbot>`

    .. seealso:: :wiki:`Architecture Overview <Architecture>`,
        :wiki:`Job Queue <Extensions---JobQueue>`

    .. 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)ÚsunÚmonÚtueÚwedÚthuÚfriÚsatr   Nc                 ó†   — t         st        d«      ‚d | _        t        «       | _        t        di | j                  ¤Ž| _        y )Nz\To use `JobQueue`, PTB must be installed via `pip install "python-telegram-bot[job-queue]"`.© )ÚAPS_AVAILABLEÚRuntimeErrorr"   r   r#   r	   Úscheduler_configurationr$   ©Úselfs    r   Ú__init__zJobQueue.__init__t   sG   € ÝÜð5óð ð
 HLˆÔÜ(Ó*ˆŒÜ-=ñ .
Ø×*Ñ*ñ.
ˆ�r    c                 ó0   — t        | | j                  ¬«      S )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)r   r5   r1   s    r   Ú__repr__zJobQueue.__repr__�   s   € ô .¨dÀ×@PÑ@PÔQÐQr    c                 ón   — | j                   €t        d«      ‚| j                  «       }|�|S t        d«      ‚)z1The application this JobQueue is associated with.z)No application was set for this JobQueue.z,The application instance is no longer alive.)r"   r/   ©r2   r5   s     r   r5   zJobQueue.applicationŒ   sB   € ð ×ÑÐ$ÜÐJÓKÐKØ×'Ñ'Ó)ˆØÐ"ØÐÜÐIÓJÐJr    c                 ó4  — t         }| j                  rvt        | j                  j                  t
        «      rR| j                  j                  j                  r2| j                  j                  j                  j                  xs t         }|d| j                  idœS )a_  Provides configuration values that are used by :class:`JobQueue` for :attr:`scheduler`.

        Tip:
            Since calling
            :meth:`scheduler.configure() <apscheduler.schedulers.base.BaseScheduler.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"   Ú
isinstancer5   Úbotr   ÚdefaultsÚtzinfor#   )r2   r;   s     r   r0   z JobQueue.scheduler_configuration–   sz   € ô0  #ˆà×ÒÜ˜4×+Ñ+×/Ñ/´Ô8Ø× Ñ ×$Ñ$×-Ò-à×'Ñ'×+Ñ+×4Ñ4×;Ñ;ÒB¼sˆHð !Ø# T§^¡^Ð4ñ
ð 	
r    c                 óh   — t         j                  j                  | j                  j                  «      S ©N)ÚdtmÚdatetimeÚnowr$   r;   r1   s    r   Ú_tz_nowzJobQueue._tz_now»   s!   € Ü�|‰|×Ñ §¡× 7Ñ 7Ó8Ð8r    ÚtimeÚ	shift_dayc                  ó   — y rB   r-   ©r2   rG   rH   s      r   Ú_parse_time_inputzJobQueue._parse_time_input¾   s   € ØNQr    c                  ó   — y rB   r-   rJ   s      r   rK   zJobQueue._parse_time_inputÁ   s   € ð
 r    c                 óÐ  — |€y t        |t        t        z  «      r'| j                  «       t	        j
                  |¬«      z   S t        |t        j
                  «      r| j                  «       |z   S t        |t        j                  «      rÝt        j                  j                  t        j                  j                  |j                  xs | j                  j                  ¬«      j                  «       |«      }|j                  € t        || j                  j                  «      }|r?|t        j                  j                  t        «      k  r|t	        j
                  d¬«      z  }|S |S )N)Úseconds)Útzé   )Údays)r=   ÚintÚfloatrF   rC   Ú	timedeltarG   rD   ÚcombinerE   r@   r$   r;   Údater   r
   )r2   rG   rH   Ú	date_times       r   rK   zJobQueue._parse_time_inputÈ   s  € ð
 ˆ<ØÜ�dœC¤%™KÔ(Ø—<‘<“>¤C§M¡M¸$Ô$?Ñ?Ð?Ü�dœCŸM™MÔ*Ø—<‘<“> DÑ(Ð(Ü�dœCŸH™HÔ%ÜŸ™×,Ñ,Ü—‘× Ñ  D§K¡KÒ$J°4·>±>×3JÑ3JÐ ÓK×PÑPÓRÐTXóˆIð ×ÑÐ'ô % Y°·±×0GÑ0GÓH�	Ù˜Y¬#¯,©,×*:Ñ*:¼3Ó*?Ò?ØœSŸ]™]°Ô2Ñ2�	ØÐØˆr    c                 ó„   — t        j                  |«      | _         | j                  j                  di | j
                  ¤Ž y)z—Set the application to be used by this JobQueue.

        Args:
            application (:class:`telegram.ext.Application`): The application.

        Nr-   )ÚweakrefÚrefr"   r$   Ú	configurer0   r8   s     r   Úset_applicationzJobQueue.set_applicationà   s2   € ô $ŸK™K¨Ó4ˆÔØ ˆ�‰× Ñ Ñ@ 4×#?Ñ#?Ó@r    úJob[CCT]c              ƒ   óV   K  — |j                  | j                  «      ƒ d{  –—†  y7 Œ­w)a‘  This 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)Úrunr5   )Ú	job_queueÚjobs     r   Újob_callbackzJobQueue.job_callbackì   s    è ø€ ð, �g‰g�i×+Ñ+Ó,×,Ò,ús   ‚)¡'¢)r   ÚwhenÚdataÚnameÚchat_idÚuser_idÚ
job_kwargsc           	      ó"  — |si }|xs t        |«      }t        |||||¬«      }| j                  |d¬«      }	 | j                  j                  | j
                  f|d|	| |f|	j                  xs | j                  j                  dœ|¤Ž}
|
|_        |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__ <definition.__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   rd   re   rf   rg   T)rH   rV   )re   ÚtriggerÚrun_dateÚargsr;   )	r   r   rK   r$   Úadd_jobrb   r@   r;   Ú_job)r2   r   rc   rd   re   rf   rg   rh   ra   rW   Újs              r   Úrun_oncezJobQueue.run_once  s©   € ñ@ ØˆJàÒ3Ô)¨(Ó3ˆÜ˜8¨$°TÀ7ÐT[Ô\ˆØ×*Ñ*¨4¸4Ð*Ó@ˆ	à"ˆD�N‰N×"Ñ"Ø×Ñð
àØØØ˜�Ø×%Ñ%Ò@¨¯©×)@Ñ)@ñ
ð ñ
ˆð ˆŒØˆ
r    ÚintervalÚfirstÚlastc
           
      óz  — |	si }	|xs t        |«      }t        |||||¬«      }
| j                  |«      }| j                  |«      }|r|r||k  rt        d«      ‚t	        |t
        j                  «      r|j                  «       } | j                  j                  | j                  fd| |
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__ <definition.__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.

        rj   z"'last' must not be before 'first'!rr   )rk   rm   Ú
start_dateÚend_daterN   re   )r   r   rK   Ú
ValueErrorr=   rC   rT   Útotal_secondsr$   rn   rb   ro   )r2   r   rr   rs   rt   rd   re   rf   rg   rh   ra   Údt_firstÚdt_lastrp   s                 r   Úrun_repeatingzJobQueue.run_repeatingX  sÖ   € ñD ØˆJàÒ3Ô)¨(Ó3ˆÜ˜8¨$°TÀ7ÐT[Ô\ˆà×)Ñ)¨%Ó0ˆØ×(Ñ(¨Ó.ˆá‘x G¨hÒ$6ÜÐAÓBÐBä�h¤§¡Ô.Ø×-Ñ-Ó/ˆHà"ˆD�N‰N×"Ñ"Ø×Ñð	
àØ˜�ØØØØñ	
ð ñ	
ˆð ˆŒØˆ
r    Údayc	                 óL  — |si }|xs t        |«      }t        |||||¬«      }	 | j                  j                  | j                  fd| |	f||dk(  rdn||j
                  |j                  |j                  |j                  xs | j                  j                  dœ|¤Ž}
|
|	_
        |	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__ <definition.__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.

        rj   Úcronéÿÿÿÿrt   )rk   rm   re   r}   ÚhourÚminuteÚsecondr;   )r   r   r$   rn   rb   r�   r‚   rƒ   r@   r;   ro   )r2   r   rc   r}   rd   re   rf   rg   rh   ra   rp   s              r   Úrun_monthlyzJobQueue.run_monthly×  s¯   € ñr ØˆJàÒ3Ô)¨(Ó3ˆÜ˜8¨$°TÀ7ÐT[Ô\ˆà"ˆD�N‰N×"Ñ"Ø×Ñð
àØ˜�ØØ š)‘¨Ø—‘Ø—;‘;Ø—;‘;Ø—[‘[Ò; D§N¡N×$;Ñ$;ñ
ð ñ
ˆð ˆŒØˆ
r    rQ   .c	                 óœ  — |si }|xs t        |«      }t        |||||¬«      }	 | j                  j                  | j                  f|| |	fddj                  |D �
cg c]  }
| j                  |
   ‘Œ c}
«      |j                  |j                  |j                  |j                  xs | j                  j                  dœ|¤Ž}||	_        |	S c c}
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__ <definition.__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.

        rj   r   ú,)re   rm   rk   Úday_of_weekr�   r‚   rƒ   r;   )r   r   r$   rn   rb   ÚjoinÚ_CRON_MAPPINGr�   r‚   rƒ   r@   r;   ro   )r2   r   rG   rQ   rd   re   rf   rg   rh   ra   Údrp   s               r   Ú	run_dailyzJobQueue.run_daily%  sÌ   € ñ| ØˆJàÒ3Ô)¨(Ó3ˆÜ˜8¨$°TÀ7ÐT[Ô\ˆà"ˆD�N‰N×"Ñ"Ø×Ñð
àØ˜�ØØŸ™ÀÖ!F¸A $×"4Ñ"4°QÓ"7Ò!FÓGØ—‘Ø—;‘;Ø—;‘;Ø—[‘[Ò; D§N¡N×$;Ñ$;ñ
ð ñ
ˆð ˆŒØˆ
ùò "Gs   ÁC	c                 óª   — |xs t        |«      }t        |||||¬«      } | j                  j                  | j                  f| |f|dœ|¤Ž}||_        |S )aL  Creates 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__ <definition.__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.

        rj   )rm   re   )r   r   r$   rn   rb   ro   )	r2   r   rh   rd   re   rf   rg   ra   rp   s	            r   Ú
run_customzJobQueue.run_customy  sa   € ðX Ò3Ô)¨(Ó3ˆÜ˜8¨$°TÀ7ÐT[Ô\ˆà"ˆD�N‰N×"Ñ" 4×#4Ñ#4Ð`¸DÀ#¸;ÈTÑ`ÐU_Ñ`ˆàˆŒØˆ
r    c              ƒ   ón   K  — | j                   j                  s| j                   j                  «        yy­w)z+Starts the :class:`~telegram.ext.JobQueue`.N)r$   ÚrunningÚstartr1   s    r   r�   zJobQueue.start­  s*   è ø€ ð �~‰~×%Ò%Ø�N‰N× Ñ Õ"ð &ùs   ‚35Úwaitc              ƒ   ó  K  — |r1t        j                  | j                  j                  ddiŽƒ d{  –—†  | j                  j
                  r:| j                  j                  |¬«       t        j                  d«      ƒ d{  –—†  yy7 ŒU7 Œ­w)zÛShuts 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)r‘   g{®Gáz„?)ÚasyncioÚgatherr#   Ú_pending_futuresr$   r�   ÚshutdownÚsleep)r2   r‘   s     r   ÚstopzJobQueue.stop³  s~   è ø€ ñ ä—.‘.Ø—‘×0Ñ0ðà"&ñ÷ ð ð �>‰>×!Ò!Ø�N‰N×#Ñ#¨Ð#Ô.ô —-‘- Ó%×%Ñ%ð	 "ð	øð &ús"   ‚/B±B²ABÂ B	ÂBÂ	BÚpattern)r]   .c                 óˆ   ‡— d„ | j                   j                  «       D «       }‰€t        |«      S t        ˆfd„|D «       «      S )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.
        c              3   óF   K  — | ]  }t         j                  |«      –— Œ y ­wrB   )r   Úfrom_aps_job)Ú.0ra   s     r   ú	<genexpr>z JobQueue.jobs.<locals>.<genexpr>Ú  s    è ø€ ò )
Ø&)ŒC×Ñ˜S×!ñ)
ùs   ‚!c              3   óš   •K  — | ]B  }|j                   sŒt        j                  ‰«      j                  |j                   «      sŒ?|–— ŒD y ­wrB   )re   ÚreÚcompileÚsearch)rž   ra   rš   s     €r   rŸ   z JobQueue.jobs.<locals>.<genexpr>ß  s9   øè ø€ ò 
Ø¨c¯h«h¼2¿:¹:ÀgÓ;N×;UÑ;UÐVY×V^ÑV^Õ;_ŒCñ
ùs   ƒA•.AÁA)r$   Úget_jobsÚtuple)r2   rš   Újobs_generators    ` r   ÚjobszJobQueue.jobsÊ  sK   ø€ ñ )
Ø-1¯^©^×-DÑ-DÓ-Fô)
ˆð ˆ?Ü˜Ó(Ð(Üó 
Ø)ô
ó 
ð 	
r    c                 óR   — | j                  dt        j                  |«      › d�«      S )af  Returns 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.
        ú^ú$)r§   r¡   Úescape)r2   re   s     r   Úget_jobs_by_namezJobQueue.get_jobs_by_nameã  s%   € ð �y‰y˜1œRŸY™Y t›_Ð-¨QÐ/Ó0Ð0r    ©r   N)r   ú3Application[Any, CCT, Any, Any, Any, JobQueue[CCT]])F©r5   r®   r   N)r`   zJobQueue[CCT]ra   r]   r   N)NNNNN)NNNNNNN©NNNN)TrB   )*r   Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r‰   r3   Ústrr6   Úpropertyr5   r   r0   rC   rD   rF   r   ÚboolrK   rS   rT   rG   r\   Ústaticmethodrb   r   r   ÚobjectrR   rq   r|   r„   Ú	_ALL_DAYSr¥   r‹   r�   r�   r™   r¡   ÚPatternr§   r¬   r-   r    r   r   r   C   sã  „ ñ+ðZ ;€IØE€Mó
ð	R˜#ó 	Rð òKó ðKð ð"
¨ò "
ó ð"
ðH9˜Ÿ™ó 9ð ÙQ dÐQ°tÐQÈÒQó ØQàð  ñà�c—m‘mÑ# c§l¡lÑ2°S·X±XÑ=ðð ðð 
�‰ò	ó ðð  ñà�c—m‘mÑ# c§l¡lÑ2°S·X±XÑ=ÀÑDðð ðð 
�‰˜Ñ	ó	ð0
AØPð
Aà	ó
Að ò-ó ð-ð6 #ØØ"Ø"Ø&*ñRà˜cÑ"ðRð �c—m‘mÑ# c§l¡lÑ2°S·X±XÑ=ðRð �t‰mð	Rð
 �D‰jðRð �t‘ðRð �t‘ðRð ˜t‘OðRð 
óRðp IMØGKØ"ØØ"Ø"Ø&*ñ}à˜cÑ"ð}ð ˜#Ÿ-™-Ñ'ð}ð �s—}‘}Ñ$ s§|¡|Ñ3°c·h±hÑ>ÀÑEð	}ð
 �c—m‘mÑ# c§l¡lÑ2°S·X±XÑ=ÀÑDð}ð �t‰mð}ð �D‰jð}ð �t‘ð}ð �t‘ð}ð ˜t‘Oð}ð 
ó}ðH #ØØ"Ø"Ø&*ñLà˜cÑ"ðLð �h‰hðLð ð	Lð
 �t‰mðLð �D‰jðLð �t‘ðLð �t‘ðLð ˜t‘OðLð 
óLðd !*Ø"ØØ"Ø"Ø&*ñRà˜cÑ"ðRð �h‰hðRð �C˜�H‰oð	Rð
 �t‰mðRð �D‰jðRð �t‘ðRð �t‘ðRð ˜t‘OðRð 
óRðp #ØØ"Ø"ñ2à˜cÑ"ð2ð ð2ð �t‰mð	2ð
 �D‰jð2ð �t‘ð2ð �t‘ð2ð 
ó2óh#ñ&˜tð &¨tó &ñ.
˜C "§*¡*¨S¡/Ñ1°DÑ8ð 
ÀEÈ/ÑDZó 
ð21 Sð 1¨U°?Ñ-Cô 1r    c                   óf  — e Zd ZdZdZ	 	 	 	 ddee   dedz  dedz  de	dz  de	dz  f
d	„Z
d
edefd„Zdedefd„Zde	fd„Zdefd„Zedd„«       Zedefd„«       Zedefd„«       Zej(                  deddfd„«       Zedej,                  dz  fd„«       Zedd„«       Z	 	 	 	 dd„Z	 	 	 	 dd„Zdd„Zy) r   aþ
  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 <apscheduler.job.Job>` 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 <Extensions---JobQueue>`

    .. 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__ <definition.__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
    )Ú_enabledro   Ú_removedr   rf   rd   re   rg   Nr   rd   re   rf   rg   c                 óÄ   — t         st        d«      ‚|| _        || _        |xs t	        |«      | _        || _        || _        d| _        d| _	        t        dd «      | _        y )NzWTo use `Job`, PTB must be installed via `pip install "python-telegram-bot[job-queue]"`.FÚAPSJob)r.   r/   r   rd   r   re   rf   rg   r¾   r½   r   ro   )r2   r   rd   re   rf   rg   s         r   r3   zJob.__init__?  se   € õ Üð5óð ð
 +3ˆŒØ#'ˆŒ	Ø $Ò DÔ(:¸8Ó(DˆŒ	Ø#*ˆŒØ#*ˆŒàˆŒØˆŒä˜ 4Ó(ˆ�	r    Úitemr   c                 ór   — 	 t        | j                  |«      S # t        $ r}t        d|› d�«      |‚d}~ww xY w)aú  Overrides :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)r   ra   ÚAttributeError)r2   rÁ   Úexcs      r   Ú__getattr__zJob.__getattr__X  sG   € ð	Ü˜4Ÿ8™8 TÓ*Ð*øÜò 	Ü ØVÐW[ÐV\Ð\]Ð^óàðûð	ús   ‚ ˜	6¡1±6Úotherc                 ób   — t        || j                  «      r| j                  |j                  k(  S y)aP  Defines equality condition for the :class:`telegram.ext.Job` object.
        Two objects of this class are considered to be equal if their
        :class:`id <apscheduler.job.Job>` are equal.

        Returns:
            :obj:`True` if both objects have :paramref:`id` parameters identical.
            :obj:`False` otherwise.
        F)r=   r   Úid)r2   rÇ   s     r   Ú__eq__z
Job.__eq__n  s(   € ô �e˜TŸ^™^Ô,Ø—7‘7˜eŸh™hÑ&Ð&Ør    c                 ó,   — t        | j                  «      S )zèBuilds 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.
        )ÚhashrÉ   r1   s    r   Ú__hash__zJob.__hash__{  s   € ô �D—G‘G‹}Ðr    c                 ó¬   — t        | | j                  j                  | j                  t	        | j
                  «      | j                  j                  ¬«      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`
        )rÉ   re   r   rk   )r   ra   rÉ   re   r   r   rk   r1   s    r   r6   zJob.__repr__„  s?   € ô .ØØ�x‰x�{‰{Ø—‘Ü'¨¯©Ó6Ø—H‘H×$Ñ$ô
ð 	
r    c                 ó   — | j                   S )z›:class:`apscheduler.job.Job`: The APS Job this job is a wrapper for.

        .. versionchanged:: 20.0
            This property is now read-only.
        )ro   r1   s    r   ra   zJob.job–  s   € ð �y‰yÐr    c                 ó   — | j                   S )z3:obj:`bool`: Whether this job is due to be removed.)r¾   r1   s    r   ÚremovedzJob.removedŸ  ó   € ð �}‰}Ðr    c                 ó   — | j                   S )z):obj:`bool`: Whether this job is enabled.)r½   r1   s    r   ÚenabledzJob.enabled¤  rÒ   r    Ústatusc                 óŽ   — |r"| j                   j                  «        || _        y | j                   j                  «        || _        y rB   )ra   ÚresumeÚpauser½   )r2   rÕ   s     r   rÔ   zJob.enabled©  s3   € áØ�H‰H�O‰OÔð ˆ�ð �H‰H�N‰NÔØˆ�r    c                 ó.   — | j                   j                  S )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`.
        )ra   Únext_run_timer1   s    r   Únext_tz
Job.next_t±  s   € ð �x‰x×%Ñ%Ð%r    c                 ó2   — |j                   d   }||_        |S )a­  Provides 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`
        rP   )rm   ro   )ÚclsÚaps_jobÚext_jobs      r   r�   zJob.from_aps_job¾  s   € ð" —,‘,˜q‘/ˆØˆŒØˆr    c              ƒ   óh   K  — t        j                  | j                  |«      «      ƒ d{  –—†  y7 Œ­w)a…  Executes 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)r”   ÚshieldÚ_runr8   s     r   r_   zJob.runÓ  s#   è ø€ ô �n‰n˜TŸY™Y {Ó3Ó4×4Ò4ús   ‚(2ª0«2c              ƒ   óP  K  — 	 	 |j                   j                  j                  | |«      }|j                  «       ƒ d {  –—†  | j                  |«      ƒ d {  –—†  |j                  | ¬«       y # t        $ r>}t        j                  d| j                  |¬«       Y d }~|j                  | ¬«       y d }~ww xY w7 Œz7 Œc# t        $ rF}|j                  |j                  d || ¬«      d| j                  › d�¬«      ƒ d {  –—†7   Y d }~Œ«d }~ww xY w# |j                  | ¬«       w xY w­w)NzEError while building CallbackContext for job %s. Job will not be run.)Úexc_info)ra   zJob:z:run:process_error)re   )Úcontext_typesÚcontextÚfrom_jobÚ	ExceptionÚ_LOGGERÚcriticalro   Ú_mark_for_persistence_updateÚrefresh_datar   Úcreate_taskÚprocess_errorrÉ   )r2   r5   ræ   rÅ   s       r   râ   zJob._runã  s   è ø€ ð	?ðØ%×3Ñ3×;Ñ;×DÑDÀTÈ;ÓW�ð ×&Ñ&Ó(×(Ð(Ø—-‘- Ó(×(Ð(ð ×4Ñ4¸Ð4Õ>øô# ò Ü× Ñ Ø[Ø—I‘IØ ð !ô ó
 ð ×4Ñ4¸Ð4Õ>ûð#úð )øØ(ùÜò 	Ø×)Ñ)Ø×)Ñ)¨$°¸Ð)Ó>Ø˜DŸG™G˜9Ð$6Ð7ð *ó ÷ ö ûð	ûð ×4Ñ4¸Ð4Õ>üs‹   ‚D&…&A/ «B= ¾B9¿B= ÁB;ÁB= ÁD&Á/	B6Á8"B1ÂB= ÂD&Â1B6Â6B= Â;B= Â=	DÃ6DÃ<C?Ã=DÄD ÄDÄD ÄD#Ä#D&c                 óF   — | j                   j                  «        d| _        y)z–
        Schedules this job for removal from the :class:`JobQueue`. It will be removed without
        executing its callback function again.
        TN)ra   Úremover¾   r1   s    r   Úschedule_removalzJob.schedule_removalü  s   € ð
 	�‰�‰ÔØˆ�r    r°   )r   rÀ   )rÞ   rÀ   r   r]   r¯   r­   )r   r±   r²   r³   r´   r   r   r¹   rµ   rR   r3   rÆ   r·   rÊ   rÍ   r6   r¶   ra   rÑ   rÔ   ÚsetterrC   rD   rÛ   Úclassmethodr�   r_   râ   rñ   r-   r    r   r   r   ñ  s}  „ ñ@ðD	€Ið #ØØ"Ø"ñ)à˜cÑ"ð)ð �t‰mð)ð �D‰jð	)ð
 �t‘ð)ð �t‘ó)ð2 ð ¨ó ð,˜Fð  tó ð˜#ó ð
˜#ó 
ð$ òó ðð ð˜ò ó ðð ð˜ò ó ðð ‡^�^ð˜dð  tò ó ðð ð
&˜Ÿ™ tÑ+ò 
&ó ð
&ð òó ðð(5ØPð5à	ó5ð ?ØPð?à	ó?ô2r    r   )0r³   r”   rD   rC   r¡   rY   Útypingr   r   r   r   r   Úapscheduler.executors.asyncior   Úapscheduler.schedulers.asyncior	   r.   ÚImportErrorÚtelegram._utils.datetimer
   r   Útelegram._utils.loggingr   Útelegram._utils.reprr   Útelegram._utils.typesr   Útelegram.ext._extbotr   Útelegram.ext._utils.typesr   r   Úcollections.abcr   Úapscheduler.jobr   rÀ   Útelegram.extr   r¥   Úrangerº   r   ré   r¹   rµ   r   r   r-   r    r   ú<module>r     s¼   ðñ& 9ã Û Û 	Û ß >Õ >ðÝ=Ý?à€M÷ 3Ý .Ý ?Ý *Ý 'ß 6áÝ(áÝ1å(ñ ‘%˜“(‹O€	Ù
�X¨*Ô
5€ð	N ð 	N¨Có 	Nôk
1ˆw�s‰|ô k
1ô\Qˆ'�#‰,õ Qøðc ò Ø‚Mðús   ¢B+ Â+B5Â4B5