Thumbnail

rani/matterbridge.git

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

commit 3640d966913301041be82931cf16b746e216611e Author: Wim <wim@42.be> Date: Fri Oct 27 00:07:33 2017 +0000 Add StripNick option, only allow alphanumerical nicks. Closes #285 diff --git a/bridge/config/config.go b/bridge/config/config.go index c6686a4..0dfba94 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -806 +807 @@ type Protocol struct {   ShowJoinPart bool // all protocols   ShowEmbeds bool // discord   SkipTLSVerify bool // IRC, mattermost + StripNick bool // all protocols   Team string // mattermost   Token string // gitter, slack, discord, api   URL string // mattermost, slack // DEPRECATED diff --git a/gateway/gateway.go b/gateway/gateway.go index 06eec56..cdd8247 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -2436 +24310 @@ func (gw *Gateway) ignoreMessage(msg *config.Message) bool {  func (gw *Gateway) modifyUsername(msg config.Message, dest *bridge.Bridge) string {   br := gw.Bridges[msg.Account]   msg.Protocol = br.Protocol + if gw.Config.General.StripNick || dest.Config.StripNick { + re := regexp.MustCompile("[^a-zA-Z0-9]+") + msg.Username = re.ReplaceAllString(msg.Username, "") + }   nick := dest.Config.RemoteNickFormat   if nick == "" {   nick = gw.Config.General.RemoteNickFormat diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index d122ea9..b6a674e 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -1046 +10411 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "  #OPTIONAL (default false)  ShowJoinPart=false   +#StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285 +#It will strip other characters from the nick +#OPTIONAL (default false) +StripNick=false +  ###################################################################  #XMPP section  ################################################################### @@ -1616 +16610 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "  #OPTIONAL (default false)  ShowJoinPart=false   +#StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285 +#It will strip other characters from the nick +#OPTIONAL (default false) +StripNick=false    ###################################################################  #hipchat section @@ -2116 +22010 @@ RemoteNickFormat="[{PROTOCOL}/{BRIDGE}] <{NICK}> "  #OPTIONAL (default false)  ShowJoinPart=false   +#StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285 +#It will strip other characters from the nick +#OPTIONAL (default false) +StripNick=false    ###################################################################  #mattermost section @@ -3216 +33411 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "  #OPTIONAL (default false)  ShowJoinPart=false   +#StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285 +#It will strip other characters from the nick +#OPTIONAL (default false) +StripNick=false +  ###################################################################  #Gitter section  #Best to make a dedicated gitter account for the bot. @@ -3606 +37811 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "  #OPTIONAL (default false)  ShowJoinPart=false   +#StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285 +#It will strip other characters from the nick +#OPTIONAL (default false) +StripNick=false +  ###################################################################  #slack section  ################################################################### @@ -4466 +46911 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "  #OPTIONAL (default false)  ShowJoinPart=false   +#StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285 +#It will strip other characters from the nick +#OPTIONAL (default false) +StripNick=false +  ###################################################################  #discord section  ################################################################### @@ -5096 +53711 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "  #OPTIONAL (default false)  ShowJoinPart=false   +#StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285 +#It will strip other characters from the nick +#OPTIONAL (default false) +StripNick=false +  ###################################################################  #telegram section  ################################################################### @@ -5716 +60410 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "  #OPTIONAL (default false)  ShowJoinPart=false   +#StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285 +#It will strip other characters from the nick +#OPTIONAL (default false) +StripNick=false    ###################################################################  #rocketchat section @@ -6356 +67211 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "  #OPTIONAL (default false)  ShowJoinPart=false   +#StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285 +#It will strip other characters from the nick +#OPTIONAL (default false) +StripNick=false +  ###################################################################  #matrix section  ################################################################### @@ -6906 +73211 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "  #OPTIONAL (default false)  ShowJoinPart=false   +#StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285 +#It will strip other characters from the nick +#OPTIONAL (default false) +StripNick=false +  ###################################################################  #steam section  ################################################################### @@ -7396 +78610 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "  #OPTIONAL (default false)  ShowJoinPart=false   +#StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285 +#It will strip other characters from the nick +#OPTIONAL (default false) +StripNick=false    ###################################################################  #API @@ -7826 +83311 @@ RemoteNickFormat="{NICK}"  #OPTIONAL (default empty)  RemoteNickFormat="[{PROTOCOL}] <{NICK}> "   +#StripNick only allows alphanumerical nicks. See https://github.com/42wim/matterbridge/issues/285 +#It will strip other characters from the nick +#OPTIONAL (default false) +StripNick=false +  ###################################################################  #Gateway configuration  ###################################################################