You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AstrBot supports integrating platform adapters in plugin form, allowing you to connect platforms that AstrBot does not natively support — such as Lark, DingTalk, Bilibili private messages, or even Minecraft.
8
8
9
-
我们以一个平台 `FakePlatform`为例展开讲解。
9
+
We will use a platform called `FakePlatform`as an example.
First, add `fake_platform_adapter.py`and`fake_platform_event.py`to your plugin directory. The former handles the platform adapter implementation, while the latter defines the platform event.
12
12
13
-
## 平台适配器
13
+
## Platform Adapter
14
14
15
-
假设 FakePlatform 的客户端 SDK 是这样:
15
+
Assume FakePlatform's client SDK looks like this:
16
16
17
17
```py
18
18
import asyncio
19
19
20
20
classFakeClient():
21
-
'''模拟一个消息平台,这里 5 秒钟下发一个消息'''
21
+
'''Simulates a messaging platform that sends a message every 5 seconds'''
22
22
def__init__(self, token: str, username: str):
23
23
self.token = token
24
24
self.username = username
@@ -29,101 +29,102 @@ class FakeClient():
29
29
await asyncio.sleep(5)
30
30
awaitgetattr(self, 'on_message_received')({
31
31
'bot_id': '123',
32
-
'content': '新消息',
32
+
'content': 'new message',
33
33
'username': 'zhangsan',
34
34
'userid': '123',
35
35
'message_id': 'asdhoashd',
36
36
'group_id': 'group123',
37
37
})
38
38
39
39
asyncdefsend_text(self, to: str, message: str):
40
-
print('发了消息:', to, message)
40
+
print('Message sent:', to, message)
41
41
42
42
asyncdefsend_image(self, to: str, image_path: str):
43
-
print('发了消息:', to, image_path)
43
+
print('Image sent:', to, image_path)
44
44
```
45
45
46
-
我们创建 `fake_platform_adapter.py`:
46
+
Now create`fake_platform_adapter.py`:
47
47
48
48
```py
49
49
import asyncio
50
50
51
51
from astrbot.api.platform import Platform, AstrBotMessage, MessageMember, PlatformMetadata, MessageType
52
52
from astrbot.api.event import MessageChain
53
-
from astrbot.api.message_components import Plain, Image, Record #消息链中的组件,可以根据需要导入
54
-
from astrbot.core.platform.astr_message_eventimport MessageSesion
53
+
from astrbot.api.message_components import Plain, Image, Record #Message chain components, import as needed
54
+
from astrbot.core.platform.message_sessionimport MessageSesion
55
55
from astrbot.api.platform import register_platform_adapter
56
56
from astrbot import logger
57
57
from .client import FakeClient
58
58
from .fake_platform_event import FakePlatformEvent
Copy file name to clipboardExpand all lines: docs/en/dev/star/guides/simple.md
-16Lines changed: 0 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,19 +40,3 @@ Explanation:
40
40
41
41
All handler functions must be written within the plugin class. To keep content concise, in subsequent sections, we may omit the plugin class definition.
Open the [PPIO Cloud website](https://ppio.cn/user/register?invited_by=AIOONE) and register an account (accounts registered through this link will receive a ¥15 voucher).
8
8
9
-
进入 [模型 API 服务](https://ppio.cn/model-api/console),找到你想接入的模型。你可以通过筛选器选择不同厂商或者免费的模型。
9
+
Go to [Model API Service](https://ppio.cn/model-api/console) and find the model you want to use. You can filter by provider or select free models.
找到你想要接入的模型后,点击模型卡片,侧边会展开一个模型详情卡片,找到下方的 API 接入指南,如果您还没创建过 Key 可以点击创建。
13
+
Once you find the model, click its card to expand a detail panel on the right. Scroll down to the API integration guide — if you haven't created a key yet, click to create one.
Open the AstrBot dashboard → Service Providers page, click **Add Provider**, find and click `PPIO Cloud` (requires version >= 3.5.10; older versions are also supported, see below).
> 2.然后将`API Base URL`设置为`https://api.ppinfra.com/v3/openai`
27
-
> 3.然后将 API Key 和模型名称填入对话框表单,点击保存,即可完成创建。
24
+
> If you are using an older version of AstrBot (< 3.5.10), open the AstrBot dashboard → Service Providers page, click **Add Provider**, find `OpenAI`, and click to enter.
25
+
> 1.Set the ID to`ppio` (any name works)
26
+
> 2.Set`API Base URL`to`https://api.ppinfra.com/v3/openai`
27
+
> 3.Fill in the API Key and model name in the dialog form, then click **Save** to complete the setup.
28
28
29
+
## Usage
29
30
30
-
## 使用
31
+
Send the `/provider` command to the bot to switch to the PPIO Cloud provider you just added.
0 commit comments