Fix FileMessage mirai code

This commit is contained in:
Him188 2021-03-20 22:31:12 +08:00
parent f5e1206673
commit 9f52a26fbd
2 changed files with 9 additions and 8 deletions

View File

@ -23,6 +23,7 @@ import net.mamoe.mirai.event.events.MessageEvent
import net.mamoe.mirai.internal.message.copy
import net.mamoe.mirai.internal.message.map
import net.mamoe.mirai.message.code.CodableMessage
import net.mamoe.mirai.message.code.internal.appendStringAsMiraiCode
import net.mamoe.mirai.utils.MiraiExperimentalApi
import net.mamoe.mirai.utils.MiraiInternalApi
import net.mamoe.mirai.utils.RemoteFile
@ -66,6 +67,14 @@ public interface FileMessage : MessageContent, ConstrainSingle, CodableMessage {
override fun contentToString(): String = "[文件]$name" // orthodox
override fun appendMiraiCodeTo(builder: StringBuilder) {
builder.append("[mirai:file:")
builder.appendStringAsMiraiCode(id).append(",")
builder.append(internalId).append(",")
builder.appendStringAsMiraiCode(name).append(",")
builder.append(size).append("]")
}
/**
* 获取一个对应的 [RemoteFile]. 当目标群或好友不存在这个文件时返回 `null`.
*/

View File

@ -31,13 +31,5 @@ internal data class FileMessageImpl(
override val internalId: Int
get() = busId
override fun appendMiraiCodeTo(builder: StringBuilder) {
builder.append("[mirai:file:")
builder.append(id).append(",")
builder.append(busId).append(",")
builder.append(name).append(",")
builder.append(size).append("]")
}
override fun toString(): String = "[mirai:file:$name,$id,$size,$busId]"
}