💡 update source docstring #46 #49

This commit is contained in:
yanyongyu
2020-11-13 01:46:26 +08:00
parent 5c29abd724
commit 28e3177e60
10 changed files with 160 additions and 77 deletions

View File

@ -69,6 +69,45 @@ Websocket 连接对象
Adapter 类型
### _abstract async classmethod_ `check_permission(driver, connection_type, headers, body)`
* **说明**
检查连接请求是否合法的函数,如果合法则返回当前连接 `唯一标识符`,通常为机器人 ID如果不合法则抛出 `RequestDenied` 异常。
* **参数**
* `driver: Driver`: Driver 对象
* `connection_type: str`: 连接类型
* `headers: dict`: 请求头
* `body: Optional[dict]`: 请求数据WebSocket 连接该部分为空
* **返回**
* `str`: 连接唯一标识符
* **异常**
* `RequestDenied`: 请求非法
### _abstract async_ `handle_message(message)`
@ -108,7 +147,7 @@ Adapter 类型
```python
await bot.call_api("send_msg", data={"message": "hello world"})
await bot.call_api("send_msg", message="hello world"})
await bot.send_msg(message="hello world")
```

View File

@ -169,6 +169,15 @@ CQHTTP 协议 Bot 适配。继承属性参考 [BaseBot](./#class-basebot) 。
* 返回: `"cqhttp"`
### _async classmethod_ `check_permission(driver, connection_type, headers, body)`
* **说明**
CQHTTP (OneBot) 协议鉴权。参考 [鉴权](https://github.com/howmanybots/onebot/blob/master/v11/specs/communication/authorization.md)
### _async_ `handle_message(message)`

View File

@ -17,19 +17,6 @@ sidebarDepth: 0
FastAPI 驱动框架
### `__init__(env, config)`
* **参数**
* `env: Env`: 包含环境信息的 Env 对象
* `config: Config`: 包含配置信息的 Config 对象
### _property_ `type`
驱动名称: `fastapi`
@ -65,12 +52,12 @@ fastapi 使用的 logger
使用 `uvicorn` 启动 FastAPI
### _async_ `_handle_http(adapter, data=Body(Ellipsis), x_self_id=Header(None), x_signature=Header(None), auth=Depends(get_auth_bearer))`
### _async_ `_handle_http(adapter, request, data=Body(Ellipsis))`
用于处理 HTTP 类型请求的函数
### _async_ `_handle_ws_reverse(adapter, websocket, x_self_id=Header(None), auth=Depends(get_auth_bearer))`
### _async_ `_handle_ws_reverse(adapter, websocket)`
用于处理 WebSocket 类型请求的函数
@ -80,16 +67,6 @@ fastapi 使用的 logger
基类:[`nonebot.drivers.BaseWebSocket`](#None)
### `__init__(websocket)`
* **参数**
* `websocket: Any`: WebSocket 连接对象
### _property_ `closed`

View File

@ -117,6 +117,27 @@ sidebarDepth: 0
## _exception_ `RequestDenied`
基类:`Exception`
* **说明**
Bot 连接请求不合法。
* **参数**
* `status_code: int`: HTTP 状态码
* `reason: str`: 拒绝原因
## _exception_ `ApiNotAvailable`
基类:`Exception`
@ -153,4 +174,4 @@ sidebarDepth: 0
* **参数**
* `retcode`: 错误代码
* `retcode: Optional[int]`: 错误代码