mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 14:35:00 +01:00
Add Quotes for Installation Instructions With Optional Dependencies (#3780)
This commit is contained in:
parent
623d2f7f0b
commit
4a6e0fd7a6
18 changed files with 47 additions and 47 deletions
20
README.rst
20
README.rst
|
@ -148,20 +148,20 @@ Optional Dependencies
|
|||
|
||||
PTB can be installed with optional dependencies:
|
||||
|
||||
* ``pip install python-telegram-bot[passport]`` installs the `cryptography>=39.0.1 <https://cryptography.io/en/stable>`_ library. Use this, if you want to use Telegram Passport related functionality.
|
||||
* ``pip install python-telegram-bot[socks]`` installs `httpx[socks] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to work behind a Socks5 server.
|
||||
* ``pip install python-telegram-bot[http2]`` installs `httpx[http2] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to use HTTP/2.
|
||||
* ``pip install python-telegram-bot[rate-limiter]`` installs `aiolimiter~=1.1.0 <https://aiolimiter.readthedocs.io/en/stable/>`_. Use this, if you want to use ``telegram.ext.AIORateLimiter``.
|
||||
* ``pip install python-telegram-bot[webhooks]`` installs the `tornado~=6.2 <https://www.tornadoweb.org/en/stable/>`_ library. Use this, if you want to use ``telegram.ext.Updater.start_webhook``/``telegram.ext.Application.run_webhook``.
|
||||
* ``pip install python-telegram-bot[callback-data]`` installs the `cachetools~=5.3.1 <https://cachetools.readthedocs.io/en/latest/>`_ library. Use this, if you want to use `arbitrary callback_data <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_.
|
||||
* ``pip install python-telegram-bot[job-queue]`` installs the `APScheduler~=3.10.1 <https://apscheduler.readthedocs.io/en/3.x/>`_ library and enforces `pytz>=2018.6 <https://pypi.org/project/pytz/>`_, where ``pytz`` is a dependency of ``APScheduler``. Use this, if you want to use the ``telegram.ext.JobQueue``.
|
||||
* ``pip install "python-telegram-bot[passport]"`` installs the `cryptography>=39.0.1 <https://cryptography.io/en/stable>`_ library. Use this, if you want to use Telegram Passport related functionality.
|
||||
* ``pip install "python-telegram-bot[socks]"`` installs `httpx[socks] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to work behind a Socks5 server.
|
||||
* ``pip install "python-telegram-bot[http2]"`` installs `httpx[http2] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to use HTTP/2.
|
||||
* ``pip install "python-telegram-bot[rate-limiter]"`` installs `aiolimiter~=1.1.0 <https://aiolimiter.readthedocs.io/en/stable/>`_. Use this, if you want to use ``telegram.ext.AIORateLimiter``.
|
||||
* ``pip install "python-telegram-bot[webhooks]"`` installs the `tornado~=6.2 <https://www.tornadoweb.org/en/stable/>`_ library. Use this, if you want to use ``telegram.ext.Updater.start_webhook``/``telegram.ext.Application.run_webhook``.
|
||||
* ``pip install "python-telegram-bot[callback-data]"`` installs the `cachetools~=5.3.1 <https://cachetools.readthedocs.io/en/latest/>`_ library. Use this, if you want to use `arbitrary callback_data <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_.
|
||||
* ``pip install "python-telegram-bot[job-queue]"`` installs the `APScheduler~=3.10.1 <https://apscheduler.readthedocs.io/en/3.x/>`_ library and enforces `pytz>=2018.6 <https://pypi.org/project/pytz/>`_, where ``pytz`` is a dependency of ``APScheduler``. Use this, if you want to use the ``telegram.ext.JobQueue``.
|
||||
|
||||
To install multiple optional dependencies, separate them by commas, e.g. ``pip install python-telegram-bot[socks,webhooks]``.
|
||||
To install multiple optional dependencies, separate them by commas, e.g. ``pip install "python-telegram-bot[socks,webhooks]"``.
|
||||
|
||||
Additionally, two shortcuts are provided:
|
||||
|
||||
* ``pip install python-telegram-bot[all]`` installs all optional dependencies.
|
||||
* ``pip install python-telegram-bot[ext]`` installs all optional dependencies that are related to ``telegram.ext``, i.e. ``[rate-limiter, webhooks, callback-data, job-queue]``.
|
||||
* ``pip install "python-telegram-bot[all]"`` installs all optional dependencies.
|
||||
* ``pip install "python-telegram-bot[ext]"`` installs all optional dependencies that are related to ``telegram.ext``, i.e. ``[rate-limiter, webhooks, callback-data, job-queue]``.
|
||||
|
||||
Quick Start
|
||||
===========
|
||||
|
|
|
@ -149,13 +149,13 @@ Optional Dependencies
|
|||
|
||||
PTB can be installed with optional dependencies:
|
||||
|
||||
* ``pip install python-telegram-bot-raw[passport]`` installs the `cryptography>=39.0.1 <https://cryptography.io/en/stable>`_ library. Use this, if you want to use Telegram Passport related functionality.
|
||||
* ``pip install python-telegram-bot-raw[socks]`` installs `httpx[socks] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to work behind a Socks5 server.
|
||||
* ``pip install python-telegram-bot[http2]`` installs `httpx[http2] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to use HTTP/2.
|
||||
* ``pip install "python-telegram-bot-raw[passport]"`` installs the `cryptography>=39.0.1 <https://cryptography.io/en/stable>`_ library. Use this, if you want to use Telegram Passport related functionality.
|
||||
* ``pip install "python-telegram-bot-raw[socks]"`` installs `httpx[socks] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to work behind a Socks5 server.
|
||||
* ``pip install "python-telegram-bot-raw[http2]"`` installs `httpx[http2] <https://www.python-httpx.org/#dependencies>`_. Use this, if you want to use HTTP/2.
|
||||
|
||||
To install multiple optional dependencies, separate them by commas, e.g. ``pip install python-telegram-bot-raw[passport,socks]``.
|
||||
To install multiple optional dependencies, separate them by commas, e.g. ``pip install "python-telegram-bot-raw[passport,socks]"``.
|
||||
|
||||
Additionally, the shortcut ``pip install python-telegram-bot-raw[all]`` installs all optional dependencies.
|
||||
Additionally, the shortcut ``pip install "python-telegram-bot-raw[all]"`` installs all optional dependencies.
|
||||
|
||||
Quick Start
|
||||
===========
|
||||
|
|
|
@ -40,7 +40,7 @@ up a job to send a message to that user after 30 seconds. The user can
|
|||
also cancel the timer by sending ``/unset``. To learn more about the
|
||||
``JobQueue``, read `this wiki
|
||||
article <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-%E2%80%93-JobQueue>`__.
|
||||
Note: To use ``JobQueue``, you must install PTB via ``pip install python-telegram-bot[job-queue]``
|
||||
Note: To use ``JobQueue``, you must install PTB via ``pip install "python-telegram-bot[job-queue]"``
|
||||
|
||||
:any:`examples.conversationbot`
|
||||
-------------------------------
|
||||
|
@ -116,7 +116,7 @@ Don’t forget to enable and configure payments with
|
|||
`@BotFather <https://telegram.me/BotFather>`_. Check out this
|
||||
`guide <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Telegram-Passport>`__
|
||||
on Telegram passports in PTB.
|
||||
Note: To use Telegram Passport, you must install PTB via ``pip install python-telegram-bot[passport]``
|
||||
Note: To use Telegram Passport, you must install PTB via ``pip install "python-telegram-bot[passport]"``
|
||||
|
||||
:any:`examples.paymentbot`
|
||||
--------------------------
|
||||
|
@ -164,7 +164,7 @@ combination with ``telegram.ext.Application``.
|
|||
|
||||
This example showcases how PTBs “arbitrary callback data” feature can be
|
||||
used.
|
||||
Note: To use arbitrary callback data, you must install PTB via ``pip install python-telegram-bot[callback-data]``
|
||||
Note: To use arbitrary callback data, you must install PTB via ``pip install "python-telegram-bot[callback-data]"``
|
||||
|
||||
Pure API
|
||||
--------
|
||||
|
|
|
@ -9,7 +9,7 @@ https://github.com/python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callba
|
|||
|
||||
Note:
|
||||
To use arbitrary callback data, you must install PTB via
|
||||
`pip install python-telegram-bot[callback-data]`
|
||||
`pip install "python-telegram-bot[callback-data]"`
|
||||
"""
|
||||
import logging
|
||||
from typing import List, Tuple, cast
|
||||
|
|
|
@ -12,7 +12,7 @@ See https://github.com/python-telegram-bot/python-telegram-bot/wiki/Telegram-Pas
|
|||
|
||||
Note:
|
||||
To use Telegram Passport, you must install PTB via
|
||||
`pip install python-telegram-bot[passport]`
|
||||
`pip install "python-telegram-bot[passport]"`
|
||||
"""
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
|
|
@ -19,7 +19,7 @@ bot.
|
|||
|
||||
Note:
|
||||
To use the JobQueue, you must install PTB via
|
||||
`pip install python-telegram-bot[job-queue]`
|
||||
`pip install "python-telegram-bot[job-queue]"`
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
|
|
@ -287,7 +287,7 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]):
|
|||
if not CRYPTO_INSTALLED:
|
||||
raise RuntimeError(
|
||||
"To use Telegram Passports, PTB must be installed via `pip install "
|
||||
"python-telegram-bot[passport]`."
|
||||
'"python-telegram-bot[passport]"`.'
|
||||
)
|
||||
self._private_key = serialization.load_pem_private_key(
|
||||
private_key, password=private_key_password, backend=default_backend()
|
||||
|
|
|
@ -71,7 +71,7 @@ def decrypt(secret, hash, data): # skipcq: PYL-W0622
|
|||
if not CRYPTO_INSTALLED:
|
||||
raise RuntimeError(
|
||||
"To use Telegram Passports, PTB must be installed via `pip install "
|
||||
"python-telegram-bot[passport]`."
|
||||
'"python-telegram-bot[passport]"`.'
|
||||
)
|
||||
# Make a SHA512 hash of secret + update
|
||||
digest = Hash(SHA512(), backend=default_backend())
|
||||
|
@ -171,7 +171,7 @@ class EncryptedCredentials(TelegramObject):
|
|||
if not CRYPTO_INSTALLED:
|
||||
raise RuntimeError(
|
||||
"To use Telegram Passports, PTB must be installed via `pip install "
|
||||
"python-telegram-bot[passport]`."
|
||||
'"python-telegram-bot[passport]"`.'
|
||||
)
|
||||
# Try decrypting according to step 1 at
|
||||
# https://core.telegram.org/passport#decrypting-data
|
||||
|
|
|
@ -62,7 +62,7 @@ class AIORateLimiter(BaseRateLimiter[int]):
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
pip install python-telegram-bot[rate-limiter]
|
||||
pip install "python-telegram-bot[rate-limiter]"
|
||||
|
||||
The rate limiting is applied by combining two levels of throttling and :meth:`process_request`
|
||||
roughly boils down to::
|
||||
|
@ -136,7 +136,7 @@ class AIORateLimiter(BaseRateLimiter[int]):
|
|||
if not AIO_LIMITER_AVAILABLE:
|
||||
raise RuntimeError(
|
||||
"To use `AIORateLimiter`, PTB must be installed via `pip install "
|
||||
"python-telegram-bot[rate-limiter]`."
|
||||
'"python-telegram-bot[rate-limiter]"`.'
|
||||
)
|
||||
if overall_max_rate and overall_time_period:
|
||||
self._base_limiter: Optional[AsyncLimiter] = AsyncLimiter(
|
||||
|
|
|
@ -371,7 +371,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
|
|||
if self._job_queue is None:
|
||||
warn(
|
||||
"No `JobQueue` set up. To use `JobQueue`, you must install PTB via "
|
||||
"`pip install python-telegram-bot[job-queue]`.",
|
||||
'`pip install "python-telegram-bot[job-queue]"`.',
|
||||
stacklevel=2,
|
||||
)
|
||||
return self._job_queue
|
||||
|
@ -807,7 +807,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
pip install python-telegram-bot[webhooks]
|
||||
pip install "python-telegram-bot[webhooks]"
|
||||
|
||||
.. include:: inclusions/application_run_tip.rst
|
||||
|
||||
|
|
|
@ -582,7 +582,7 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
pip install python-telegram-bot[http2]
|
||||
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" <https://www.python-httpx.org/http2#enabling-http2>`_.
|
||||
|
@ -827,7 +827,7 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
pip install python-telegram-bot[callback-data]
|
||||
pip install "python-telegram-bot[callback-data]"
|
||||
|
||||
Examples:
|
||||
:any:`Arbitrary callback_data Bot <examples.arbitrarycallbackdatabot>`
|
||||
|
|
|
@ -404,7 +404,7 @@ class CallbackContext(Generic[BT, UD, CD, BD]):
|
|||
if self._application._job_queue is None: # pylint: disable=protected-access
|
||||
warn(
|
||||
"No `JobQueue` set up. To use `JobQueue`, you must install PTB via "
|
||||
"`pip install python-telegram-bot[job-queue]`.",
|
||||
'`pip install "python-telegram-bot[job-queue]"`.',
|
||||
stacklevel=2,
|
||||
)
|
||||
return self._application._job_queue # pylint: disable=protected-access
|
||||
|
|
|
@ -113,7 +113,7 @@ class CallbackDataCache:
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
pip install python-telegram-bot[callback-data]
|
||||
pip install "python-telegram-bot[callback-data]"
|
||||
|
||||
Examples:
|
||||
:any:`Arbitrary Callback Data Bot <examples.arbitrarycallbackdatabot>`
|
||||
|
@ -125,7 +125,7 @@ class CallbackDataCache:
|
|||
|
||||
.. versionchanged:: 20.0
|
||||
To use this class, PTB must be installed via
|
||||
``pip install python-telegram-bot[callback-data]``.
|
||||
``pip install "python-telegram-bot[callback-data]"``.
|
||||
|
||||
Args:
|
||||
bot (:class:`telegram.ext.ExtBot`): The bot this cache is for.
|
||||
|
@ -153,7 +153,7 @@ class CallbackDataCache:
|
|||
if not CACHE_TOOLS_AVAILABLE:
|
||||
raise RuntimeError(
|
||||
"To use `CallbackDataCache`, PTB must be installed via `pip install "
|
||||
"python-telegram-bot[callback-data]`."
|
||||
'"python-telegram-bot[callback-data]"`.'
|
||||
)
|
||||
|
||||
self.bot: ExtBot[Any] = bot
|
||||
|
|
|
@ -58,7 +58,7 @@ class JobQueue(Generic[CCT]):
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
pip install python-telegram-bot[job-queue]
|
||||
pip install "python-telegram-bot[job-queue]"
|
||||
|
||||
Examples:
|
||||
:any:`Timer Bot <examples.timerbot>`
|
||||
|
@ -68,7 +68,7 @@ class JobQueue(Generic[CCT]):
|
|||
|
||||
.. versionchanged:: 20.0
|
||||
To use this class, PTB must be installed via
|
||||
``pip install python-telegram-bot[job-queue]``.
|
||||
``pip install "python-telegram-bot[job-queue]"``.
|
||||
|
||||
Attributes:
|
||||
scheduler (:class:`apscheduler.schedulers.asyncio.AsyncIOScheduler`): The scheduler.
|
||||
|
@ -86,7 +86,7 @@ class JobQueue(Generic[CCT]):
|
|||
if not APS_AVAILABLE:
|
||||
raise RuntimeError(
|
||||
"To use `JobQueue`, PTB must be installed via `pip install "
|
||||
"python-telegram-bot[job-queue]`."
|
||||
'"python-telegram-bot[job-queue]"`.'
|
||||
)
|
||||
|
||||
self._application: "Optional[weakref.ReferenceType[Application]]" = None
|
||||
|
@ -678,7 +678,7 @@ class Job(Generic[CCT]):
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
pip install python-telegram-bot[job-queue]
|
||||
pip install "python-telegram-bot[job-queue]"
|
||||
|
||||
Note:
|
||||
All attributes and instance methods of :attr:`job` are also directly available as
|
||||
|
@ -696,7 +696,7 @@ class Job(Generic[CCT]):
|
|||
* 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]``.
|
||||
``pip install "python-telegram-bot[job-queue]"``.
|
||||
|
||||
Args:
|
||||
callback (:term:`coroutine function`): The callback function that should be executed by the
|
||||
|
@ -750,7 +750,7 @@ class Job(Generic[CCT]):
|
|||
if not APS_AVAILABLE:
|
||||
raise RuntimeError(
|
||||
"To use `Job`, PTB must be installed via `pip install "
|
||||
"python-telegram-bot[job-queue]`."
|
||||
'"python-telegram-bot[job-queue]"`.'
|
||||
)
|
||||
|
||||
self.callback: JobCallback[CCT] = callback
|
||||
|
|
|
@ -401,7 +401,7 @@ class Updater(AsyncContextManager["Updater"]):
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
pip install python-telegram-bot[webhooks]
|
||||
pip install "python-telegram-bot[webhooks]"
|
||||
|
||||
.. seealso:: :wiki:`Webhooks`
|
||||
|
||||
|
@ -464,7 +464,7 @@ class Updater(AsyncContextManager["Updater"]):
|
|||
if not WEBHOOKS_AVAILABLE:
|
||||
raise RuntimeError(
|
||||
"To use `start_webhook`, PTB must be installed via `pip install "
|
||||
"python-telegram-bot[webhooks]`."
|
||||
'"python-telegram-bot[webhooks]"`.'
|
||||
)
|
||||
|
||||
async with self.__lock:
|
||||
|
|
|
@ -56,7 +56,7 @@ class HTTPXRequest(BaseRequest):
|
|||
* The proxy URL can also be set via the environment variables ``HTTPS_PROXY`` or
|
||||
``ALL_PROXY``. See `the docs of httpx`_ for more info.
|
||||
* For Socks5 support, additional dependencies are required. Make sure to install
|
||||
PTB via :command:`pip install python-telegram-bot[socks]` in this case.
|
||||
PTB via :command:`pip install "python-telegram-bot[socks]"` in this case.
|
||||
* Socks5 proxies can not be set via environment variables.
|
||||
|
||||
.. _the docs of httpx: https://www.python-httpx.org/environment_variables/#proxies
|
||||
|
@ -139,11 +139,11 @@ class HTTPXRequest(BaseRequest):
|
|||
if "httpx[socks]" in str(exc):
|
||||
raise RuntimeError(
|
||||
"To use Socks5 proxies, PTB must be installed via `pip install "
|
||||
"python-telegram-bot[socks]`."
|
||||
'"python-telegram-bot[socks]"`.'
|
||||
) from exc
|
||||
raise RuntimeError(
|
||||
"To use HTTP/2, PTB must be installed via `pip install "
|
||||
"python-telegram-bot[http2]`."
|
||||
'"python-telegram-bot[http2]"`.'
|
||||
) from exc
|
||||
|
||||
@property
|
||||
|
|
|
@ -203,7 +203,7 @@ class TestApplication:
|
|||
def test_job_queue(self, one_time_bot, app, recwarn):
|
||||
expected_warning = (
|
||||
"No `JobQueue` set up. To use `JobQueue`, you must install PTB via "
|
||||
"`pip install python-telegram-bot[job-queue]`."
|
||||
'`pip install "python-telegram-bot[job-queue]"`.'
|
||||
)
|
||||
assert app.job_queue is app._job_queue
|
||||
application = ApplicationBuilder().bot(one_time_bot).job_queue(None).build()
|
||||
|
|
|
@ -63,7 +63,7 @@ class TestCallbackContext:
|
|||
def test_job_queue(self, bot, app, recwarn):
|
||||
expected_warning = (
|
||||
"No `JobQueue` set up. To use `JobQueue`, you must install PTB via "
|
||||
"`pip install python-telegram-bot[job-queue]`."
|
||||
'`pip install "python-telegram-bot[job-queue]"`.'
|
||||
)
|
||||
|
||||
callback_context = CallbackContext(app)
|
||||
|
|
Loading…
Reference in a new issue