From 47d29ecf63be89fff5c2ecb9e354dc6cca70c5f0 Mon Sep 17 00:00:00 2001 From: Patrick Connolly Date: Sat, 1 Dec 2018 07:24:07 +0800 Subject: Tidy up fetching of config values. (#616) --- gateway/gateway.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'gateway') diff --git a/gateway/gateway.go b/gateway/gateway.go index 674179fb..2874ef24 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -233,14 +233,14 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM } // only relay join/part when configured - if msg.Event == config.EventJoinLeave && !gw.Bridges[dest.Account].GetBool("ShowJoinPart") { + if msg.Event == config.EventJoinLeave && !dest.GetBool("ShowJoinPart") { return brMsgIDs } // only relay topic change when used in some way on other side if msg.Event == config.EventTopicChange && - !gw.Bridges[dest.Account].GetBool("ShowTopicChange") && - !gw.Bridges[dest.Account].GetBool("SyncTopic") { + dest.GetBool("ShowTopicChange") && + dest.GetBool("SyncTopic") { return brMsgIDs } @@ -252,7 +252,7 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM // Get the ID of the parent message in thread var canonicalParentMsgID string - if msg.ParentID != "" && (gw.BridgeValues().General.PreserveThreading || dest.GetBool("PreserveThreading")) { + if msg.ParentID != "" && dest.GetBool("PreserveThreading") { canonicalParentMsgID = gw.FindCanonicalMsgID(msg.Protocol, msg.ParentID) } @@ -364,14 +364,11 @@ 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.BridgeValues().General.StripNick || dest.GetBool("StripNick") { + if dest.GetBool("StripNick") { re := regexp.MustCompile("[^a-zA-Z0-9]+") msg.Username = re.ReplaceAllString(msg.Username, "") } nick := dest.GetString("RemoteNickFormat") - if nick == "" { - nick = gw.BridgeValues().General.RemoteNickFormat - } // loop to replace nicks for _, outer := range br.GetStringSlice2D("ReplaceNicks") { @@ -409,10 +406,7 @@ func (gw *Gateway) modifyUsername(msg config.Message, dest *bridge.Bridge) strin } func (gw *Gateway) modifyAvatar(msg config.Message, dest *bridge.Bridge) string { - iconurl := gw.BridgeValues().General.IconURL - if iconurl == "" { - iconurl = dest.GetString("IconURL") - } + iconurl := dest.GetString("IconURL") iconurl = strings.Replace(iconurl, "{NICK}", msg.Username, -1) if msg.Avatar == "" { msg.Avatar = iconurl -- cgit v1.2.3