mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-27 08:11:38 +00:00
@ -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")
|
||||
```
|
||||
|
||||
|
@ -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)`
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user