diff options
author | Wim <wim@42.be> | 2017-10-27 00:07:33 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-10-27 00:07:33 +0200 |
commit | 41aa8ad7994075a72aebb2ce14d62a00bef022d7 (patch) | |
tree | 9984aab0ae3b9661586f1ffbd28d78dee7b405ac | |
parent | 7973baedd0ced9b57492e0b532b34dfff1329da1 (diff) | |
download | matterbridge-msglm-41aa8ad7994075a72aebb2ce14d62a00bef022d7.tar.gz matterbridge-msglm-41aa8ad7994075a72aebb2ce14d62a00bef022d7.tar.bz2 matterbridge-msglm-41aa8ad7994075a72aebb2ce14d62a00bef022d7.zip |
Add StripNick option, only allow alphanumerical nicks. Closes #285
-rw-r--r-- | bridge/config/config.go | 1 | ||||
-rw-r--r-- | gateway/gateway.go | 4 | ||||
-rw-r--r-- | matterbridge.toml.sample | 56 |
3 files changed, 61 insertions, 0 deletions
diff --git a/bridge/config/config.go b/bridge/config/config.go index c6686a42..0dfba94b 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -80,6 +80,7 @@ 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 06eec560..cdd8247e 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -243,6 +243,10 @@ 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 d122ea9f..b6a674e9 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -104,6 +104,11 @@ 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 ################################################################### @@ -161,6 +166,10 @@ 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 @@ -211,6 +220,10 @@ 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 @@ -321,6 +334,11 @@ 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. @@ -360,6 +378,11 @@ 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 ################################################################### @@ -446,6 +469,11 @@ 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 ################################################################### @@ -509,6 +537,11 @@ 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 ################################################################### @@ -571,6 +604,10 @@ 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 @@ -635,6 +672,11 @@ 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 ################################################################### @@ -690,6 +732,11 @@ 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 ################################################################### @@ -739,6 +786,10 @@ 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 @@ -782,6 +833,11 @@ 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 ################################################################### |