Skip to content

Commit

Permalink
Add StripNick option, only allow alphanumerical nicks. Closes #285
Browse files Browse the repository at this point in the history
  • Loading branch information
42wim committed Oct 26, 2017
1 parent 7973bae commit 41aa8ad
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions bridge/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 56 additions & 0 deletions matterbridge.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
###################################################################
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
###################################################################
Expand Down Expand Up @@ -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
###################################################################
Expand Down Expand Up @@ -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
###################################################################
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
###################################################################
Expand Down Expand Up @@ -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
###################################################################
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
###################################################################
Expand Down

0 comments on commit 41aa8ad

Please sign in to comment.