Simple Robot | QQ频道 v4.0.0-beta5 Help

消息

公告

站点迁移啦~!

为什么迁移?

作为由我们官方维护的组件库,分散在各自的文档站点中的确有好处:它们可以各自维护自己所需的东西、互不干扰。

但是缺点也很明显: 太过分散。

组件库与核心库之间的关系是比较紧密的, 我们希望你能够在一个站点内就可以查阅或搜索到所有你想要得知的信息。

      消息元素实现

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

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

      QGArk

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

      QGContentText
      QGEmbed

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

      QGReference

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

      QGReplyTo

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

      发送消息

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

      前者多由 行为对象 中的一些类型实现(例如QGMember、 QGTextChannel), 而后者则通常由与消息相关的事件实现(例如 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: 15 July 2024