ErisPulse-OneBot12Adapter 1.2.0__tar.gz → 4.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- erispulse_onebot12adapter-4.3.0/ErisPulse_OneBot12Adapter.egg-info/PKG-INFO +450 -0
- {erispulse_onebot12adapter-1.2.0 → erispulse_onebot12adapter-4.3.0}/ErisPulse_OneBot12Adapter.egg-info/SOURCES.txt +2 -1
- erispulse_onebot12adapter-4.3.0/OneBot12Adapter/Core.py +731 -0
- erispulse_onebot12adapter-4.3.0/OneBot12Adapter/__init__.py +3 -0
- erispulse_onebot12adapter-4.3.0/OneBot12Adapter/i18n.py +119 -0
- erispulse_onebot12adapter-4.3.0/PKG-INFO +450 -0
- erispulse_onebot12adapter-4.3.0/README.md +416 -0
- {erispulse_onebot12adapter-1.2.0 → erispulse_onebot12adapter-4.3.0}/pyproject.toml +6 -2
- erispulse_onebot12adapter-1.2.0/ErisPulse_OneBot12Adapter.egg-info/PKG-INFO +0 -546
- erispulse_onebot12adapter-1.2.0/OneBot12Adapter/Core.py +0 -866
- erispulse_onebot12adapter-1.2.0/OneBot12Adapter/__init__.py +0 -3
- erispulse_onebot12adapter-1.2.0/PKG-INFO +0 -546
- erispulse_onebot12adapter-1.2.0/README.md +0 -512
- {erispulse_onebot12adapter-1.2.0 → erispulse_onebot12adapter-4.3.0}/ErisPulse_OneBot12Adapter.egg-info/dependency_links.txt +0 -0
- {erispulse_onebot12adapter-1.2.0 → erispulse_onebot12adapter-4.3.0}/ErisPulse_OneBot12Adapter.egg-info/entry_points.txt +0 -0
- {erispulse_onebot12adapter-1.2.0 → erispulse_onebot12adapter-4.3.0}/ErisPulse_OneBot12Adapter.egg-info/top_level.txt +0 -0
- {erispulse_onebot12adapter-1.2.0 → erispulse_onebot12adapter-4.3.0}/LICENSE +0 -0
- {erispulse_onebot12adapter-1.2.0 → erispulse_onebot12adapter-4.3.0}/setup.cfg +0 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ErisPulse-OneBot12Adapter
|
|
3
|
+
Version: 4.3.0
|
|
4
|
+
Summary: ErisPulse的OneBotV12协议适配模块,基线协议适配器
|
|
5
|
+
Author-email: wsu2059q <wsu2059@qq.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 WSu2059
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: homepage, https://github.com/ErisPulse/ErisPulse-OneBot12Adapter
|
|
29
|
+
Keywords: erispulse,erispulse-adapter
|
|
30
|
+
Requires-Python: >=3.10
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
<div align="center">
|
|
36
|
+
|
|
37
|
+
<img src=".github/assets/ErisPulseLogo.png" width="180" alt="ErisPulse OneBot12Adapter" />
|
|
38
|
+
|
|
39
|
+
# ErisPulse OneBot12Adapter
|
|
40
|
+
|
|
41
|
+
**OneBot v12 baseline protocol adapter — multi-account, Server/Client dual mode.**
|
|
42
|
+
|
|
43
|
+
A OneBot V12 baseline protocol adapter for the ErisPulse framework. It transparently passes through standard-format events, runs multiple accounts simultaneously, and supports both Server (passive) and Client (active) WebSocket modes.
|
|
44
|
+
|
|
45
|
+
<p>
|
|
46
|
+
<a href="https://pypi.org/project/ErisPulse-OneBot12Adapter/"><img src="https://img.shields.io/pypi/v/ErisPulse-OneBot12Adapter?style=for-the-badge&logo=pypi&logoColor=white" alt="PyPI"></a>
|
|
47
|
+
<a href="https://pypi.org/project/ErisPulse-OneBot12Adapter/"><img src="https://img.shields.io/badge/Python-3.10+-FFD43B?style=for-the-badge&logo=python&logoColor=blue" alt="Python"></a>
|
|
48
|
+
<a href="./LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue?style=for-the-badge" alt="License"></a>
|
|
49
|
+
<a href="https://github.com/ErisPulse/ErisPulse-OneBot12Adapter"><img src="https://img.shields.io/github/stars/ErisPulse/ErisPulse-OneBot12Adapter?style=for-the-badge&logo=github&color=brightgreen" alt="Stars"></a>
|
|
50
|
+
<a href="https://pepy.tech/project/ErisPulse-OneBot12Adapter"><img src="https://img.shields.io/pepy/dt/ErisPulse-OneBot12Adapter?style=for-the-badge&color=blue" alt="Downloads"></a>
|
|
51
|
+
<a href="https://github.com/ErisPulse/ErisPulse"><img src="https://img.shields.io/badge/Powered_by-ErisPulse-FF6B9D?style=for-the-badge&logo=bookstack&logoColor=white" alt="ErisPulse"></a>
|
|
52
|
+
</p>
|
|
53
|
+
|
|
54
|
+
[English](#english) | [简体中文](#中文)
|
|
55
|
+
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
<a id="english"></a>
|
|
61
|
+
|
|
62
|
+
## English
|
|
63
|
+
|
|
64
|
+
A OneBot V12 baseline protocol adapter for the [ErisPulse](https://github.com/ErisPulse/ErisPulse/) framework, supporting multi-account and Server/Client dual mode operation.
|
|
65
|
+
|
|
66
|
+
### Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
epsdk install OneBot12Adapter
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Configuration
|
|
73
|
+
|
|
74
|
+
Add to `config/config.toml`:
|
|
75
|
+
|
|
76
|
+
```toml
|
|
77
|
+
[OneBotv12_Adapter.accounts.main]
|
|
78
|
+
bot_id = "Bot ID"
|
|
79
|
+
mode = "server"
|
|
80
|
+
server_path = "/onebot12"
|
|
81
|
+
server_token = ""
|
|
82
|
+
enabled = true
|
|
83
|
+
|
|
84
|
+
# Client mode example
|
|
85
|
+
[OneBotv12_Adapter.accounts.backup]
|
|
86
|
+
bot_id = "Another Bot ID"
|
|
87
|
+
mode = "client"
|
|
88
|
+
client_url = "ws://127.0.0.1:3002"
|
|
89
|
+
client_token = ""
|
|
90
|
+
enabled = true
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
#### Configuration Fields
|
|
94
|
+
|
|
95
|
+
| Field | Type | Required | Description |
|
|
96
|
+
|-------|------|----------|-------------|
|
|
97
|
+
| `bot_id` | string | Yes | Bot ID, used for SDK routing |
|
|
98
|
+
| `mode` | string | No | Run mode: `server` (passive) or `client` (active), default `server` |
|
|
99
|
+
| `server_path` | string | No | Server mode WS path, default `/onebot12` |
|
|
100
|
+
| `server_token` | string | No | Server mode authentication Token |
|
|
101
|
+
| `client_url` | string | No | Client mode WS address, default `ws://127.0.0.1:3001` |
|
|
102
|
+
| `client_token` | string | No | Client mode authentication Token |
|
|
103
|
+
| `enabled` | bool | No | Whether to enable (default true) |
|
|
104
|
+
| `platform` | string | No | Platform identifier, default `onebot12` |
|
|
105
|
+
| `implementation` | string | No | Implementation identifier (e.g., `go-cqhttp`) |
|
|
106
|
+
|
|
107
|
+
### Quick Start
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from ErisPulse import sdk
|
|
111
|
+
from ErisPulse.Core.Event import command, message
|
|
112
|
+
|
|
113
|
+
@command("hello")
|
|
114
|
+
async def hello_handler(event):
|
|
115
|
+
await event.reply("Hello from OneBot12!")
|
|
116
|
+
|
|
117
|
+
async def main():
|
|
118
|
+
await sdk.run(keep_running=True)
|
|
119
|
+
|
|
120
|
+
if __name__ == "__main__":
|
|
121
|
+
import asyncio
|
|
122
|
+
asyncio.run(main())
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Sending Messages
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
onebot12 = sdk.adapter.get("onebot12")
|
|
129
|
+
|
|
130
|
+
# Text messages
|
|
131
|
+
await onebot12.Send.To("user", "123456").Text("Hello!")
|
|
132
|
+
await onebot12.Send.To("group", "789012").Text("Group message")
|
|
133
|
+
|
|
134
|
+
# Media messages
|
|
135
|
+
await onebot12.Send.To("user", "123456").Image("file_id_or_url")
|
|
136
|
+
await onebot12.Send.To("user", "123456").Video("file_id_or_url")
|
|
137
|
+
await onebot12.Send.To("user", "123456").Audio("file_id_or_url")
|
|
138
|
+
|
|
139
|
+
# Send bytes
|
|
140
|
+
with open("image.png", "rb") as f:
|
|
141
|
+
await onebot12.Send.To("user", "123456").Image(f.read())
|
|
142
|
+
|
|
143
|
+
# Location
|
|
144
|
+
await onebot12.Send.To("group", "789012").Location(39.9042, 116.4074, title="Beijing")
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### Chain Modifiers
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
# @user
|
|
151
|
+
await onebot12.Send.To("group", "789012").At("123456").Text("Hello!")
|
|
152
|
+
|
|
153
|
+
# @everyone
|
|
154
|
+
await onebot12.Send.To("group", "789012").AtAll().Text("Announcement!")
|
|
155
|
+
|
|
156
|
+
# Reply to message
|
|
157
|
+
await onebot12.Send.To("group", "789012").Reply("msg_id").Text("Reply content")
|
|
158
|
+
|
|
159
|
+
# Combined usage
|
|
160
|
+
await onebot12.Send.To("group", "789012").Reply("msg_id").At("123456").Text("Reply and @mention")
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### Sending via a Specific Account
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
# Use Using to specify the account
|
|
167
|
+
await onebot12.Send.Using("backup").To("user", "123456").Text("From backup account")
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
#### Message Operations
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
# Recall
|
|
174
|
+
await onebot12.Send.To("group", "789012").Recall("message_id")
|
|
175
|
+
|
|
176
|
+
# Edit
|
|
177
|
+
await onebot12.Send.To("group", "789012").Edit("message_id", "New content")
|
|
178
|
+
|
|
179
|
+
# Raw OB12 message segments
|
|
180
|
+
await onebot12.Send.To("group", "789012").Raw_ob12([
|
|
181
|
+
{"type": "text", "data": {"text": "Hello"}},
|
|
182
|
+
{"type": "image", "data": {"file_id": "xxx"}}
|
|
183
|
+
])
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Run Modes
|
|
187
|
+
|
|
188
|
+
#### Server Mode (default)
|
|
189
|
+
|
|
190
|
+
Starts a WS server waiting for OneBot12 implementation clients to connect. Suitable for scenarios where multiple clients connect to the same server.
|
|
191
|
+
|
|
192
|
+
#### Client Mode
|
|
193
|
+
|
|
194
|
+
Actively connects to a OneBot12 implementation. Supports automatic reconnection (30-second interval).
|
|
195
|
+
|
|
196
|
+
### Event Handling
|
|
197
|
+
|
|
198
|
+
The OneBot12 adapter passes through standard-format events directly, with no conversion needed. Use the ErisPulse standard event handlers:
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
from ErisPulse.Core.Event import message, notice, request, meta
|
|
202
|
+
|
|
203
|
+
@message.on_message()
|
|
204
|
+
async def handle_message(event):
|
|
205
|
+
text = event.get_text()
|
|
206
|
+
user_id = event.get_user_id()
|
|
207
|
+
group_id = event.get_group_id()
|
|
208
|
+
await event.reply(f"Received: {text}")
|
|
209
|
+
|
|
210
|
+
@notice.on_group_increase()
|
|
211
|
+
async def handle_member_increase(event):
|
|
212
|
+
group_id = event.get_group_id()
|
|
213
|
+
user_id = event.get_user_id()
|
|
214
|
+
await event.reply(f"Welcome {user_id} to the group!")
|
|
215
|
+
|
|
216
|
+
@request.on_friend_request()
|
|
217
|
+
async def handle_friend_request(event):
|
|
218
|
+
user_id = event.get_user_id()
|
|
219
|
+
comment = event.get_comment()
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
#### Event Extension Fields
|
|
223
|
+
|
|
224
|
+
All events automatically have a `onebot12_raw_type` field added to preserve the original event type.
|
|
225
|
+
|
|
226
|
+
### API Calls
|
|
227
|
+
|
|
228
|
+
```python
|
|
229
|
+
# Direct API call
|
|
230
|
+
resp = await onebot12.call_api(
|
|
231
|
+
"get_user_info",
|
|
232
|
+
_account_id="main",
|
|
233
|
+
user_id="123456"
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
# Get self info
|
|
237
|
+
info = await onebot12.call_api("get_self_info", _account_id="main")
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
#### Response Format
|
|
241
|
+
|
|
242
|
+
```python
|
|
243
|
+
# Success
|
|
244
|
+
{"status": "ok", "retcode": 0, "data": {...}, "message_id": "xxx", "message": ""}
|
|
245
|
+
|
|
246
|
+
# Failure
|
|
247
|
+
{"status": "failed", "retcode": 10003, "data": None, "message_id": "", "message": "Error description"}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Reference Links
|
|
251
|
+
|
|
252
|
+
- [ErisPulse main repository](https://github.com/ErisPulse/ErisPulse/)
|
|
253
|
+
- [OneBot V12 protocol documentation](https://12.onebot.dev/)
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
<a id="中文"></a>
|
|
258
|
+
|
|
259
|
+
## 中文
|
|
260
|
+
|
|
261
|
+
基于 [ErisPulse](https://github.com/ErisPulse/ErisPulse/) 框架的 OneBot V12 基线协议适配器,支持多账号、Server/Client 双模式运行。
|
|
262
|
+
|
|
263
|
+
## 安装
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
epsdk install OneBot12Adapter
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## 配置
|
|
270
|
+
|
|
271
|
+
在 `config/config.toml` 中添加:
|
|
272
|
+
|
|
273
|
+
```toml
|
|
274
|
+
[OneBotv12_Adapter.accounts.main]
|
|
275
|
+
bot_id = "机器人ID"
|
|
276
|
+
mode = "server"
|
|
277
|
+
server_path = "/onebot12"
|
|
278
|
+
server_token = ""
|
|
279
|
+
enabled = true
|
|
280
|
+
|
|
281
|
+
# Client 模式示例
|
|
282
|
+
[OneBotv12_Adapter.accounts.backup]
|
|
283
|
+
bot_id = "另一个机器人ID"
|
|
284
|
+
mode = "client"
|
|
285
|
+
client_url = "ws://127.0.0.1:3002"
|
|
286
|
+
client_token = ""
|
|
287
|
+
enabled = true
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### 配置字段
|
|
291
|
+
|
|
292
|
+
| 字段 | 类型 | 必填 | 说明 |
|
|
293
|
+
|------|------|------|------|
|
|
294
|
+
| `bot_id` | string | 是 | 机器人ID,用于SDK路由 |
|
|
295
|
+
| `mode` | string | 否 | 运行模式:`server`(被动)或 `client`(主动),默认 `server` |
|
|
296
|
+
| `server_path` | string | 否 | Server 模式 WS 路径,默认 `/onebot12` |
|
|
297
|
+
| `server_token` | string | 否 | Server 模式认证 Token |
|
|
298
|
+
| `client_url` | string | 否 | Client 模式 WS 地址,默认 `ws://127.0.0.1:3001` |
|
|
299
|
+
| `client_token` | string | 否 | Client 模式认证 Token |
|
|
300
|
+
| `enabled` | bool | 否 | 是否启用(默认 true) |
|
|
301
|
+
| `platform` | string | 否 | 平台标识,默认 `onebot12` |
|
|
302
|
+
| `implementation` | string | 否 | 实现标识(如 `go-cqhttp`) |
|
|
303
|
+
|
|
304
|
+
## 快速开始
|
|
305
|
+
|
|
306
|
+
```python
|
|
307
|
+
from ErisPulse import sdk
|
|
308
|
+
from ErisPulse.Core.Event import command, message
|
|
309
|
+
|
|
310
|
+
@command("hello")
|
|
311
|
+
async def hello_handler(event):
|
|
312
|
+
await event.reply("Hello from OneBot12!")
|
|
313
|
+
|
|
314
|
+
async def main():
|
|
315
|
+
await sdk.run(keep_running=True)
|
|
316
|
+
|
|
317
|
+
if __name__ == "__main__":
|
|
318
|
+
import asyncio
|
|
319
|
+
asyncio.run(main())
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## 消息发送
|
|
323
|
+
|
|
324
|
+
```python
|
|
325
|
+
onebot12 = sdk.adapter.get("onebot12")
|
|
326
|
+
|
|
327
|
+
# 文本消息
|
|
328
|
+
await onebot12.Send.To("user", "123456").Text("Hello!")
|
|
329
|
+
await onebot12.Send.To("group", "789012").Text("群消息")
|
|
330
|
+
|
|
331
|
+
# 媒体消息
|
|
332
|
+
await onebot12.Send.To("user", "123456").Image("file_id_or_url")
|
|
333
|
+
await onebot12.Send.To("user", "123456").Video("file_id_or_url")
|
|
334
|
+
await onebot12.Send.To("user", "123456").Audio("file_id_or_url")
|
|
335
|
+
|
|
336
|
+
# 发送 bytes
|
|
337
|
+
with open("image.png", "rb") as f:
|
|
338
|
+
await onebot12.Send.To("user", "123456").Image(f.read())
|
|
339
|
+
|
|
340
|
+
# 位置
|
|
341
|
+
await onebot12.Send.To("group", "789012").Location(39.9042, 116.4074, title="北京")
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### 链式修饰
|
|
345
|
+
|
|
346
|
+
```python
|
|
347
|
+
# @用户
|
|
348
|
+
await onebot12.Send.To("group", "789012").At("123456").Text("你好!")
|
|
349
|
+
|
|
350
|
+
# @全体
|
|
351
|
+
await onebot12.Send.To("group", "789012").AtAll().Text("通知!")
|
|
352
|
+
|
|
353
|
+
# 回复消息
|
|
354
|
+
await onebot12.Send.To("group", "789012").Reply("msg_id").Text("回复内容")
|
|
355
|
+
|
|
356
|
+
# 组合使用
|
|
357
|
+
await onebot12.Send.To("group", "789012").Reply("msg_id").At("123456").Text("回复并@")
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### 指定账户发送
|
|
361
|
+
|
|
362
|
+
```python
|
|
363
|
+
# 使用 Using 指定账户
|
|
364
|
+
await onebot12.Send.Using("backup").To("user", "123456").Text("来自备用账户")
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### 消息操作
|
|
368
|
+
|
|
369
|
+
```python
|
|
370
|
+
# 撤回
|
|
371
|
+
await onebot12.Send.To("group", "789012").Recall("message_id")
|
|
372
|
+
|
|
373
|
+
# 编辑
|
|
374
|
+
await onebot12.Send.To("group", "789012").Edit("message_id", "新内容")
|
|
375
|
+
|
|
376
|
+
# 原始 OB12 消息段
|
|
377
|
+
await onebot12.Send.To("group", "789012").Raw_ob12([
|
|
378
|
+
{"type": "text", "data": {"text": "你好"}},
|
|
379
|
+
{"type": "image", "data": {"file_id": "xxx"}}
|
|
380
|
+
])
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
## 运行模式
|
|
384
|
+
|
|
385
|
+
### Server 模式(默认)
|
|
386
|
+
|
|
387
|
+
启动 WS 服务器等待 OneBot12 实现端连接。适用于多客户端连接同一服务端的场景。
|
|
388
|
+
|
|
389
|
+
### Client 模式
|
|
390
|
+
|
|
391
|
+
主动连接 OneBot12 实现端。支持自动重连(间隔 30 秒)。
|
|
392
|
+
|
|
393
|
+
## 事件处理
|
|
394
|
+
|
|
395
|
+
OneBot12 适配器直接 pass-through 标准格式事件,无需转换。使用 ErisPulse 标准事件处理器:
|
|
396
|
+
|
|
397
|
+
```python
|
|
398
|
+
from ErisPulse.Core.Event import message, notice, request, meta
|
|
399
|
+
|
|
400
|
+
@message.on_message()
|
|
401
|
+
async def handle_message(event):
|
|
402
|
+
text = event.get_text()
|
|
403
|
+
user_id = event.get_user_id()
|
|
404
|
+
group_id = event.get_group_id()
|
|
405
|
+
await event.reply(f"收到: {text}")
|
|
406
|
+
|
|
407
|
+
@notice.on_group_increase()
|
|
408
|
+
async def handle_member_increase(event):
|
|
409
|
+
group_id = event.get_group_id()
|
|
410
|
+
user_id = event.get_user_id()
|
|
411
|
+
await event.reply(f"欢迎 {user_id} 加入群!")
|
|
412
|
+
|
|
413
|
+
@request.on_friend_request()
|
|
414
|
+
async def handle_friend_request(event):
|
|
415
|
+
user_id = event.get_user_id()
|
|
416
|
+
comment = event.get_comment()
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### 事件扩展字段
|
|
420
|
+
|
|
421
|
+
所有事件自动添加 `onebot12_raw_type` 字段保留原始事件类型。
|
|
422
|
+
|
|
423
|
+
## API 调用
|
|
424
|
+
|
|
425
|
+
```python
|
|
426
|
+
# 直接 API 调用
|
|
427
|
+
resp = await onebot12.call_api(
|
|
428
|
+
"get_user_info",
|
|
429
|
+
_account_id="main",
|
|
430
|
+
user_id="123456"
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
# 获取自身信息
|
|
434
|
+
info = await onebot12.call_api("get_self_info", _account_id="main")
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### 响应格式
|
|
438
|
+
|
|
439
|
+
```python
|
|
440
|
+
# 成功
|
|
441
|
+
{"status": "ok", "retcode": 0, "data": {...}, "message_id": "xxx", "message": ""}
|
|
442
|
+
|
|
443
|
+
# 失败
|
|
444
|
+
{"status": "failed", "retcode": 10003, "data": None, "message_id": "", "message": "错误描述"}
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
## 参考链接
|
|
448
|
+
|
|
449
|
+
- [ErisPulse 主库](https://github.com/ErisPulse/ErisPulse/)
|
|
450
|
+
- [OneBot V12 协议文档](https://12.onebot.dev/)
|
|
@@ -7,4 +7,5 @@ ErisPulse_OneBot12Adapter.egg-info/dependency_links.txt
|
|
|
7
7
|
ErisPulse_OneBot12Adapter.egg-info/entry_points.txt
|
|
8
8
|
ErisPulse_OneBot12Adapter.egg-info/top_level.txt
|
|
9
9
|
OneBot12Adapter/Core.py
|
|
10
|
-
OneBot12Adapter/__init__.py
|
|
10
|
+
OneBot12Adapter/__init__.py
|
|
11
|
+
OneBot12Adapter/i18n.py
|