MiraiForwardMessageBuilder

class MiraiForwardMessageBuilder(var displayStrategy: ForwardMessage.DisplayStrategy = ForwardMessage.DisplayStrategy)(source)

用于构建 MiraiForwardMessage 的构建器。

类似于 ForwardMessageBuilder, 但是有所简化,且使用的为 simbot 中的实体对象。

MiraiForwardMessageBuilder 屏蔽了构建 ForwardMessageBuilder 时所需要的 OriginalMiraiContact 参数, 但取而代之的,当你想要向转发消息中添加消息时,将不能直接使用 Bot 来拼接消息,而应该使用 OrganizationBot 或其下其他衍生类型。

在 Kotlin 中,你可以直接使用顶层函数 buildMiraiForwardMessage 来构建。

buildMiraiForwardMessage(displayStrategy = ...) {
add(114514, "用户名", "你好".toText(), Timestamp.now())
add(114514, "用户名", At(810.ID) + "你好".toText())

add(messageEvent)
add(messageEvent, 12345678)
add(messageEvent, Timestamp.now())

bot.says("最近如何".toText() + Face(5.ID))
user.says("感觉不错".toText())
// ....
}

对于 Java 开发者,直接构建并使用 MiraiForwardMessageBuilder 即可。

MiraiForwardMessageBuilder builder = new MiraiForwardMessageBuilder();
builder.add(123456, "forte", Text.of("早上好"));
builder.add(bot)

builder.add(event);
builder.add(event.getBot(), Text.of("早上好"));

// 在 Java 中,基本所有的API都叫 'add'。包括在Kotlin中被成为 'says' 的那些。

MiraiSendOnlyForwardMessage message = builder.build();

See also

Constructors

Link copied to clipboard
fun MiraiForwardMessageBuilder(displayStrategy: ForwardMessage.DisplayStrategy = ForwardMessage.DisplayStrategy)

Functions

Link copied to clipboard

直接添加一个 MiraiForwardMessage.Node.

直接添加一个 ForwardMessage.Node.

fun add(messageEvent: ChatRoomMessageEvent, secondTimestamp: Int): MiraiForwardMessageBuilder
fun add(messageEvent: ChatRoomMessageEvent, time: Timestamp = messageEvent.timestamp): MiraiForwardMessageBuilder

追加一个 ChatRoomMessageEvent 作为转发消息的元素。

fun add(messageEvent: ContactMessageEvent, secondTimestamp: Int): MiraiForwardMessageBuilder
fun add(messageEvent: ContactMessageEvent, time: Timestamp = messageEvent.timestamp): MiraiForwardMessageBuilder

追加一个 ContactMessageEvent 作为转发消息的元素。

fun add(senderId: Long, senderName: String, time: Timestamp, message: Message): MiraiForwardMessageBuilder
fun add(senderId: Long, senderName: String, time: Timestamp, messageContent: MessageContent): MiraiForwardMessageBuilder
fun add(senderId: Long, senderName: String, message: Message, secondTimestamp: Int = userCurrentTime()): MiraiForwardMessageBuilder
fun add(senderId: Long, senderName: String, messageContent: MessageContent, secondTimestamp: Int = userCurrentTime()): MiraiForwardMessageBuilder
fun add(senderId: ID, senderName: String, time: Timestamp, message: Message): MiraiForwardMessageBuilder
fun add(senderId: ID, senderName: String, time: Timestamp, messageContent: MessageContent): MiraiForwardMessageBuilder
fun add(senderId: ID, senderName: String, message: Message, secondTimestamp: Int = userCurrentTime()): MiraiForwardMessageBuilder
fun add(senderId: ID, senderName: String, messageContent: MessageContent, secondTimestamp: Int = userCurrentTime()): MiraiForwardMessageBuilder

根据 MiraiForwardMessage.Node 中的最基本的属性添加内容。

Link copied to clipboard

将当前构建器中的信息整合转化为 MiraiSendOnlyForwardMessage

Link copied to clipboard
@JvmName(name = "add")
fun Bot.says(text: String, secondTimestamp: Int = userCurrentTime(), name: String? = null): MiraiForwardMessageBuilder
@JvmName(name = "add")
fun Bot.says(message: Message, secondTimestamp: Int = userCurrentTime(), name: String? = null): MiraiForwardMessageBuilder

追加一个 Bot 说的话。

@JvmName(name = "add")
fun Contact.says(text: String, secondTimestamp: Int = userCurrentTime(), name: String = when (val c = this@says) { is Member -> c.nickOrUsername else -> c.username }): MiraiForwardMessageBuilder
@JvmName(name = "add")
fun Contact.says(message: Message, secondTimestamp: Int = userCurrentTime(), name: String = when (val c = this@says) { is Member -> c.nickOrUsername else -> c.username }): MiraiForwardMessageBuilder

追加一个 Contact 说的话。

Properties

Link copied to clipboard

当前时间。 构建node(追加消息节点时)时若不指定时间, 则会使用 currentSecondTimestamp 自增 1 的时间。

Link copied to clipboard

mirai中合并转发卡片展示策略.