Skip to content

Commit 70c400d

Browse files
authored
🔀 Merge pull request #43
Pre Release 2.0.0a4
2 parents 93aa179 + 2a5cfe7 commit 70c400d

29 files changed

+1079
-157
lines changed

archive/2.0.0a3/api/drivers/README.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

archive/2.0.0a3/api/drivers/fastapi.md

Lines changed: 0 additions & 16 deletions
This file was deleted.
File renamed without changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
* [nonebot.config](config.html)
1111

1212

13+
* [nonebot.plugin](plugin.html)
14+
15+
1316
* [nonebot.matcher](matcher.html)
1417

1518

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,11 @@ CQHTTP 协议 Event 适配。继承属性参考 [BaseEvent](./#class-baseevent)
405405

406406
基类:[`nonebot.adapters.BaseMessageSegment`](#None)
407407

408+
CQHTTP 协议 MessageSegment 适配。具体方法参考协议消息段类型或源码。
409+
408410

409411
## _class_ `Message`
410412

411413
基类:[`nonebot.adapters.BaseMessage`](#None)
414+
415+
CQHTTP 协议 Message 适配。
File renamed without changes.
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
---
2+
contentSidebar: true
3+
sidebarDepth: 0
4+
---
5+
6+
# NoneBot.drivers 模块
7+
8+
## 后端驱动适配基类
9+
10+
各驱动请继承以下基类
11+
12+
13+
## _class_ `BaseDriver`
14+
15+
基类:`abc.ABC`
16+
17+
Driver 基类。将后端框架封装,以满足适配器使用。
18+
19+
20+
### `_adapters`
21+
22+
23+
* **类型**
24+
25+
`Dict[str, Type[Bot]]`
26+
27+
28+
29+
* **说明**
30+
31+
已注册的适配器列表
32+
33+
34+
35+
### _abstract_ `__init__(env, config)`
36+
37+
38+
* **参数**
39+
40+
41+
* `env: Env`: 包含环境信息的 Env 对象
42+
43+
44+
* `config: Config`: 包含配置信息的 Config 对象
45+
46+
47+
48+
### `env`
49+
50+
51+
* **类型**
52+
53+
`str`
54+
55+
56+
57+
* **说明**
58+
59+
环境名称
60+
61+
62+
63+
### `config`
64+
65+
66+
* **类型**
67+
68+
`Config`
69+
70+
71+
72+
* **说明**
73+
74+
配置对象
75+
76+
77+
78+
### `_clients`
79+
80+
81+
* **类型**
82+
83+
`Dict[str, Bot]`
84+
85+
86+
87+
* **说明**
88+
89+
已连接的 Bot
90+
91+
92+
93+
### _classmethod_ `register_adapter(name, adapter)`
94+
95+
96+
* **说明**
97+
98+
注册一个协议适配器
99+
100+
101+
102+
* **参数**
103+
104+
105+
* `name: str`: 适配器名称,用于在连接时进行识别
106+
107+
108+
* `adapter: Type[Bot]`: 适配器 Class
109+
110+
111+
112+
### _abstract property_ `type`
113+
114+
驱动类型名称
115+
116+
117+
### _abstract property_ `server_app`
118+
119+
驱动 APP 对象
120+
121+
122+
### _abstract property_ `asgi`
123+
124+
驱动 ASGI 对象
125+
126+
127+
### _abstract property_ `logger`
128+
129+
驱动专属 logger 日志记录器
130+
131+
132+
### _property_ `bots`
133+
134+
135+
* **类型**
136+
137+
`Dict[str, Bot]`
138+
139+
140+
141+
* **说明**
142+
143+
获取当前所有已连接的 Bot
144+
145+
146+
147+
### _abstract_ `on_startup(func)`
148+
149+
注册一个在驱动启动时运行的函数
150+
151+
152+
### _abstract_ `on_shutdown(func)`
153+
154+
注册一个在驱动停止时运行的函数
155+
156+
157+
### _abstract_ `run(host=None, port=None, *args, **kwargs)`
158+
159+
160+
* **说明**
161+
162+
启动驱动框架
163+
164+
165+
166+
* **参数**
167+
168+
169+
* `host: Optional[str]`: 驱动绑定 IP
170+
171+
172+
* `post: Optional[int]`: 驱动绑定端口
173+
174+
175+
* `*args`
176+
177+
178+
* `**kwargs`
179+
180+
181+
182+
### _abstract async_ `_handle_http()`
183+
184+
用于处理 HTTP 类型请求的函数
185+
186+
187+
### _abstract async_ `_handle_ws_reverse()`
188+
189+
用于处理 WebSocket 类型请求的函数
190+
191+
192+
## _class_ `BaseWebSocket`
193+
194+
基类:`object`
195+
196+
WebSocket 连接封装,统一接口方便外部调用。
197+
198+
199+
### _abstract_ `__init__(websocket)`
200+
201+
202+
* **参数**
203+
204+
205+
* `websocket: Any`: WebSocket 连接对象
206+
207+
208+
209+
### _property_ `websocket`
210+
211+
WebSocket 连接对象
212+
213+
214+
### _abstract property_ `closed`
215+
216+
217+
* **类型**
218+
219+
`bool`
220+
221+
222+
223+
* **说明**
224+
225+
连接是否已经关闭
226+
227+
228+
229+
### _abstract async_ `accept()`
230+
231+
接受 WebSocket 连接请求
232+
233+
234+
### _abstract async_ `close(code)`
235+
236+
关闭 WebSocket 连接请求
237+
238+
239+
### _abstract async_ `receive()`
240+
241+
接收一条 WebSocket 信息
242+
243+
244+
### _abstract async_ `send(data)`
245+
246+
发送一条 WebSocket 信息

0 commit comments

Comments
 (0)