Simple Robot v4.6.0 Help

消息元素

消息元素实现

所有的 Message.Element 特殊实现类型均定义在包 love.forte.simbot.component.qguild.message 中。

它们都继承了 love.forte.simbot.component.qguild.message.QGMessageElement

QGArk

对 API 模块中 Ark 消息的包装体,可用来发送 Ark 消息。

QGContentText
QGMarkdown
QGAttachmentMessage
QGEmbed

对 API 模块中 Embed 消息的包装体,可用来发送 Embed 消息。

QGReference

发送消息时,QQ频道的消息引用。与官方发送消息API中的 reference 对应。

QGReplyTo

发送消息时,指定一个需要回复的目标消息ID。

QGMedia

发送消息

在simbot中,使用组件的消息元素与使用其他消息元素别无二致, 通常使用 SendSupportReplySupport 的实现类中提供的 send(...)reply(..) API 发送消息。

前者多由 行为对象 中的一些类型实现(例如QGMemberQGTextChannel), 而后者则通常由与消息相关的事件实现(例如 QGAtMessageCreateEvent)。

此处以 QGTextChannel 为例, send 可以使用拼接后的消息链、字符串或单独的消息元素作为参数。

val channel: QGTextChannel = ... channel.send("消息内容") channel.send("消息内容".toText() + At("user id".ID))
QGTextChannel channel = ... var sendTask1 = channel.sendAsync("消息内容"); var sendTask2 = channel.sendAsync(Messages.of( Text.of("文本消息"), At.of(Identifies.of("user id")) ));
QGTextChannel channel = ...; channel.sendBlocking("消息内容"); channel.sendBlocking(Messages.of( Text.of("文本消息"), At.of(Identifies.of("user id")) ));
QGTextChannel channel = ...; channel.sendReserve("消息内容") .transform(SuspendReserves.mono()) .subscribe(receipt -> { ... }); channel.sendReserve(Messages.of( Text.of("文本消息"), At.of(Identifies.of("user id")) )) .transform(SuspendReserves.mono()) .subscribe(receipt -> { ... });
Last modified: 19 September 2024