mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
Merge pull request #138 from sam01101/patch-msg-len
Fix message length problem
This commit is contained in:
commit
336be30cc8
@ -248,7 +248,7 @@ func (msg *SendingMessage) ToFragmented() [][]IMessageElement {
|
|||||||
func EstimateLength(elems []IMessageElement, limit int) int {
|
func EstimateLength(elems []IMessageElement, limit int) int {
|
||||||
sum := 0
|
sum := 0
|
||||||
for _, elem := range elems {
|
for _, elem := range elems {
|
||||||
if sum >= limit {
|
if sum > limit {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
left := int(math.Max(float64(limit-sum), 0))
|
left := int(math.Max(float64(limit-sum), 0))
|
||||||
|
@ -55,7 +55,7 @@ func ChineseLength(str string, limit int) int {
|
|||||||
default:
|
default:
|
||||||
sum += 4
|
sum += 4
|
||||||
}
|
}
|
||||||
if sum >= limit {
|
if sum > limit {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user