@@ -396,13 +396,24 @@ func init() {
396
396
b .WriteString (" 条消息总结:\n \n " )
397
397
b .WriteString (summary )
398
398
399
- // 分割总结内容为多段
400
- parts := strings .Split (b .String (), "\n " )
401
- msg := make (message.Message , 0 , len (parts ))
402
- for _ , part := range parts {
403
- if part != "" {
404
- msg = append (msg , ctxext .FakeSenderForwardNode (ctx , message .Text (part )))
399
+ // 分割总结内容为多段(按1000字符长度切割)
400
+ summaryText := b .String ()
401
+ msg := make (message.Message , 0 )
402
+ for len (summaryText ) > 0 {
403
+ if len (summaryText ) <= 1000 {
404
+ msg = append (msg , ctxext .FakeSenderForwardNode (ctx , message .Text (summaryText )))
405
+ break
405
406
}
407
+
408
+ // 查找1000字符内的最后一个换行符,尽量在换行处分割
409
+ chunk := summaryText [:1000 ]
410
+ lastNewline := strings .LastIndex (chunk , "\n " )
411
+ if lastNewline > 0 {
412
+ chunk = summaryText [:lastNewline + 1 ]
413
+ }
414
+
415
+ msg = append (msg , ctxext .FakeSenderForwardNode (ctx , message .Text (chunk )))
416
+ summaryText = summaryText [len (chunk ):]
406
417
}
407
418
if len (msg ) > 0 {
408
419
ctx .Send (msg )
@@ -470,13 +481,23 @@ func init() {
470
481
return
471
482
}
472
483
473
- // 分割内容为多段
474
- parts = strings . Split ( reply , " \n " )
475
- msg := make (message. Message , 0 , len ( parts ))
476
- for _ , part := range parts {
477
- if part != "" {
478
- msg = append ( msg , ctxext . FakeSenderForwardNode ( ctx , message . Text ( part )))
484
+ // 分割总结内容为多段(按1000字符长度切割)
485
+ msg := make (message. Message , 0 )
486
+ for len ( reply ) > 0 {
487
+ if len ( reply ) <= 1000 {
488
+ msg = append ( msg , ctxext . FakeSenderForwardNode ( ctx , message . Text ( reply )))
489
+ break
479
490
}
491
+
492
+ // 查找1000字符内的最后一个换行符,尽量在换行处分割
493
+ chunk := reply [:1000 ]
494
+ lastNewline := strings .LastIndex (chunk , "\n " )
495
+ if lastNewline > 0 {
496
+ chunk = reply [:lastNewline + 1 ]
497
+ }
498
+
499
+ msg = append (msg , ctxext .FakeSenderForwardNode (ctx , message .Text (chunk )))
500
+ reply = reply [len (chunk ):]
480
501
}
481
502
if len (msg ) > 0 {
482
503
ctx .Send (msg )
0 commit comments