mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-05 07:30:09 +08:00
Fix inconsistent message length (#855)
* Fix #195 again, also fix #539 * Let AtAll consistent with At Co-authored-by: Him188 <Him188@mamoe.net> Co-authored-by: Him188 <Him188@mamoe.net>
This commit is contained in:
parent
9d25f05569
commit
72f870a3df
@ -11,8 +11,6 @@ package net.mamoe.mirai.internal.utils
|
||||
|
||||
import net.mamoe.mirai.contact.ContactOrBot
|
||||
import net.mamoe.mirai.message.data.*
|
||||
import net.mamoe.mirai.message.data.AtAll.display
|
||||
import net.mamoe.mirai.utils.safeCast
|
||||
|
||||
|
||||
internal fun Int.toIpV4AddressString(): String {
|
||||
@ -48,10 +46,10 @@ internal fun MessageChain.estimateLength(target: ContactOrBot, upTo: Int): Int =
|
||||
internal fun SingleMessage.estimateLength(target: ContactOrBot, upTo: Int): Int {
|
||||
return when (this) {
|
||||
is QuoteReply -> 444 + this.source.originalMessage.estimateLength(target, upTo) // Magic number
|
||||
is Image -> 260 // Magic number
|
||||
is Image -> 40 //magic number
|
||||
is PlainText -> content.chineseLength(upTo)
|
||||
is At -> this.getDisplay(target.safeCast()).chineseLength(upTo)
|
||||
is AtAll -> display.chineseLength(upTo)
|
||||
is At -> 60 //magic number
|
||||
is AtAll -> 60 //magic number
|
||||
else -> this.toString().chineseLength(upTo)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user