Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 4f6161a396788c7356837789aa1ab75f79aa003d Author: Wim <wim@42.be> Date: Fri Feb 02 21:04:43 2018 +0000 Add ShowTopicChange option. Allow/disable topic change messages (currently only from slack). Closes #353 diff --git a/bridge/config/config.go b/bridge/config/config.go index af3bf03..fdb6e55 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -116 +117 @@ 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" @@ -886 +897 @@ 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 421cc6a..f700156 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -2846 +2849 @@ 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 6e32768..93e5b5b 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -1816 +1819 @@ 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 fea60c1..e0589fc 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -1267 +1267 @@ 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   @@ -1356 +13511 @@ 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  ################################################################### @@ -2057 +2107 @@ 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   @@ -2146 +21911 @@ 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  ################################################################### @@ -2767 +2867 @@ 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   @@ -2856 +29511 @@ 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  ################################################################### @@ -4077 +4227 @@ 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   @@ -4166 +43111 @@ 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. @@ -4687 +4887 @@ 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   @@ -4776 +49711 @@ 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  ################################################################### @@ -5767 +6017 @@ 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   @@ -5856 +61011 @@ 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  ################################################################### @@ -6617 +6917 @@ 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   @@ -6706 +70011 @@ 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  ################################################################### @@ -7457 +7807 @@ 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   @@ -7546 +78911 @@ 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  ################################################################### @@ -8307 +8707 @@ 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   @@ -8396 +87911 @@ 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  ################################################################### @@ -9077 +9527 @@ 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   @@ -9166 +96111 @@ 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  ################################################################### @@ -9787 +10287 @@ 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   @@ -9876 +103711 @@ 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  ###################################################################