Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 0e719b1ace6951e62df4c0e09a9464210619625b Author: Wim <wim@42.be> Date: Mon May 29 21:54:34 2017 +0000 Limit message length (irc). Closes #179 diff --git a/bridge/config/config.go b/bridge/config/config.go index 2cd5366..243f660 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -596 +597 @@ 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 a9a2352..8bb8896 100644 --- a/bridge/irc/irc.go +++ b/bridge/irc/irc.go @@ -466 +469 @@ 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  }   @@ -1116 +1149 @@ 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>" diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index f4d9af7..4e1a3f7 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -4810 +4815 @@ MessageDelay=1300    #Maximum amount of messages to hold in queue. If queue is full  #messages will be dropped. -#<clipped> will be add to the message that fills the queue. +#<message clipped> will be add to the message that fills the queue.  #OPTIONAL (default 30)  MessageQueue=30   +#Maximum length of message sent to irc server. If it exceeds +#<message clipped> will be add to the message. +#OPTIONAL (default 400) +MessageLength=400 +  #Nicks you want to ignore.  #Messages from those users will not be sent to other bridges.  #OPTIONAL