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

  1. package util
  2. import (
  3. "strings"
  4. )
  5. // RemoveNPCAttribution removes NPC attribution.
  6. func RemoveNPCAttribution(str string) string {
  7. lastOpen := strings.LastIndex(str, "(")
  8. lastClose := strings.LastIndex(str, ")")
  9. ending := len(str) - 1
  10. if lastOpen > 0 && str[lastOpen-1] != '(' && (lastClose == -1 || lastClose == ending) {
  11. cutoff := lastOpen
  12. for cutoff > 1 && str[cutoff-1] == ' ' {
  13. cutoff--
  14. }
  15. return str[:cutoff]
  16. }
  17. return str
  18. }