mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-06 08:00:10 +08:00
Fix FileMessage mirai code
This commit is contained in:
parent
f5e1206673
commit
9f52a26fbd
@ -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`.
|
||||
*/
|
||||
|
@ -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]"
|
||||
}
|
Loading…
Reference in New Issue
Block a user