mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-15 13:00:12 +08:00
Merge pull request #1115 from mamoe/transform_special_messages
Move Dice to MarketFace conversion from `SendMessageHandler.transformSpecialMessages`...
This commit is contained in:
commit
c47535289a
@ -255,6 +255,9 @@ internal abstract class SendMessageHandler<C : Contact> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 处理需要 `suspend` 操作的消息转换. 这个转换只会在发送消息时进行, 而不会在处理合并转发 [net.mamoe.mirai.internal.network.protocol.packet.chat.calculateValidationData] 等其他操作时进行.
|
||||||
|
* 在发包前还会进行最后的 [net.mamoe.mirai.internal.message.toRichTextElems] 转换, 这个转换会为所有操作使用.
|
||||||
|
*
|
||||||
* - [ForwardMessage] -> [ForwardMessageInternal] (by uploading through highway)
|
* - [ForwardMessage] -> [ForwardMessageInternal] (by uploading through highway)
|
||||||
* - ... any others for future
|
* - ... any others for future
|
||||||
*/
|
*/
|
||||||
@ -284,12 +287,9 @@ internal suspend fun <C : Contact> SendMessageHandler<C>.transformSpecialMessage
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun processDice(dice: Dice): MarketFaceImpl {
|
|
||||||
return MarketFaceImpl(dice.toJceStruct())
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// loses MessageMetadata and other message types but fine for now.
|
||||||
return message.takeSingleContent<ForwardMessage>()?.let { processForwardMessage(it) }?.toMessageChain()
|
return message.takeSingleContent<ForwardMessage>()?.let { processForwardMessage(it) }?.toMessageChain()
|
||||||
?: message.takeSingleContent<Dice>()?.let { processDice(it) }?.toMessageChain()
|
|
||||||
?: message.toMessageChain()
|
?: message.toMessageChain()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +194,7 @@ internal fun MessageChain.toRichTextElems(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
is Dice -> transformOneMessage(MarketFaceImpl(currentMessage.toJceStruct()))
|
||||||
is MarketFace -> {
|
is MarketFace -> {
|
||||||
if (currentMessage is MarketFaceImpl) {
|
if (currentMessage is MarketFaceImpl) {
|
||||||
elements.add(ImMsgBody.Elem(marketFace = currentMessage.delegate))
|
elements.add(ImMsgBody.Elem(marketFace = currentMessage.delegate))
|
||||||
|
Loading…
Reference in New Issue
Block a user