mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-08-15 15:40:38 +02:00
Add files via upload
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user