5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-09-19 15:49:36 +00:00

Add StripNick option, only allow alphanumerical nicks. Closes #285

This commit is contained in:
Wim 2017-10-27 00:07:33 +02:00
parent 7973baedd0
commit 41aa8ad799
3 changed files with 61 additions and 0 deletions

View File

@ -80,6 +80,7 @@ type Protocol struct {
ShowJoinPart bool // all protocols ShowJoinPart bool // all protocols
ShowEmbeds bool // discord ShowEmbeds bool // discord
SkipTLSVerify bool // IRC, mattermost SkipTLSVerify bool // IRC, mattermost
StripNick bool // all protocols
Team string // mattermost Team string // mattermost
Token string // gitter, slack, discord, api Token string // gitter, slack, discord, api
URL string // mattermost, slack // DEPRECATED URL string // mattermost, slack // DEPRECATED

View File

@ -243,6 +243,10 @@ func (gw *Gateway) ignoreMessage(msg *config.Message) bool {
func (gw *Gateway) modifyUsername(msg config.Message, dest *bridge.Bridge) string { func (gw *Gateway) modifyUsername(msg config.Message, dest *bridge.Bridge) string {
br := gw.Bridges[msg.Account] br := gw.Bridges[msg.Account]
msg.Protocol = br.Protocol 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 nick := dest.Config.RemoteNickFormat
if nick == "" { if nick == "" {
nick = gw.Config.General.RemoteNickFormat nick = gw.Config.General.RemoteNickFormat

View File

@ -104,6 +104,11 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#OPTIONAL (default false) #OPTIONAL (default false)
ShowJoinPart=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 #XMPP section
################################################################### ###################################################################
@ -161,6 +166,10 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#OPTIONAL (default false) #OPTIONAL (default false)
ShowJoinPart=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 #hipchat section
@ -211,6 +220,10 @@ RemoteNickFormat="[{PROTOCOL}/{BRIDGE}] <{NICK}> "
#OPTIONAL (default false) #OPTIONAL (default false)
ShowJoinPart=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 #mattermost section
@ -321,6 +334,11 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#OPTIONAL (default false) #OPTIONAL (default false)
ShowJoinPart=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 #Gitter section
#Best to make a dedicated gitter account for the bot. #Best to make a dedicated gitter account for the bot.
@ -360,6 +378,11 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#OPTIONAL (default false) #OPTIONAL (default false)
ShowJoinPart=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 #slack section
################################################################### ###################################################################
@ -446,6 +469,11 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#OPTIONAL (default false) #OPTIONAL (default false)
ShowJoinPart=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 #discord section
################################################################### ###################################################################
@ -509,6 +537,11 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#OPTIONAL (default false) #OPTIONAL (default false)
ShowJoinPart=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 #telegram section
################################################################### ###################################################################
@ -571,6 +604,10 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#OPTIONAL (default false) #OPTIONAL (default false)
ShowJoinPart=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 #rocketchat section
@ -635,6 +672,11 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#OPTIONAL (default false) #OPTIONAL (default false)
ShowJoinPart=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 #matrix section
################################################################### ###################################################################
@ -690,6 +732,11 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#OPTIONAL (default false) #OPTIONAL (default false)
ShowJoinPart=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 #steam section
################################################################### ###################################################################
@ -739,6 +786,10 @@ RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#OPTIONAL (default false) #OPTIONAL (default false)
ShowJoinPart=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 #API
@ -782,6 +833,11 @@ RemoteNickFormat="{NICK}"
#OPTIONAL (default empty) #OPTIONAL (default empty)
RemoteNickFormat="[{PROTOCOL}] <{NICK}> " 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 #Gateway configuration
################################################################### ###################################################################