iamai.adapter.utils module#
适配器实用工具。
这里定义了一些在编写适配器时常用的基类,适配器开发者可以直接继承自这里的类或者用作参考。
- class iamai.adapter.utils.HttpClientAdapter(bot: Bot)[source]#
Bases:
PollingAdapter
[EventT
,ConfigT
]HTTP 客户端适配器示例。
- session: ClientSession#
- class iamai.adapter.utils.HttpServerAdapter(bot: Bot)[source]#
Bases:
Adapter
[EventT
,ConfigT
]HTTP 服务端适配器示例。
- app: Application#
- get_url: str#
- host: str#
- port: int#
- post_url: str#
- runner: AppRunner#
- site: TCPSite#
- class iamai.adapter.utils.PollingAdapter(bot: Bot)[source]#
Bases:
Adapter
[EventT
,ConfigT
]轮询式适配器示例。
- create_task: bool = False#
- delay: float = 0.1#
- class iamai.adapter.utils.WebSocketAdapter(bot: Bot)[source]#
Bases:
Adapter
[EventT
,ConfigT
]WebSocket 适配器示例。
同时支持 WebSocket 客户端和服务端。
- adapter_type: Literal['ws', 'reverse-ws']#
- app: Application | None#
- async handle_reverse_ws_response(request: Request) WebSocketResponse [source]#
处理 aiohttp WebSocket 服务器的接收。
- host: str#
- port: int#
- reconnect_interval: int = 3#
- runner: AppRunner | None#
- session: ClientSession | None#
- site: TCPSite | None#
- url: str#
- websocket: WebSocketResponse | ClientWebSocketResponse | None = None#
- class iamai.adapter.utils.WebSocketClientAdapter(bot: Bot)[source]#
Bases:
Adapter
[EventT
,ConfigT
]WebSocket 客户端适配器示例。
- url: str#