mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-23 06:10:30 +08:00
Fix FlashImage constructing
This commit is contained in:
parent
ebe3ecd2cb
commit
b4f77454a1
@ -116,8 +116,10 @@ internal fun MessageChain.toRichTextElems(forGroup: Boolean, withGeneralFlags: B
|
||||
is OnlineGroupImageImpl -> elements.add(ImMsgBody.Elem(customFace = it.delegate))
|
||||
is OnlineFriendImageImpl -> elements.add(ImMsgBody.Elem(notOnlineImage = it.delegate))
|
||||
is OfflineFriendImage -> elements.add(ImMsgBody.Elem(notOnlineImage = it.toJceData()))
|
||||
is GroupFlashImageImpl -> elements.add(it.toJceData()).also { transformOneMessage(UNSUPPORTED_FLASH_MESSAGE_PLAIN) }
|
||||
is FriendFlashImageImpl -> elements.add(it.toJceData()).also { transformOneMessage(UNSUPPORTED_FLASH_MESSAGE_PLAIN) }
|
||||
is GroupFlashImage -> elements.add(it.toJceData())
|
||||
.also { transformOneMessage(UNSUPPORTED_FLASH_MESSAGE_PLAIN) }
|
||||
is FriendFlashImage -> elements.add(it.toJceData())
|
||||
.also { transformOneMessage(UNSUPPORTED_FLASH_MESSAGE_PLAIN) }
|
||||
is AtAll -> elements.add(atAllData)
|
||||
is Face -> elements.add(ImMsgBody.Elem(face = it.toJceData()))
|
||||
is QuoteReplyToSend -> {
|
||||
@ -303,10 +305,10 @@ internal fun List<ImMsgBody.Elem>.joinToMessageChain(message: MessageChainBuilde
|
||||
3 -> {
|
||||
val proto = it.commonElem.pbElem.loadAs(HummerCommelem.MsgElemInfoServtype3.serializer())
|
||||
if (proto.flashTroopPic != null) {
|
||||
message.add(GroupFlashImageImpl(OnlineGroupImageImpl(proto.flashTroopPic)))
|
||||
message.add(GroupFlashImage(OnlineGroupImageImpl(proto.flashTroopPic)))
|
||||
}
|
||||
if (proto.flashC2cPic != null) {
|
||||
message.add(FriendFlashImageImpl(OnlineFriendImageImpl(proto.flashC2cPic)))
|
||||
message.add(FriendFlashImage(OnlineFriendImageImpl(proto.flashC2cPic)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
package net.mamoe.mirai.message.data
|
||||
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.SinceMirai
|
||||
import kotlin.jvm.JvmSynthetic
|
||||
|
||||
@ -14,6 +15,7 @@ import kotlin.jvm.JvmSynthetic
|
||||
sealed class FlashImage : MessageContent {
|
||||
companion object Key : Message.Key<FlashImage> {
|
||||
operator fun invoke(image: Image): FlashImage {
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
return when (image) {
|
||||
is GroupImage -> GroupFlashImage(image)
|
||||
is FriendImage -> FriendFlashImage(image)
|
||||
@ -51,6 +53,12 @@ inline fun GroupImage.flash(): GroupFlashImage = FlashImage(this) as GroupFlashI
|
||||
@JvmSynthetic
|
||||
inline fun FriendImage.flash(): FriendFlashImage = FlashImage(this) as FriendFlashImage
|
||||
|
||||
class GroupFlashImage internal constructor(override val image: GroupImage) : FlashImage()
|
||||
/**
|
||||
* @see FlashImage.invoke
|
||||
*/
|
||||
class GroupFlashImage @MiraiInternalAPI constructor(override val image: GroupImage) : FlashImage()
|
||||
|
||||
class FriendFlashImage internal constructor(override val image: FriendImage) : FlashImage()
|
||||
/**
|
||||
* @see FlashImage.invoke
|
||||
*/
|
||||
class FriendFlashImage @MiraiInternalAPI constructor(override val image: FriendImage) : FlashImage()
|
Loading…
Reference in New Issue
Block a user