4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-06-26 16:39:24 +00:00

Add MessageSplit option to split messages on MessageLength (irc). Closes #281

This commit is contained in:
Wim
2017-11-24 23:27:13 +01:00
parent 7ec95f786d
commit e0cbb69a4f
4 changed files with 25 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import (
"crypto/tls"
"fmt"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
log "github.com/Sirupsen/logrus"
"github.com/lrstanley/girc"
"github.com/paulrosania/go-charset/charset"
@ -191,6 +192,10 @@ func (b *Birc) Send(msg config.Message) (string, error) {
}
}
// split long messages on messageLength, to avoid clipped messages #281
if b.Config.MessageSplit {
msg.Text = helper.SplitStringLength(msg.Text, b.Config.MessageLength)
}
for _, text := range strings.Split(msg.Text, "\n") {
if len(text) > b.Config.MessageLength {
text = text[:b.Config.MessageLength] + " <message clipped>"