Skip to content

Commit 8806393

Browse files
committed
chunk string
1 parent 360764d commit 8806393

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

service/bot/api_handler.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import (
77

88
"github.com/Mrs4s/MiraiGo/client"
99
"github.com/Mrs4s/MiraiGo/message"
10+
"github.com/Mrs4s/MiraiGo/utils"
1011
"github.com/ProtobufBot/Go-Mirai-Client/proto_gen/onebot"
1112
"github.com/ProtobufBot/Go-Mirai-Client/service/cache"
1213
log "github.com/sirupsen/logrus"
1314
)
1415

15-
const MAX_TEXT_LENGTH = 64
16+
const MAX_TEXT_LENGTH = 80
1617

1718
// 风控临时解决方案
1819
func splitText(content string, limit int) []string {
@@ -66,9 +67,7 @@ func preProcessGroupSendingMessage(cli *client.QQClient, groupCode int64, m *mes
6667
newElements := make([]message.IMessageElement, 0, len(m.Elements))
6768
for _, element := range m.Elements {
6869
if i, ok := element.(*message.TextElement); ok {
69-
content := i.Content
70-
textList := splitText(content, MAX_TEXT_LENGTH)
71-
for _, text := range textList {
70+
for _, text := range utils.ChunkString(i.Content, MAX_TEXT_LENGTH) {
7271
newElements = append(newElements, message.NewText(text))
7372
}
7473
continue

0 commit comments

Comments
 (0)