package bot import ( "strings" "unicode" ) const maxNoteLength = 500 const maxUsernameLength = 64 // SanitizeNote cleans user-provided note text: trims whitespace, limits length, // and removes control characters (keeps newlines). func SanitizeNote(s string) string { s = strings.TrimSpace(s) if len(s) > maxNoteLength { s = s[:maxNoteLength] } return strings.Map(func(r rune) rune { if r == '\n' || r == '\t' || r == ' ' { return r } if unicode.IsControl(r) { return -1 } return r }, s) } // SanitizeDisplayName cleans a display name (username) for safe rendering. func SanitizeDisplayName(s string) string { s = strings.TrimSpace(s) if len(s) > maxUsernameLength { s = s[:maxUsernameLength] } return strings.Map(func(r rune) rune { if unicode.IsControl(r) { return -1 } return r }, s) }