Base#

Abstract session for all client sessions

class aiogram.client.session.base.BaseSession(api: aiogram.client.telegram.TelegramAPIServer = TelegramAPIServer(base='https://api.telegram.org/bot{token}/{method}', file='https://api.telegram.org/file/bot{token}/{path}', is_local=False, wrap_local_file=<aiogram.client.telegram.BareFilesPathWrapper object>), json_loads: typing.Callable[[...], typing.Any] = <function loads>, json_dumps: typing.Callable[[...], str] = <function dumps>, timeout: float = 60.0)[source]#
check_response(method: aiogram.methods.base.TelegramMethod[aiogram.methods.base.TelegramType], status_code: int, content: str) aiogram.methods.base.Response[source]#

Check response status

clean_json(value: Any) Any[source]#

Clean data before send

abstract async close() None[source]#

Close client session

abstract async make_request(bot: Bot, method: TelegramMethod[TelegramType], timeout: Optional[int] = sentinel.UNSET) TelegramType[source]#

Make request to Telegram Bot API

Parameters
  • bot – Bot instance

  • method – Method instance

  • timeout – Request timeout

Returns

Raises

TelegramApiError

prepare_value(value: Any) Union[str, int, bool][source]#

Prepare value before send

abstract async stream_content(url: str, timeout: int, chunk_size: int) AsyncGenerator[bytes, None][source]#

Stream reader