L i? ~dZddlmZddlmZmZddlmZddlm Z m Z m Z m Z m Z mZmZddlZddlmZddlmZmZmZdd lmZmZmZmZmZmZmZdd lm Z dd l!m"Z"m#Z#dd l$m%Z%dd l&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2ddl3m4Z4ddl5m6Z6e rddl7m8Z8ddl9m:Z:m;Z;mZ>edeZ?edede)fZ@eddZAedZBedZCedZDeddZEgd ZFd!ZGGd"de e.e/e2e0e-e1fZHeHe'de%jeJe e feJe e feJe e fe)e%jfZKy)#zEThis module contains the Builder classes for the telegram.ext module.)Queue) Collection Coroutine)Path) TYPE_CHECKINGAnyCallableGenericOptionalTypeVarUnionN)Bot) DEFAULT_FALSE DEFAULT_NONE DefaultValue)BaseUrlDVInputDVType FilePathInput HTTPVersionODVInput SocketOpt) Application)BaseUpdateProcessorSimpleUpdateProcessor) ContextTypes)ExtBot)JobQueue)Updater)BDBTCCTCDJQUD) BaseRequest) HTTPXRequest)Update)BasePersistenceBaseRateLimiterCallbackContextDefaults)RLARGSInBT)boundInJQInCCTr+InUDInCDInBD BuilderTypeApplicationBuilder))requestrequest instance)get_updates_requestget_updates_request instance)connection_pool_sizer;)proxyr<)socket_optionsr=) pool_timeoutr>)connect_timeoutr?) read_timeoutr@) write_timeoutrA)media_write_timeoutrB) http_versionrC) get_updates_connection_pool_sizerD)get_updates_proxyrE)get_updates_socket_optionsrF)get_updates_pool_timeoutrG)get_updates_connect_timeoutrH)get_updates_read_timeoutrI)get_updates_write_timeoutrJ)get_updates_http_versionrK) base_file_urlrL)base_urlrM)tokenrN)defaultsrO)arbitrary_callback_datarP) private_keyrQ) rate_limiterzrate_limiter instance) local_modezlocal_mode settingz5The parameter `{}` may only be set, if no {} was set.c eZdZdZdZdcdZdedefdZde fdZ d e dd fd Z d e dd fd Z dd deeeeeeeffdZ dddedeeeeeeeefdeee efdefdZdede defdZdededefdZdededefdZ dedd fdZ!d e dedd fdZ"dededefdZ#dede$defdZ%dede&e e'jPe'jRfdefdZ*ded e+e,defd!Z-ded"ee.defd#Z/ded$ee.defd%Z0ded&ee.defd'Z1ded(ee.defd)Z2ded*ee.defd+Z3ded,e4defd-Z5ded.edefd/Z6ded0e$defd1Z7ded2e&e e'jPe'jRfdefd3Z8ded4e+e,defd5Z9ded6ee.defd7Z:ded8ee.defd9Z;ded:ee.defd;Ze4defd?Z> ddded@e&e?e@fdAee&e?e@fdefdBZAdedCdDdefdEZBdedFe&ee$fdefdGZCdedHedefdIZDdd dJeEddKfdLZFdedMdNdefdOZGdedPe&ee$dQfdefdRZHdd dSeIddTfdUZJdedVdWdefdXZK dedYZLdedZeeMdefd[ZNded\eOegePeed ffdefd]ZQded^eOegePeed ffdefd_ZRded`eOegePeed ffdefdaZS dfdbZTy )gr6aThis class serves as initializer for :class:`telegram.ext.Application` via the so called `builder pattern`_. To build a :class:`telegram.ext.Application`, one first initializes an instance of this class. Arguments for the :class:`telegram.ext.Application` to build are then added by subsequently calling the methods of the builder. Finally, the :class:`telegram.ext.Application` is built by calling :meth:`build`. In the simplest case this can look like the following example. Example: .. code:: python application = ApplicationBuilder().token("TOKEN").build() Please see the description of the individual methods for information on which arguments can be set and what the defaults are when not called. When no default is mentioned, the argument will not be used by default. Note: * Some arguments are mutually exclusive. E.g. after calling :meth:`token`, you can't set a custom bot with :meth:`bot` and vice versa. * Unless a custom :class:`telegram.Bot` instance is set via :meth:`bot`, :meth:`build` will use :class:`telegram.ext.ExtBot` for the bot. .. seealso:: :wiki:`Your First Bot `, :wiki:`Builder Pattern ` .. versionchanged:: 22.0 Removed deprecated methods ``proxy_url`` and ``get_updates_proxy_url``. .. _`builder pattern`: https://en.wikipedia.org/wiki/Builder_pattern )(_application_class_application_kwargs_arbitrary_callback_data_base_file_url _base_url_bot_connect_timeout_connection_pool_size_context_types _defaults_get_updates_connect_timeout!_get_updates_connection_pool_size_get_updates_http_version_get_updates_pool_timeout_get_updates_proxy_get_updates_read_timeout_get_updates_request_get_updates_socket_options_get_updates_write_timeout _http_version _job_queue _local_mode_media_write_timeout _persistence _pool_timeout _post_init_post_shutdown _post_stop _private_key_private_key_password_proxy _rate_limiter _read_timeout_request_socket_options_token_update_processor _update_queue_updater_write_timeoutselfcRtd|_td|_td|_t|_t|_t|_t|_t|_ t|_ t|_ t|_ t|_ t|_t|_t|_t|_t|_t|_t|_t|_td|_t|_t|_t|_t4|_t4|_t|_tt=|_ ttA|_!t|_$ttK|_&ttN|_(i|_)tUd|_+t|_,d|_-d|_.d|_/t|_0td|_1y#tD$r#}dtG|vrt|_!Yd}~d}~wwxYw)Nzhttps://api.telegram.org/botz!https://api.telegram.org/file/bot1.1zPTB must be installed via)max_concurrent_updates)2rrxrYrXrr\rsrwr[rur|rkrmrvr`rcrfr_rdrgrbrerarqrrr^rrWrjrZrrzrri RuntimeErrorstrrlrr]rrUrVrryr{rnrorprtrh)r}excs f/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/telegram/ext/_applicationbuilder.py__init__zApplicationBuilder.__init__s#/#3 *67U*V/;<_/`3?"CO ?K1=.:/;5A!.:.: ?K.O[KW(=I):F&;G':F&:F!7CE7J&-96B"-9HU%)6". COPUPWCX +2>xz2JDO 8D4@4P=I+=V68 6K#$7 ,8 X\\`X\8D+7+># +*#c(:*DOO +sG:: H&H!!H& get_updatesreturnc|rdnd}tt||dtst||dStjt||d}tjt||d}|r'tjt||dxsd}n&tjt||dxsd}t||d t||d t||d t||d d }|s|j|d<|j Dcic]\}}t|tr||} }}tjt||dxsd} t d||| |d| Scc}}w)N _get_updates__r7r<r=r;rr?r@rAr>r?r@rAr>rBrCr)r;r<rCr=) isinstancegetattrr get_valuerkitemsr') r}rprefixr<r=r;timeoutskeyvalueeffective_timeoutsrCs r_build_requestz!ApplicationBuilder._build_requests$/S'$6('(:;\J4F87!34 4&&wtxu5E'FG%//>W0XY &&wtx?S5T'UV[Z[ ! &&wtx?S5T'UV]Z] ! 'tx-GH#DVHL*AB$TfX]+CD#DVHL*AB  .2.G.GH* +*2)9 %3ES_A`CJ  $--gdvhlE<ct|jtr tdt |jtj |j tj |jtj |jtj |jtj |jtj |j|jd|jdtj |jtj |j S)NzNo bot token was set.FrT) rNrMrLrQprivate_key_passwordrOrPr7r9rRrS)rrxrrrrrYrXrqrrr^rWrrtrj)r}s r_build_ext_botz!ApplicationBuilder._build_ext_bot s dkk< 067 7++!++DNN;&001D1DE$..t/@/@A!-!7!78R8R!S!++DNN;$0$:$:4;X;X$Y''E': $ 3 3 3 E%//0B0BC#--d.>.>?  nameNcf|jturttj |dy)N bot instance)rZrr _TWO_ARGS_REQformatr}rs r _bot_checkzApplicationBuilder._bot_checks+ 99L (}33D.IJ J )rcj|jtdfvrttj |dy)Nupdater)r{rrrrrs r_updater_checkz!ApplicationBuilder._updater_check!s0 ==t 4 4}33D)DE E 5r+ApplicationBuilder[BT, CCT, UD, CD, BD, JQ]cntj|j}tj|j}t |j ts |j st |j tr|j}n |j }tj|j}|j d}nFt||}n8|j }|j j}|j j}tj|jd||||j||tj|j|j|j |j"d |j$}||j'|||j)||S)aBuilds a :class:`telegram.ext.Application` with the provided arguments. Calls :meth:`telegram.ext.JobQueue.set_application` and :meth:`telegram.ext.BasePersistence.set_bot` if appropriate. Returns: :class:`telegram.ext.Application` N)bot update_queue) rrrupdate_processor job_queue persistence context_types post_init post_shutdown post_stopr)rrrirlrr{rZrrzrrrrUryr]rnrorprVset_applicationset_bot)r}rrrrr applications rbuildzApplicationBuilder.build%sp!**4??; ",,T->->? dmm\ 2dmm6K$))\2..0ii'11$2D2DEL}}$!c EmmG--##C==55L= L`, :meth:`base_file_url` .. versionchanged:: 21.11 Supports callable input and string formatting. Args: base_url (:obj:`str` | Callable[[:obj:`str`], :obj:`str`]): The URL or input for the URL as accepted by :paramref:`telegram.Bot.base_url`. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. rM)rrrY)r}rMs rrMzApplicationBuilder.base_urls*"  # J'! rrLcX|jd|jd||_|S)aSets the base file URL for :attr:`telegram.ext.Application.bot`. If not called, will default to ``'https://api.telegram.org/file/bot'``. .. seealso:: :paramref:`telegram.Bot.base_file_url`, :wiki:`Local Bot API Server `, :meth:`base_url` .. versionchanged:: 21.11 Supports callable input and string formatting. Args: base_file_url (:obj:`str` | Callable[[:obj:`str`], :obj:`str`]): The URL or input for the URL as accepted by :paramref:`telegram.Bot.base_file_url`. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. rL)rrrX)r}rLs rrLz ApplicationBuilder.base_file_urls+" ( O,+ rc B|rdnd}|dz}gd}|s|jd|D]@}tt|d||tr#t t j ||tt|d|dtst t j |dtt|d|dtst t j |dtt|d|d tst t j |d tt|d|d tst t j |d |j||jtdfvrt t j |d y) N get_updates_rr7rrBrr;r<r=rCupdater instance) appendrrrrrrrr{r)r}rrrrattrs r_request_checkz!ApplicationBuilder._request_checksy#.B !W OO1 2 EDgdaxv,>?N"=#7#7d#CDD E'$!F83G(HI<X}33D:PQR R'$!F85(9:LI}33D'BC C'$!F8>(BC\R}33D:JKL L'$!F8<(@A<P}33D.IJ J  ==t 4 4}33D:LMN N 5rc|r4|jtur"ttj d|d|j turttj |d|j tur/ttj |rd|d|d|jtdfvr/ttj |rd|d|dy)Nrr:r8rr)rerrrrrvrZr{)r}rrs r_request_param_checkz'ApplicationBuilder._request_param_checks 444LH$$|D6%:BN  ==t 4 4$$k|D6%:U^_ OSU^_  5rr7c8|jd||_|S)aSets a :class:`telegram.request.BaseRequest` instance for the :paramref:`telegram.Bot.request` parameter of :attr:`telegram.ext.Application.bot`. .. seealso:: :meth:`get_updates_request` Args: request (:class:`telegram.request.BaseRequest`): The request instance. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. Fr)rrv)r}r7s rr7zApplicationBuilder.requests! .  rr;c:|jdd||_|S)aSets the size of the connection pool for the :paramref:`~telegram.request.HTTPXRequest.connection_pool_size` parameter of :attr:`telegram.Bot.request`. Defaults to ``256``. .. include:: inclusions/pool_size_tip.rst .. seealso:: :meth:`get_updates_connection_pool_size` Args: connection_pool_size (:obj:`int`): The size of the connection pool. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. r;Frr)rr\)r}r;s rr;z'ApplicationBuilder.connection_pool_sizes% !!'=5!Q%9" rr<c:|jdd||_|S)a]Sets the proxy for the :paramref:`~telegram.request.HTTPXRequest.proxy` parameter of :attr:`telegram.Bot.request`. Defaults to :obj:`None`. .. seealso:: :meth:`get_updates_proxy` .. versionadded:: 20.7 Args: proxy (:obj:`str` | ``httpx.Proxy`` | ``httpx.URL``): The URL to a proxy server, a ``httpx.Proxy`` object or a ``httpx.URL`` object. See :paramref:`telegram.request.HTTPXRequest.proxy` for more information. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. r<Fr)rrs)r}r<s rr<zApplicationBuilder.proxy s# !!wE!B  rr=c:|jdd||_|S)a*Sets the options for the :paramref:`~telegram.request.HTTPXRequest.socket_options` parameter of :attr:`telegram.Bot.request`. Defaults to :obj:`None`. .. seealso:: :meth:`get_updates_socket_options` .. versionadded:: 20.7 Args: socket_options (Collection[:obj:`tuple`], optional): Socket options. See :paramref:`telegram.request.HTTPXRequest.socket_options` for more information. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. r=Fr)rrw)r}r=s rr=z!ApplicationBuilder.socket_optionss% !!'7U!K- rr?c:|jdd||_|S)aSets the connection attempt timeout for the :paramref:`~telegram.request.HTTPXRequest.connect_timeout` parameter of :attr:`telegram.Bot.request`. Defaults to ``5.0``. .. seealso:: :meth:`get_updates_connect_timeout` Args: connect_timeout (:obj:`float`): See :paramref:`telegram.request.HTTPXRequest.connect_timeout` for more information. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. r?Fr)rr[)r}r?s rr?z"ApplicationBuilder.connect_timeout0s% !!'8e!L / rr@c:|jdd||_|S)aSets the waiting timeout for the :paramref:`~telegram.request.HTTPXRequest.read_timeout` parameter of :attr:`telegram.Bot.request`. Defaults to ``5.0``. .. seealso:: :meth:`get_updates_read_timeout` Args: read_timeout (:obj:`float`): See :paramref:`telegram.request.HTTPXRequest.read_timeout` for more information. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. r@Fr)rru)r}r@s rr@zApplicationBuilder.read_timeoutBs$ !!~5!I) rrAc:|jdd||_|S)aSets the write operation timeout for the :paramref:`~telegram.request.HTTPXRequest.write_timeout` parameter of :attr:`telegram.Bot.request`. Defaults to ``5.0``. .. seealso:: :meth:`get_updates_write_timeout` Args: write_timeout (:obj:`float`): See :paramref:`telegram.request.HTTPXRequest.write_timeout` for more information. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. rAFr)rr|)r}rAs rrAz ApplicationBuilder.write_timeoutTs$ !!E!J+ rrBc:|jdd||_|S)aSets the media write operation timeout for the :paramref:`~telegram.request.HTTPXRequest.media_write_timeout` parameter of :attr:`telegram.Bot.request`. Defaults to ``20``. .. versionadded:: 21.0 Args: media_write_timeout (:obj:`float`): See :paramref:`telegram.request.HTTPXRequest.media_write_timeout` for more information. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. rBFr)rrk)r}rBs rrBz&ApplicationBuilder.media_write_timeoutfs% !!'<%!P$7! rr>c:|jdd||_|S)a8Sets the connection pool's connection freeing timeout for the :paramref:`~telegram.request.HTTPXRequest.pool_timeout` parameter of :attr:`telegram.Bot.request`. Defaults to ``1.0``. .. include:: inclusions/pool_size_tip.rst .. seealso:: :meth:`get_updates_pool_timeout` Args: pool_timeout (:obj:`float`): See :paramref:`telegram.request.HTTPXRequest.pool_timeout` for more information. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. r>Fr)rrm)r}r>s rr>zApplicationBuilder.pool_timeoutzs$ !!~5!I) rrCc:|jdd||_|S)aSets the HTTP protocol version which is used for the :paramref:`~telegram.request.HTTPXRequest.http_version` parameter of :attr:`telegram.Bot.request`. By default, HTTP/1.1 is used. .. seealso:: :meth:`get_updates_http_version` Note: Users have observed stability issues with HTTP/2, which happen due to how the `h2 library handles `_ cancellations of keepalive connections. See `#3556 `_ for a discussion. If you want to use HTTP/2, you must install PTB with the optional requirement ``http2``, i.e. .. code-block:: bash pip install "python-telegram-bot[http2]" Keep in mind that the HTTP/1.1 implementation may be considered the `"more robust option at this time" `_. .. versionadded:: 20.1 .. versionchanged:: 20.2 Reset the default version to 1.1. Args: http_version (:obj:`str`): Pass ``"2"`` or ``"2.0"`` if you'd like to use HTTP/2 for making requests to Telegram. Defaults to ``"1.1"``, in which case HTTP/1.1 is used. .. versionchanged:: 20.5 Accept ``"2"`` as a valid value. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. rCFr)rrh)r}rCs rrCzApplicationBuilder.http_versions%J !!~5!I) rr9c8|jd||_|S)aSets a :class:`telegram.request.BaseRequest` instance for the :paramref:`~telegram.Bot.get_updates_request` parameter of :attr:`telegram.ext.Application.bot`. .. seealso:: :meth:`request` Args: get_updates_request (:class:`telegram.request.BaseRequest`): The request instance. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. Tr)rre)r}r9s rr9z&ApplicationBuilder.get_updates_requests" -$7! rrDc:|jdd||_|S)aSets the size of the connection pool for the :paramref:`telegram.request.HTTPXRequest.connection_pool_size` parameter which is used for the :meth:`telegram.Bot.get_updates` request. Defaults to ``1``. .. seealso:: :meth:`connection_pool_size` Args: get_updates_connection_pool_size (:obj:`int`): The size of the connection pool. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. r;Tr)rr`)r}rDs rrDz3ApplicationBuilder.get_updates_connection_pool_sizes% !!'=4!P1Q. rrEc:|jdd||_|S)acSets the proxy for the :paramref:`telegram.request.HTTPXRequest.proxy` parameter which is used for :meth:`telegram.Bot.get_updates`. Defaults to :obj:`None`. .. seealso:: :meth:`proxy` .. versionadded:: 20.7 Args: proxy (:obj:`str` | ``httpx.Proxy`` | ``httpx.URL``): The URL to a proxy server, a ``httpx.Proxy`` object or a ``httpx.URL`` object. See :paramref:`telegram.request.HTTPXRequest.proxy` for more information. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. r<Tr)rrc)r}rEs rrEz$ApplicationBuilder.get_updates_proxys$$ !!wD!A"3 rrFc:|jdd||_|S)a:Sets the options for the :paramref:`~telegram.request.HTTPXRequest.socket_options` parameter of :paramref:`telegram.Bot.get_updates_request`. Defaults to :obj:`None`. .. seealso:: :meth:`socket_options` .. versionadded:: 20.7 Args: get_updates_socket_options (Collection[:obj:`tuple`], optional): Socket options. See :paramref:`telegram.request.HTTPXRequest.socket_options` for more information. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. r=Tr)rrf)r}rFs rrFz-ApplicationBuilder.get_updates_socket_optionss%" !!'7T!J+E( rrHc:|jdd||_|S)aSets the connection attempt timeout for the :paramref:`telegram.request.HTTPXRequest.connect_timeout` parameter which is used for the :meth:`telegram.Bot.get_updates` request. Defaults to ``5.0``. .. seealso:: :meth:`connect_timeout` Args: get_updates_connect_timeout (:obj:`float`): See :paramref:`telegram.request.HTTPXRequest.connect_timeout` for more information. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. r?Tr)rr_)r}rHs rrHz.ApplicationBuilder.get_updates_connect_timeouts% !!'8d!K,G) rrIc:|jdd||_|S)aSets the waiting timeout for the :paramref:`telegram.request.HTTPXRequest.read_timeout` parameter which is used for the :meth:`telegram.Bot.get_updates` request. Defaults to ``5.0``. .. seealso:: :meth:`read_timeout` Args: get_updates_read_timeout (:obj:`float`): See :paramref:`telegram.request.HTTPXRequest.read_timeout` for more information. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. r@Tr)rrd)r}rIs rrIz+ApplicationBuilder.get_updates_read_timeout$ !!~4!H)A& rrJc:|jdd||_|S)aSets the write operation timeout for the :paramref:`telegram.request.HTTPXRequest.write_timeout` parameter which is used for the :meth:`telegram.Bot.get_updates` request. Defaults to ``5.0``. .. seealso:: :meth:`write_timeout` Args: get_updates_write_timeout (:obj:`float`): See :paramref:`telegram.request.HTTPXRequest.write_timeout` for more information. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. rATr)rrg)r}rJs rrJz,ApplicationBuilder.get_updates_write_timeout.s$ !!D!I*C' rrGc:|jdd||_|S)a$Sets the connection pool's connection freeing timeout for the :paramref:`~telegram.request.HTTPXRequest.pool_timeout` parameter which is used for the :meth:`telegram.Bot.get_updates` request. Defaults to ``1.0``. .. seealso:: :meth:`pool_timeout` Args: get_updates_pool_timeout (:obj:`float`): See :paramref:`telegram.request.HTTPXRequest.pool_timeout` for more information. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. r>Tr)rrb)r}rGs rrGz+ApplicationBuilder.get_updates_pool_timeoutBrrrKc:|jdd||_|S)aSets the HTTP protocol version which is used for the :paramref:`~telegram.request.HTTPXRequest.http_version` parameter which is used in the :meth:`telegram.Bot.get_updates` request. By default, HTTP/1.1 is used. .. seealso:: :meth:`http_version` Note: Users have observed stability issues with HTTP/2, which happen due to how the `h2 library handles `_ cancellations of keepalive connections. See `#3556 `_ for a discussion. You will also need to install the http2 dependency. Keep in mind that the HTTP/1.1 implementation may be considered the `"more robust option at this time" `_. .. code-block:: bash pip install httpx[http2] .. versionadded:: 20.1 .. versionchanged:: 20.2 Reset the default version to 1.1. Args: get_updates_http_version (:obj:`str`): Pass ``"2"`` or ``"2.0"`` if you'd like to use HTTP/2 for making requests to Telegram. Defaults to ``"1.1"``, in which case HTTP/1.1 is used. .. versionchanged:: 20.5 Accept ``"2"`` as a valid value. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. rCTr)rra)r}rKs rrKz+ApplicationBuilder.get_updates_http_versionVs%L !!~4!H)A& rrQpasswordc|jd|jdt|tr|nt |j |_|t|tr ||_|St |j |_|S)aSets the private key and corresponding password for decryption of telegram passport data for :attr:`telegram.ext.Application.bot`. Examples: :any:`Passport Bot ` .. seealso:: :wiki:`Telegram Passports ` Args: private_key (:obj:`bytes` | :obj:`str` | :obj:`pathlib.Path`): The private key or the file path of a file that contains the key. In the latter case, the file's content will be read automatically. password (:obj:`bytes` | :obj:`str` | :obj:`pathlib.Path`, optional): The corresponding password or the file path of a file that contains the password. In the latter case, the file's content will be read automatically. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. rQ)rrrbytesr read_bytesrqrr)r}rQrs rrQzApplicationBuilder.private_keys0  & M*&k59KtK?P?[?[?]   z(E:)1D & *.h)B)B)DD & rrOr,cX|jd|jd||_|S)aSets the :class:`telegram.ext.Defaults` instance for :attr:`telegram.ext.Application.bot`. .. seealso:: :wiki:`Adding Defaults to Your Bot ` Args: defaults (:class:`telegram.ext.Defaults`): The defaults instance. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. rO)rrr^)r}rOs rrOzApplicationBuilder.defaultss*  # J'! rrPcX|jd|jd||_|S)aISpecifies whether :attr:`telegram.ext.Application.bot` should allow arbitrary objects as callback data for :class:`telegram.InlineKeyboardButton` and how many keyboards should be cached in memory. If not called, only strings can be used as callback data and no data will be stored in memory. Important: If you want to use this feature, you must install PTB with the optional requirement ``callback-data``, i.e. .. code-block:: bash pip install "python-telegram-bot[callback-data]" Examples: :any:`Arbitrary callback_data Bot ` .. seealso:: :wiki:`Arbitrary callback_data ` Args: arbitrary_callback_data (:obj:`bool` | :obj:`int`): If :obj:`True` is passed, the default cache size of ``1024`` will be used. Pass an integer to specify a different cache size. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. rP)rrrW)r}rPs rrPz*ApplicationBuilder.arbitrary_callback_datas-: 12 56(?% rrScX|jd|jd||_|S)aSpecifies the value for :paramref:`~telegram.Bot.local_mode` for the :attr:`telegram.ext.Application.bot`. If not called, will default to :obj:`False`. .. seealso:: :wiki:`Local Bot API Server ` Args: local_mode (:obj:`bool`): Whether the bot should run in local mode. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. rS)rrrj)r}rSs rrSzApplicationBuilder.local_modes+  % L)% rrz-ApplicationBuilder[InBT, CCT, UD, CD, BD, JQ]c|jdtD]A\}}tt|d|tr$t t jd|||_|S)aZSets a :class:`telegram.Bot` instance for :attr:`telegram.ext.Application.bot`. Instances of subclasses like :class:`telegram.ext.ExtBot` are also valid. Args: bot (:class:`telegram.Bot`): The bot. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. rr) r _BOT_CHECKSrrrrrrrZ)r}rrerrors rrzApplicationBuilder.botsd E"& GKD%gdavJ7F"=#7#7u#EFF G  rrz Queue[object]cz|jtdfvrttj dd||_|S)aSets a :class:`asyncio.Queue` instance for :attr:`telegram.ext.Application.update_queue`, i.e. the queue that the application will fetch updates from. Will also be used for the :attr:`telegram.ext.Application.updater`. If not called, a queue will be instantiated. .. seealso:: :attr:`telegram.ext.Updater.update_queue` Args: update_queue (:class:`asyncio.Queue`): The queue. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. Nrr)r{rrrrrz)r}rs rrzApplicationBuilder.update_queues; ==t 4 4}33NDVWX X) rconcurrent_updatesrcd|durd}n|durd}t|tr t|}||_|S)aDSpecifies if and how many updates may be processed concurrently instead of one by one. If not called, updates will be processed one by one. Warning: Processing updates concurrently is not recommended when stateful handlers like :class:`telegram.ext.ConversationHandler` are used. Only use this if you are sure that your bot does not (explicitly or implicitly) rely on updates being processed sequentially. .. include:: inclusions/pool_size_tip.rst .. seealso:: :attr:`telegram.ext.Application.concurrent_updates` Args: concurrent_updates (:obj:`bool` | :obj:`int` | :class:`BaseUpdateProcessor`): Passing :obj:`True` will allow for ``256`` updates to be processed concurrently using :class:`telegram.ext.SimpleUpdateProcessor`. Pass an integer to specify a different number of updates that may be processed concurrently. Pass an instance of :class:`telegram.ext.BaseUpdateProcessor` to use that instance for handling updates concurrently. .. versionchanged:: 20.4 Now accepts :class:`BaseUpdateProcessor` instances. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. TrFr)rintrry)r}rs rrz%ApplicationBuilder.concurrent_updatessI>  %!$  5 (!"  (# .!67I!J 7I rrz-ApplicationBuilder[BT, CCT, UD, CD, BD, InJQ]c||_|S)aSets a :class:`telegram.ext.JobQueue` instance for :attr:`telegram.ext.Application.job_queue`. If not called, a job queue will be instantiated if the requirements of :class:`telegram.ext.JobQueue` are installed. Examples: :any:`Timer Bot ` .. seealso:: :wiki:`Job Queue ` Note: * :meth:`telegram.ext.JobQueue.set_application` will be called automatically by :meth:`build`. * The job queue will be automatically started and stopped by :meth:`telegram.ext.Application.start` and :meth:`telegram.ext.Application.stop`, respectively. * When passing :obj:`None` or when the requirements of :class:`telegram.ext.JobQueue` are not installed, :attr:`telegram.ext.ConversationHandler.conversation_timeout` can not be used, as this uses :attr:`telegram.ext.Application.job_queue` internally. Args: job_queue (:class:`telegram.ext.JobQueue`): The job queue. Pass :obj:`None` if you don't want to use a job queue. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. )ri)r}rs rrzApplicationBuilder.job_queueAs<$ rrzBasePersistence[Any, Any, Any]c||_|S)aSets a :class:`telegram.ext.BasePersistence` instance for :attr:`telegram.ext.Application.persistence`. Note: When using a persistence, note that all data stored in :attr:`context.user_data `, :attr:`context.chat_data `, :attr:`context.bot_data ` and in :attr:`telegram.ext.ExtBot.callback_data_cache` must be copyable with :func:`copy.deepcopy`. This is due to the data being deep copied before handing it over to the persistence in order to avoid race conditions. Examples: :any:`Persistent Conversation Bot ` .. seealso:: :wiki:`Making Your Bot Persistent ` Warning: If a :class:`telegram.ext.ContextTypes` instance is set via :meth:`context_types`, the persistence instance must use the same types! Args: persistence (:class:`telegram.ext.BasePersistence`): The persistence instance. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. )rl)r}rs rrzApplicationBuilder.persistencebs<( rc||_|S)aSets a :class:`telegram.ext.ContextTypes` instance for :attr:`telegram.ext.Application.context_types`. Examples: :any:`Context Types Bot ` Args: context_types (:class:`telegram.ext.ContextTypes`): The context types. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. )r])r}rs rrz ApplicationBuilder.context_typess , rrcd| ||_|S|jdf|jdffD]4\}}t|trt t jd|tD]A\}}tt|d|tr$t t jd|||_|S)aYSets a :class:`telegram.ext.Updater` instance for :attr:`telegram.ext.Application.updater`. The :attr:`telegram.ext.Updater.bot` and :attr:`telegram.ext.Updater.update_queue` will be used for :attr:`telegram.ext.Application.bot` and :attr:`telegram.ext.Application.update_queue`, respectively. Args: updater (:class:`telegram.ext.Updater` | :obj:`None`): The updater instance or :obj:`None` if no updater should be used. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. rrrr) r{rZrzrrrrrrr)r}rrr attr_names rrzApplicationBuilder.updaters ?#DMKYY '    0  KKD%dL1"=#7#7 5#IJJ  K!, K Iugda {O None: await application.bot.set_my_commands([('start', 'Starts the bot')]) application = Application.builder().token("TOKEN").post_init(post_init).build() Note: |post_methods_note| .. seealso:: :meth:`post_stop`, :meth:`post_shutdown` Args: post_init (:term:`coroutine function`): The custom callback. Must be a :term:`coroutine function` and must accept exactly one positional argument, which is the :class:`~telegram.ext.Application`:: async def post_init(application: Application) -> None: Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. )rn)r}rs rrzApplicationBuilder.post_initsH$ rrc||_|S)a+ Sets a callback to be executed by :meth:`Application.run_polling` and :meth:`Application.run_webhook` *after* executing :meth:`Updater.shutdown` and :meth:`Application.shutdown`. Tip: This can be used for custom shutdown logic that requires to await coroutines, e.g. closing a database connection Example: .. code:: async def post_shutdown(application: Application) -> None: await application.bot_data['database'].close() application = Application.builder() .token("TOKEN") .post_shutdown(post_shutdown) .build() Note: |post_methods_note| .. seealso:: :meth:`post_init`, :meth:`post_stop` Args: post_shutdown (:term:`coroutine function`): The custom callback. Must be a :term:`coroutine function` and must accept exactly one positional argument, which is the :class:`~telegram.ext.Application`:: async def post_shutdown(application: Application) -> None: Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. )ro)r}rs rrz ApplicationBuilder.post_shutdownsL, rrc||_|S)a Sets a callback to be executed by :meth:`Application.run_polling` and :meth:`Application.run_webhook` *after* executing :meth:`Updater.stop` and :meth:`Application.stop`. .. versionadded:: 20.1 Tip: This can be used for custom stop logic that requires to await coroutines, e.g. sending message to a chat before shutting down the bot. Hint: The callback will be called only, if :meth:`Application.stop` was indeed called successfully. For example, if the application is stopped early by calling :meth:`Application.stop_running` within :meth:`post_init`, then the set callback will *not* be called. Example: .. code:: async def post_stop(application: Application) -> None: await application.bot.send_message(123456, "Shutting down...") application = Application.builder() .token("TOKEN") .post_stop(post_stop) .build() Note: |post_methods_note| .. seealso:: :meth:`post_init`, :meth:`post_shutdown` Args: post_stop (:term:`coroutine function`): The custom callback. Must be a :term:`coroutine function` and must accept exactly one positional argument, which is the :class:`~telegram.ext.Application`:: async def post_stop(application: Application) -> None: Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. )rp)r}rs rrzApplicationBuilder.post_stops\$ rcX|jd|jd||_|S)aSets a :class:`telegram.ext.BaseRateLimiter` instance for the :paramref:`telegram.ext.ExtBot.rate_limiter` parameter of :attr:`telegram.ext.Application.bot`. Args: rate_limiter (:class:`telegram.ext.BaseRateLimiter`): The rate limiter. Returns: :class:`ApplicationBuilder`: The same builder with the updated argument. rR)rrrt)r}rRs rrRzApplicationBuilder.rate_limiter7s+ ' N+) r)r}InitApplicationBuilder)N)r}rrz%ContextTypes[InCCT, InUD, InCD, InBD]rz3ApplicationBuilder[BT, InCCT, InUD, InCD, InBD, JQ])r}rrRzBaseRateLimiter[RLARGS]rz7ApplicationBuilder[ExtBot[RLARGS], CCT, UD, CD, BD, JQ])U__name__ __module__ __qualname____doc__ __slots__rboolr&rrrrrrrr!r"r%r#r r$rr5typerr dictobjectrrNrrMrLrrr7rr;r httpxProxyURLr<rrr=floatr?r@rArBr>rrCr9rDrErFrHrIrJrGrKrrrQrOrPrSr.rrrr0rrrrrr rrrrrRrrrr6r6ds>)IV1?f' $' ;' R  $KsKtKF3F4F7;7 Rb"b", -7x/3 Cc3S,H IJc6k*+  6 K   {g+,KK,O$O4O>4D(kKK ;ck&Kc5;; .I(J{([*Y:OT_&kHUOP[$;huo+$KK$08 (;huo+(';'k'k'R+KT_"=@ &.3Ceii4O.P ,7A)7L *8@ (5=e_ (6>uo (5=e_ (((5@( (Z;?##5-/0#5 !567#  #J{j["  49$)4D   D$;$;  9*;o+&--/4T3@U5U/V- -^; 9B(H B;> ?&kHW,=+@%%&. }iSRV>W/W&X% %N''*2K=)CQTVZNB[3[*\' 'R//&. }iSRV>W/W&X/ /b;/ Cr)Lrasynciorcollections.abcrrpathlibrtypingrrr r r r r r telegram._botrtelegram._utils.defaultvaluerrrtelegram._utils.typesrrrrrrrtelegram.ext._applicationr!telegram.ext._baseupdateprocessorrrtelegram.ext._contexttypesrtelegram.ext._extbotrtelegram.ext._jobqueuertelegram.ext._updaterrtelegram.ext._utils.typesr r!r"r#r$r%telegram.requestr&telegram.request._httpxrequestr'telegramr( telegram.extr)r*r+r,r-r.r0r1r2r3r4r5rrr6 DEFAULT_TYPErrrrrrsB&L1RRR RR2X3'+)==(7XX0 vS!vU4>2301vvvm+?@  <H dS"b"b!89dP't !! S#X S#X S#X**+  -r