Skip to content

Commit 79a5421

Browse files
committed
plugin dev
1 parent 1398dae commit 79a5421

File tree

4 files changed

+67
-2
lines changed

4 files changed

+67
-2
lines changed

dev/plugin.md

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,18 @@ class AstrBotMessage:
124124

125125
### 消息链
126126

127-
消息链描述一个消息的结构,是一个有序列表。
127+
`消息链`描述一个消息的结构,是一个有序列表,列表中每一个元素称为`消息段`
128+
129+
引用方式:
130+
131+
```py
132+
from astrbot.api.message_components import *
133+
```
128134

129135
```
130136
[Plain(text="Hello"), At(qq=123456), Image(file="https://example.com/image.jpg")]
131137
```
132-
qq
138+
133139
> qq 是对应消息平台上的用户 ID。
134140
135141
消息链的结构使用了 `nakuru-project`。它一共有如下种消息类型。常用的已经用注释标注。
@@ -483,6 +489,65 @@ yield event.make_result().message("文本消息")
483489
.file_image("path/to/image.jpg")
484490
```
485491

492+
### 发送群合并转发消息
493+
494+
> 当前适配情况:aiocqhttp
495+
496+
可以按照如下方式发送群合并转发消息。
497+
498+
```py
499+
@filter.command("test")
500+
async def test(self, event: AstrMessageEvent):
501+
from astrbot.api.message_components import Node, Plain, Image
502+
node = Node(
503+
uin=905617992,
504+
name="Soulter",
505+
content=[
506+
Plain("hi"),
507+
Image.fromFileSystem("test.jpg")
508+
]
509+
)
510+
yield event.chain_result([node])
511+
```
512+
513+
![发送群合并转发消息](../source/images/plugin/image-4.png)
514+
515+
516+
### 发送视频消息
517+
518+
> 当前适配情况:aiocqhttp
519+
520+
```python
521+
@filter.command("test")
522+
async def test(self, event: AstrMessageEvent):
523+
from astrbot.api.message_components import Video
524+
# fromFileSystem 需要用户的协议端和机器人端处于一个系统中。
525+
music = Video.fromFileSystem(
526+
path="test.mp4"
527+
)
528+
# 更通用
529+
music = Video.fromURL(
530+
url="https://example.com/video.mp4"
531+
)
532+
yield event.chain_result([music])
533+
```
534+
![发送视频消息](../source/images/plugin/db93a2bb-671c-4332-b8ba-9a91c35623c2.png)
535+
536+
## 发送 QQ 表情
537+
538+
> 当前适配情况:仅 aiocqhttp
539+
540+
QQ 表情 ID 参考:https://bot.q.qq.com/wiki/develop/api-v2/openapi/emoji/model.html#EmojiType
541+
542+
```python
543+
@filter.command("test")
544+
async def test(self, event: AstrMessageEvent):
545+
from astrbot.api.message_components import Face, Plain
546+
yield event.chain_result([Face(id=21), Plain("你好呀")])
547+
```
548+
549+
![发送 QQ 表情](../source/images/plugin/image-5.png)
550+
486551
### [aiocqhttp] 直接调用协议端 API
487552

488553
```py
83.2 KB
Loading

source/images/plugin/image-4.png

115 KB
Loading

source/images/plugin/image-5.png

34.8 KB
Loading

0 commit comments

Comments
 (0)