Shamrock: fix #155

This commit is contained in:
WhiteChi 2023-12-18 21:15:56 +08:00
parent 6107ec6ffb
commit 6ee5ceb321
3 changed files with 17 additions and 1 deletions

View File

@ -18,7 +18,6 @@ public final class MarkdownElement {
}
public MarkdownElement(String str) {
this.content = "";
this.content = str;
}
}

View File

@ -53,6 +53,7 @@ internal object MessageConvert {
MsgConstant.KELEMTYPEREPLY to MessageElemConverter.ReplyConverter,
MsgConstant.KELEMTYPEGRAYTIP to MessageElemConverter.GrayTipsConverter,
MsgConstant.KELEMTYPEFILE to MessageElemConverter.FileConverter,
MsgConstant.KELEMTYPEMARKDOWN to MessageElemConverter.MarkdownConverter,
//MsgConstant.KELEMTYPEMULTIFORWARD to MessageElemConverter.XmlMultiMsgConverter,
//MsgConstant.KELEMTYPESTRUCTLONGMSG to MessageElemConverter.XmlLongMsgConverter,
)

View File

@ -412,6 +412,22 @@ internal sealed class MessageElemConverter: IMessageConvert {
}
}
object MarkdownConverter: MessageElemConverter() {
override suspend fun convert(
chatType: Int,
peerId: String,
element: MsgElement
): MessageSegment {
val markdown = element.markdownElement
return MessageSegment(
type = "markdown",
data = mapOf(
"content" to markdown.content
)
)
}
}
protected fun unknownChatType(chatType: Int) {
throw UnsupportedOperationException("Not supported chat type: $chatType")
}