The new logbot, not committed from the wrong terminal window this time.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

23 lines
451 B

package util
import (
"strings"
)
// RemoveNPCAttribution removes NPC attribution.
func RemoveNPCAttribution(str string) string {
lastOpen := strings.LastIndex(str, "(")
lastClose := strings.LastIndex(str, ")")
ending := len(str) - 1
if lastOpen > 0 && str[lastOpen-1] != '(' && (lastClose == -1 || lastClose == ending) {
cutoff := lastOpen
for cutoff > 1 && str[cutoff-1] == ' ' {
cutoff--
}
return str[:cutoff]
}
return str
}