diff options
author | Wim <wim@42.be> | 2017-05-29 21:54:34 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-05-29 21:54:34 +0200 |
commit | 9d9cb32f4efa78fcdbb49a84d221b5e731c336c2 (patch) | |
tree | 8b317d3921d70e75169511f8c853ac65458b3c0a /bridge/irc | |
parent | 87229bab13d89d87284993f27a4c5c2afa762aa2 (diff) | |
download | matterbridge-msglm-9d9cb32f4efa78fcdbb49a84d221b5e731c336c2.tar.gz matterbridge-msglm-9d9cb32f4efa78fcdbb49a84d221b5e731c336c2.tar.bz2 matterbridge-msglm-9d9cb32f4efa78fcdbb49a84d221b5e731c336c2.zip |
Limit message length (irc). Closes #179
Diffstat (limited to 'bridge/irc')
-rw-r--r-- | bridge/irc/irc.go | 6 |
1 files changed, 6 insertions, 0 deletions
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>" |