MessageChainBuilder
MessageChain 构建器.
注意: 无并发安全性.
连续 String 优化
多个连续的 String 会被连接为单个 PlainText 以优化性能。
MessageChain chain = new MessageChainBuilder()
.append("Hello ")
.append("mirai!")
.build();
// chain 将会只包含一个 [PlainText], 其内容为 "Hello mirai!".
Content copied to clipboard
Kotlin 示例
val chain = buildMessageChain {
+PlainText("a")
+AtAll
+Image("/f8f1ab55-bf8e-4236-b55e-955848d7069f")
add(At(123456))
}
Content copied to clipboard
该示例中 +
是 MessageChainBuilder.unaryPlus. 使用 +
和使用 add
是相等的.
Java 示例
MessageChain chain = new MessageChainBuilder()
.append(new PlainText("string"))
.append("string") // 会被构造成 PlainText 再添加, 相当于上一行
.append(AtAll.INSTANCE)
.append(Image.fromId("{f8f1ab55-bf8e-4236-b55e-955848d7069f}.png"))
.build();
Content copied to clipboard
See also
Constructors
Functions
Link copied to clipboard
Link copied to clipboard
open override fun addAll(index: Int, elements: Collection<SingleMessage>): Boolean
Content copied to clipboard
Link copied to clipboard
open override fun append( value: CharSequence?, startIndex: Int, endIndex: Int): MessageChainBuilder
Content copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun containsAll(elements: Collection<SingleMessage>): Boolean
Content copied to clipboard
Link copied to clipboard
将所有已有元素引用复制到一个新的 MessageChainBuilder
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun listIterator(index: Int): MutableListIterator<SingleMessage>
Content copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun removeAll(elements: Collection<SingleMessage>): Boolean
Content copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun retainAll(elements: Collection<SingleMessage>): Boolean
Content copied to clipboard
Link copied to clipboard
open operator override fun set(index: Int, element: SingleMessage): SingleMessage
Content copied to clipboard
Link copied to clipboard
open override fun subList(fromIndex: Int, toIndex: Int): MutableList<SingleMessage>
Content copied to clipboard