From 67f625761785bdd1daf7101668f4853adacdd694 Mon Sep 17 00:00:00 2001 From: Wim Date: Fri, 2 Feb 2018 21:04:43 +0100 Subject: [PATCH] Add ShowTopicChange option. Allow/disable topic change messages (currently only from slack). Closes #353 --- bridge/config/config.go | 2 ++ bridge/slack/slack.go | 3 ++ gateway/gateway.go | 3 ++ matterbridge.toml.sample | 77 ++++++++++++++++++++++++++++++++++------ 4 files changed, 74 insertions(+), 11 deletions(-) diff --git a/bridge/config/config.go b/bridge/config/config.go index af3bf036..fdb6e55c 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -11,6 +11,7 @@ import ( const ( EVENT_JOIN_LEAVE = "join_leave" + EVENT_TOPIC_CHANGE = "topic_change" EVENT_FAILURE = "failure" EVENT_REJOIN_CHANNELS = "rejoin_channels" EVENT_USER_ACTION = "user_action" @@ -88,6 +89,7 @@ type Protocol struct { RemoteNickFormat string // all protocols Server string // IRC,mattermost,XMPP,discord ShowJoinPart bool // all protocols + ShowTopicChange bool // slack ShowEmbeds bool // discord SkipTLSVerify bool // IRC, mattermost StripNick bool // all protocols diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index 421cc6a3..f7001568 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -284,6 +284,9 @@ func (b *Bslack) handleSlack() { msg.Event = config.EVENT_MSG_DELETE msg.ID = "slack " + message.Raw.DeletedTimestamp } + if message.Raw.SubType == "channel_topic" { + msg.Event = config.EVENT_TOPIC_CHANGE + } // if we have a file attached, download it (in memory) and put a pointer to it in msg.Extra if message.Raw.File != nil { diff --git a/gateway/gateway.go b/gateway/gateway.go index 6e327686..93e5b5be 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -181,6 +181,9 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM if msg.Event == config.EVENT_JOIN_LEAVE && !gw.Bridges[dest.Account].Config.ShowJoinPart { return brMsgIDs } + if msg.Event == config.EVENT_TOPIC_CHANGE && !gw.Bridges[dest.Account].Config.ShowTopicChange { + return brMsgIDs + } // broadcast to every out channel (irc QUIT) if msg.Channel == "" && msg.Event != config.EVENT_JOIN_LEAVE { log.Debug("empty channel") diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index fea60c12..e0589fcb 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -126,7 +126,7 @@ ReplaceNicks=[ ["user--","user"] ] RemoteNickFormat="[{PROTOCOL}] <{NICK}> " #Enable to show users joins/parts from other bridges -#Only works hiding/show messages from irc and mattermost bridge for now +#Currently works for messages from the following bridges: irc, mattermost, slack #OPTIONAL (default false) ShowJoinPart=false @@ -135,6 +135,11 @@ ShowJoinPart=false #OPTIONAL (default false) StripNick=false +#Enable to show topic changes from other bridges +#Only works hiding/show topic changes from slack bridge for now +#OPTIONAL (default false) +ShowTopicChange=false + ################################################################### #XMPP section ################################################################### @@ -205,7 +210,7 @@ ReplaceNicks=[ ["user--","user"] ] RemoteNickFormat="[{PROTOCOL}] <{NICK}> " #Enable to show users joins/parts from other bridges -#Only works hiding/show messages from irc and mattermost bridge for now +#Currently works for messages from the following bridges: irc, mattermost, slack #OPTIONAL (default false) ShowJoinPart=false @@ -214,6 +219,11 @@ ShowJoinPart=false #OPTIONAL (default false) StripNick=false +#Enable to show topic changes from other bridges +#Only works hiding/show topic changes from slack bridge for now +#OPTIONAL (default false) +ShowTopicChange=false + ################################################################### #hipchat section ################################################################### @@ -276,7 +286,7 @@ ReplaceNicks=[ ["user--","user"] ] RemoteNickFormat="[{PROTOCOL}/{BRIDGE}] <{NICK}> " #Enable to show users joins/parts from other bridges -#Only works hiding/show messages from irc and mattermost bridge for now +#Currently works for messages from the following bridges: irc, mattermost, slack #OPTIONAL (default false) ShowJoinPart=false @@ -285,6 +295,11 @@ ShowJoinPart=false #OPTIONAL (default false) StripNick=false +#Enable to show topic changes from other bridges +#Only works hiding/show topic changes from slack bridge for now +#OPTIONAL (default false) +ShowTopicChange=false + ################################################################### #mattermost section ################################################################### @@ -407,7 +422,7 @@ ReplaceNicks=[ ["user--","user"] ] RemoteNickFormat="[{PROTOCOL}] <{NICK}> " #Enable to show users joins/parts from other bridges -#Only works hiding/show messages from irc and mattermost bridge for now +#Currently works for messages from the following bridges: irc, mattermost, slack #OPTIONAL (default false) ShowJoinPart=false @@ -416,6 +431,11 @@ ShowJoinPart=false #OPTIONAL (default false) StripNick=false +#Enable to show topic changes from other bridges +#Only works hiding/show topic changes from slack bridge for now +#OPTIONAL (default false) +ShowTopicChange=false + ################################################################### #Gitter section #Best to make a dedicated gitter account for the bot. @@ -468,7 +488,7 @@ ReplaceNicks=[ ["user--","user"] ] RemoteNickFormat="[{PROTOCOL}] <{NICK}> " #Enable to show users joins/parts from other bridges -#Only works hiding/show messages from irc and mattermost bridge for now +#Currently works for messages from the following bridges: irc, mattermost, slack #OPTIONAL (default false) ShowJoinPart=false @@ -477,6 +497,11 @@ ShowJoinPart=false #OPTIONAL (default false) StripNick=false +#Enable to show topic changes from other bridges +#Only works hiding/show topic changes from slack bridge for now +#OPTIONAL (default false) +ShowTopicChange=false + ################################################################### #slack section ################################################################### @@ -576,7 +601,7 @@ ReplaceNicks=[ ["user--","user"] ] RemoteNickFormat="[{PROTOCOL}] <{NICK}> " #Enable to show users joins/parts from other bridges -#Only works hiding/show messages from irc and mattermost bridge for now +#Currently works for messages from the following bridges: irc, mattermost, slack #OPTIONAL (default false) ShowJoinPart=false @@ -585,6 +610,11 @@ ShowJoinPart=false #OPTIONAL (default false) StripNick=false +#Enable to show topic changes from other bridges +#Only works hiding/show topic changes from slack bridge for now +#OPTIONAL (default false) +ShowTopicChange=false + ################################################################### #discord section ################################################################### @@ -661,7 +691,7 @@ ReplaceNicks=[ ["user--","user"] ] RemoteNickFormat="[{PROTOCOL}] <{NICK}> " #Enable to show users joins/parts from other bridges -#Only works hiding/show messages from irc and mattermost bridge for now +#Currently works for messages from the following bridges: irc, mattermost, slack #OPTIONAL (default false) ShowJoinPart=false @@ -670,6 +700,11 @@ ShowJoinPart=false #OPTIONAL (default false) StripNick=false +#Enable to show topic changes from other bridges +#Only works hiding/show topic changes from slack bridge for now +#OPTIONAL (default false) +ShowTopicChange=false + ################################################################### #telegram section ################################################################### @@ -745,7 +780,7 @@ ReplaceNicks=[ ["user--","user"] ] RemoteNickFormat="[{PROTOCOL}] <{NICK}> " #Enable to show users joins/parts from other bridges -#Only works hiding/show messages from irc and mattermost bridge for now +#Currently works for messages from the following bridges: irc, mattermost, slack #OPTIONAL (default false) ShowJoinPart=false @@ -754,6 +789,11 @@ ShowJoinPart=false #OPTIONAL (default false) StripNick=false +#Enable to show topic changes from other bridges +#Only works hiding/show topic changes from slack bridge for now +#OPTIONAL (default false) +ShowTopicChange=false + ################################################################### #rocketchat section ################################################################### @@ -830,7 +870,7 @@ ReplaceNicks=[ ["user--","user"] ] RemoteNickFormat="[{PROTOCOL}] <{NICK}> " #Enable to show users joins/parts from other bridges -#Only works hiding/show messages from irc and mattermost bridge for now +#Currently works for messages from the following bridges: irc, mattermost, slack #OPTIONAL (default false) ShowJoinPart=false @@ -839,6 +879,11 @@ ShowJoinPart=false #OPTIONAL (default false) StripNick=false +#Enable to show topic changes from other bridges +#Only works hiding/show topic changes from slack bridge for now +#OPTIONAL (default false) +ShowTopicChange=false + ################################################################### #matrix section ################################################################### @@ -907,7 +952,7 @@ ReplaceNicks=[ ["user--","user"] ] RemoteNickFormat="[{PROTOCOL}] <{NICK}> " #Enable to show users joins/parts from other bridges -#Only works hiding/show messages from irc and mattermost bridge for now +#Currently works for messages from the following bridges: irc, mattermost, slack #OPTIONAL (default false) ShowJoinPart=false @@ -916,6 +961,11 @@ ShowJoinPart=false #OPTIONAL (default false) StripNick=false +#Enable to show topic changes from other bridges +#Only works hiding/show topic changes from slack bridge for now +#OPTIONAL (default false) +ShowTopicChange=false + ################################################################### #steam section ################################################################### @@ -978,7 +1028,7 @@ ReplaceNicks=[ ["user--","user"] ] RemoteNickFormat="[{PROTOCOL}] <{NICK}> " #Enable to show users joins/parts from other bridges -#Only works hiding/show messages from irc and mattermost bridge for now +#Currently works for messages from the following bridges: irc, mattermost, slack #OPTIONAL (default false) ShowJoinPart=false @@ -987,6 +1037,11 @@ ShowJoinPart=false #OPTIONAL (default false) StripNick=false +#Enable to show topic changes from other bridges +#Only works hiding/show topic changes from slack bridge for now +#OPTIONAL (default false) +ShowTopicChange=false + ################################################################### #API ###################################################################