diff --git a/aiogram/client/telegram.py b/aiogram/client/telegram.py index dfededb8..b8e89a89 100644 --- a/aiogram/client/telegram.py +++ b/aiogram/client/telegram.py @@ -33,6 +33,13 @@ class TelegramAPIServer: @classmethod def from_base(cls, base: str, is_local: bool = False) -> "TelegramAPIServer": + """ + Use this method to auto-generate TelegramAPIServer instance from base URL + + :param base: Base URL + :param is_local: Mark this server is in `local mode `_. + :return: instance of :class:`TelegramAPIServer` + """ base = base.rstrip("/") return cls( base=f"{base}/bot{{token}}/{{method}}", diff --git a/docs2/api/session/aiohttp.rst b/docs2/api/session/aiohttp.rst index 54b4d72d..3a595d1b 100644 --- a/docs2/api/session/aiohttp.rst +++ b/docs2/api/session/aiohttp.rst @@ -6,6 +6,8 @@ AiohttpSession represents a wrapper-class around `ClientSession` from `aiohttp < Currently `AiohttpSession` is a default session used in `aiogram.Bot` +.. autoclass:: aiogram.client.session.aiohttp.AiohttpSession + Usage example ============= diff --git a/docs2/api/session/custom_server.rst b/docs2/api/session/custom_server.rst new file mode 100644 index 00000000..fe2b86f4 --- /dev/null +++ b/docs2/api/session/custom_server.rst @@ -0,0 +1,13 @@ +Use Custom API server +===================== + +.. autoclass:: aiogram.client.telegram.TelegramAPIServer + :members: + +For example, if you want to use self-hosted API server: + +.. code-block:: python3 + + session = AiohttpSession() + session.api = TelegramAPIServer.from_base('http://localhost:8082') + bot = Bot(..., session=session) diff --git a/docs2/api/session/index.rst b/docs2/api/session/index.rst index c9ff9cd6..dff24e7a 100644 --- a/docs2/api/session/index.rst +++ b/docs2/api/session/index.rst @@ -2,6 +2,9 @@ Client session ############## +Client sessions is used for interacting with API server. + .. toctree:: + custom_server base aiohttp