mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-07-06 20:47:57 +02:00
30 lines
586 B
Go
30 lines
586 B
Go
package robot
|
|
|
|
import "strings"
|
|
|
|
// splitTextChunks splits text into chunks no longer than maxRunes (rune count).
|
|
func splitTextChunks(text string, maxRunes int) []string {
|
|
text = strings.TrimSpace(text)
|
|
if text == "" || maxRunes <= 0 {
|
|
return nil
|
|
}
|
|
runes := []rune(text)
|
|
if len(runes) <= maxRunes {
|
|
return []string{text}
|
|
}
|
|
var out []string
|
|
for len(runes) > 0 {
|
|
end := maxRunes
|
|
if end > len(runes) {
|
|
end = len(runes)
|
|
}
|
|
out = append(out, string(runes[:end]))
|
|
runes = runes[end:]
|
|
}
|
|
return out
|
|
}
|
|
|
|
func trimReply(s string) string {
|
|
return strings.TrimSpace(s)
|
|
}
|