diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go index 0e90aaf9..d95aef4e 100644 --- a/bridge/irc/irc.go +++ b/bridge/irc/irc.go @@ -19,6 +19,7 @@ import ( "strconv" "strings" "time" + "unicode/utf8" ) type Birc struct { @@ -200,9 +201,12 @@ func (b *Birc) Send(msg config.Message) (string, error) { msg.Text = helper.SplitStringLength(msg.Text, b.Config.MessageLength) } for _, text := range strings.Split(msg.Text, "\n") { - input := []rune(text) if len(text) > b.Config.MessageLength { - text = string(input[:b.Config.MessageLength]) + " " + text = text[:b.Config.MessageLength-len(" ")] + if r, size := utf8.DecodeLastRuneInString(text); r == utf8.RuneError { + text = text[:len(text)-size] + } + text += " " } if len(b.Local) < b.Config.MessageQueue { if len(b.Local) == b.Config.MessageQueue-1 {