Add deprecated constructor for migration

This commit is contained in:
Him188 2020-12-17 11:34:41 +08:00
parent d81bc23268
commit ee36735632

View File

@ -22,6 +22,7 @@ import net.mamoe.mirai.contact.nameCardOrNick
import net.mamoe.mirai.event.events.MessageEvent
import net.mamoe.mirai.message.data.ForwardMessage.DisplayStrategy
import net.mamoe.mirai.utils.MiraiExperimentalApi
import net.mamoe.mirai.utils.PlannedRemoval
import net.mamoe.mirai.utils.currentTimeSeconds
import net.mamoe.mirai.utils.safeCast
@ -109,6 +110,30 @@ public data class ForwardMessage(
return "[mirai:forward:NOT_IMPLEMENTED]" // TODO: 2020/12/3 ForwardMessage.contentToString()
}
@PlannedRemoval("2.0-M2")
@Deprecated(
"Use RawForwardMessage and render manually or use buildForwardMessage",
ReplaceWith(
"RawForwardMessage(nodeList).render(displayStrategy)",
"net.mamoe.mirai.message.data.RawForwardMessage"
)
)
@JvmOverloads
public constructor(
/**
* 消息列表
*/
nodeList: Collection<INode>,
displayStrategy: DisplayStrategy = DisplayStrategy.Default
) : this(
preview = displayStrategy.generatePreview(RawForwardMessage(nodeList.map(INode::toNode))),
title = displayStrategy.generateTitle(RawForwardMessage(nodeList.map(INode::toNode))),
brief = displayStrategy.generateBrief(RawForwardMessage(nodeList.map(INode::toNode))),
source = displayStrategy.generateSource(RawForwardMessage(nodeList.map(INode::toNode))),
summary = displayStrategy.generateSummary(RawForwardMessage(nodeList.map(INode::toNode))),
nodeList = nodeList.map(INode::toNode),
)
/**
* @see ForwardMessage
*/
@ -560,3 +585,7 @@ public class ForwardMessageBuilder private constructor(
@Suppress("NOTHING_TO_INLINE")
internal inline fun Int.toLongUnsigned(): Long = this.toLong().and(0xFFFF_FFFF)
private fun ForwardMessage.INode.toNode(): ForwardMessage.Node {
return ForwardMessage.Node(senderId, time, senderName, message)
}