diff options
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/config/config.go | 1 | ||||
-rw-r--r-- | bridge/irc/irc.go | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/bridge/config/config.go b/bridge/config/config.go index 2cd53666..243f6601 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -59,6 +59,7 @@ type Protocol struct { Protocol string //all protocols MessageQueue int // IRC, size of message queue for flood control MessageDelay int // IRC, time in millisecond to wait between messages + MessageLength int // IRC, max length of a message allowed MessageFormat string // telegram RemoteNickFormat string // all protocols Server string // IRC,mattermost,XMPP,discord diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go index a9a23529..8bb8896e 100644 --- a/bridge/irc/irc.go +++ b/bridge/irc/irc.go @@ -46,6 +46,9 @@ func New(cfg config.Protocol, account string, c chan config.Message) *Birc { if b.Config.MessageQueue == 0 { b.Config.MessageQueue = 30 } + if b.Config.MessageLength == 0 { + b.Config.MessageLength = 400 + } return b } @@ -111,6 +114,9 @@ func (b *Birc) Send(msg config.Message) error { b.Command(&msg) } for _, text := range strings.Split(msg.Text, "\n") { + if len(text) > b.Config.MessageLength { + text = text[:b.Config.MessageLength] + " <message clipped>" + } if len(b.Local) < b.Config.MessageQueue { if len(b.Local) == b.Config.MessageQueue-1 { text = text + " <message clipped>" |