Thumbnail

rani/matterbridge.git

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

commit ad2cd2f728f302bc8a9fd2696a329cffbd5259d7 Author: Wim <wim@42.be> Date: Fri Apr 07 22:27:36 2017 +0000 Add support for showing/hiding join/leave messages from mattermost. Closes #147 diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index dec8fcb..439ce9c 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -1316 +13114 @@ func (b *Bmattermost) handleMatter() {    func (b *Bmattermost) handleMatterClient(mchan chan *MMMessage) {   for message := range b.mc.MessageChan { + flog.Debugf("%#v", message.Raw.Data) + if message.Type == "system_join_leave" || + message.Type == "system_join_channel" || + message.Type == "system_leave_channel" { + flog.Debugf("Sending JOIN_LEAVE event from %s to gateway", b.Account) + b.Remote <- config.Message{Username: "system", Text: message.Text, Channel: message.Channel, Account: b.Account, Event: config.EVENT_JOIN_LEAVE} + continue + }   // do not post our own messages back to irc   // only listen to message from our team   if message.Raw.Event == "posted" && b.mc.User.Username != message.Username && message.Raw.Data["team_id"].(string) == b.TeamId { diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index 40fccea..d1dc0f4 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -647 +648 @@ IgnoreNicks="ircspammer1 ircspammer2"  #OPTIONAL (default empty)  RemoteNickFormat="[{PROTOCOL}] <{NICK}> "   -#Enable to show users joins/parts from other bridges (only from irc-bridge at the moment) +#Enable to show users joins/parts from other bridges +#Only works hiding/show messages from irc and mattermost bridge for now  #OPTIONAL (default false)  ShowJoinPart=false   @@ -1147 +1158 @@ IgnoreNicks="ircspammer1 ircspammer2"  #OPTIONAL (default empty)  RemoteNickFormat="[{PROTOCOL}] <{NICK}> "   -#Enable to show users joins/parts from other bridges (only from irc-bridge at the moment) +#Enable to show users joins/parts from other bridges +#Only works hiding/show messages from irc and mattermost bridge for now  #OPTIONAL (default false)  ShowJoinPart=false   @@ -1577 +1598 @@ IgnoreNicks="spammer1 spammer2"  #OPTIONAL (default empty)  RemoteNickFormat="[{PROTOCOL}/{BRIDGE}] <{NICK}> "   -#Enable to show users joins/parts from other bridges (only from irc-bridge at the moment) +#Enable to show users joins/parts from other bridges +#Only works hiding/show messages from irc and mattermost bridge for now  #OPTIONAL (default false)  ShowJoinPart=false   @@ -2507 +2538 @@ IgnoreNicks="ircspammer1 ircspammer2"  #OPTIONAL (default empty)  RemoteNickFormat="[{PROTOCOL}] <{NICK}> "   -#Enable to show users joins/parts from other bridges (only from irc-bridge at the moment) +#Enable to show users joins/parts from other bridges +#Only works hiding/show messages from irc and mattermost bridge for now  #OPTIONAL (default false)  ShowJoinPart=false   @@ -2827 +2868 @@ IgnoreNicks="ircspammer1 ircspammer2"  #OPTIONAL (default empty)  RemoteNickFormat="[{PROTOCOL}] <{NICK}> "   -#Enable to show users joins/parts from other bridges (only from irc-bridge at the moment) +#Enable to show users joins/parts from other bridges +#Only works hiding/show messages from irc and mattermost bridge for now  #OPTIONAL (default false)  ShowJoinPart=false   @@ -3627 +3678 @@ IgnoreNicks="ircspammer1 ircspammer2"  #OPTIONAL (default empty)  RemoteNickFormat="[{PROTOCOL}] <{NICK}> "   -#Enable to show users joins/parts from other bridges (only from irc-bridge at the moment) +#Enable to show users joins/parts from other bridges +#Only works hiding/show messages from irc and mattermost bridge for now  #OPTIONAL (default false)  ShowJoinPart=false   @@ -3977 +4038 @@ IgnoreNicks="ircspammer1 ircspammer2"  #OPTIONAL (default empty)  RemoteNickFormat="[{PROTOCOL}] <{NICK}> "   -#Enable to show users joins/parts from other bridges (only from irc-bridge at the moment) +#Enable to show users joins/parts from other bridges +#Only works hiding/show messages from irc and mattermost bridge for now  #OPTIONAL (default false)  ShowJoinPart=false   @@ -4327 +4398 @@ IgnoreNicks="spammer1 spammer2"  #OPTIONAL (default empty)  RemoteNickFormat="[{PROTOCOL}] <{NICK}> "   -#Enable to show users joins/parts from other bridges (only from irc-bridge at the moment) +#Enable to show users joins/parts from other bridges +#Only works hiding/show messages from irc and mattermost bridge for now  #OPTIONAL (default false)  ShowJoinPart=false   @@ -4897 +4978 @@ IgnoreNicks="ircspammer1 ircspammer2"  #OPTIONAL (default empty)  RemoteNickFormat="[{PROTOCOL}] <{NICK}> "   -#Enable to show users joins/parts from other bridges (only from irc-bridge at the moment) +#Enable to show users joins/parts from other bridges +#Only works hiding/show messages from irc and mattermost bridge for now  #OPTIONAL (default false)  ShowJoinPart=false   @@ -5327 +5418 @@ IgnoreNicks="spammer1 spammer2"  #OPTIONAL (default empty)  RemoteNickFormat="[{PROTOCOL}] <{NICK}> "   -#Enable to show users joins/parts from other bridges (only from irc-bridge at the moment) +#Enable to show users joins/parts from other bridges +#Only works hiding/show messages from irc and mattermost bridge for now  #OPTIONAL (default false)  ShowJoinPart=false   diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go index beae807..d2bfbae 100644 --- a/matterclient/matterclient.go +++ b/matterclient/matterclient.go @@ -346 +347 @@ type Message struct {   Channel string   Username string   Text string + Type string  }    type Team struct { @@ -2666 +2677 @@ func (m *MMClient) parseActionPost(rmsg *Message) {   }   rmsg.Username = m.GetUser(data.UserId).Username   rmsg.Channel = m.GetChannelName(data.ChannelId) + rmsg.Type = data.Type   rmsg.Team = m.GetTeamName(rmsg.Raw.Data["team_id"].(string))   // direct message   if rmsg.Raw.Data["channel_type"] == "D" {