mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Describe local servers
This commit is contained in:
parent
1a185928a2
commit
0719b27b6d
4 changed files with 25 additions and 0 deletions
|
|
@ -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 <https://core.telegram.org/bots/api#using-a-local-bot-api-server>`_.
|
||||
:return: instance of :class:`TelegramAPIServer`
|
||||
"""
|
||||
base = base.rstrip("/")
|
||||
return cls(
|
||||
base=f"{base}/bot{{token}}/{{method}}",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
=============
|
||||
|
||||
|
|
|
|||
13
docs2/api/session/custom_server.rst
Normal file
13
docs2/api/session/custom_server.rst
Normal file
|
|
@ -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)
|
||||
|
|
@ -2,6 +2,9 @@
|
|||
Client session
|
||||
##############
|
||||
|
||||
Client sessions is used for interacting with API server.
|
||||
|
||||
.. toctree::
|
||||
custom_server
|
||||
base
|
||||
aiohttp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue