5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-09 15:40:27 +00:00

Fix ShowJoinPart from irc bridge. Closes #72

This commit is contained in:
Wim 2016-11-14 22:53:06 +01:00
parent 1f36904588
commit 449ed31e25
5 changed files with 120 additions and 52 deletions

View File

@ -8,12 +8,17 @@ import (
"strings"
)
const (
EVENT_JOIN_LEAVE = "join_leave"
)
type Message struct {
Text string
Channel string
Username string
Avatar string
Account string
Event string
}
type Protocol struct {

View File

@ -156,11 +156,24 @@ func (b *Birc) handleNewConnection(event *irc.Event) {
i.SendRaw("PONG :" + e.Message())
flog.Debugf("PING/PONG")
})
i.AddCallback("JOIN", b.handleJoinPart)
i.AddCallback("PART", b.handleJoinPart)
i.AddCallback("QUIT", b.handleJoinPart)
i.AddCallback("*", b.handleOther)
// we are now fully connected
b.connected <- struct{}{}
}
func (b *Birc) handleJoinPart(event *irc.Event) {
flog.Debugf("Sending JOIN_LEAVE event from %s to gateway", b.Account)
channel := event.Arguments[0]
if event.Code == "QUIT" {
channel = ""
}
b.Remote <- config.Message{Username: "system", Text: event.Nick + " " + strings.ToLower(event.Code) + "s", Channel: channel, Account: b.Account, Event: config.EVENT_JOIN_LEAVE}
flog.Debugf("handle %#v", event)
}
func (b *Birc) handleNotice(event *irc.Event) {
if strings.Contains(event.Message(), "This nickname is registered") && event.Nick == b.Config.NickServNick {
b.i.Privmsg(b.Config.NickServNick, "IDENTIFY "+b.Config.NickServPassword)

View File

@ -1,9 +1,17 @@
# v0.8
# v0.9.0-dev
## General
* discord: add "Bot " tag to discord tokens automatically
## Bugfix
* general: fix ShowJoinPart for messages from irc bridge #72
* irc: fix !users command #78
# v0.8.0
Release because of breaking mattermost API changes
## New features
* Supports mattermost v3.5.0
# v0.7
# v0.7.0
## Breaking config changes from 0.6 to 0.7
Matterbridge now uses TOML configuration (https://github.com/toml-lang/toml)
See matterbridge.toml.sample for an example

View File

@ -106,6 +106,10 @@ func (gw *Gateway) mapIgnores() {
func (gw *Gateway) getDestChannel(msg *config.Message, dest string) []string {
channels := gw.ChannelsIn[msg.Account]
// broadcast to every out channel (irc QUIT)
if msg.Event == config.EVENT_JOIN_LEAVE && msg.Channel == "" {
return gw.ChannelsOut[dest]
}
for _, channel := range channels {
if channel == msg.Channel {
return gw.ChannelsOut[dest]
@ -118,6 +122,10 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) {
if gw.ignoreMessage(&msg) {
return
}
// only relay join/part when configged
if msg.Event == config.EVENT_JOIN_LEAVE && !gw.Bridges[dest.Account].Config.ShowJoinPart {
return
}
originchannel := msg.Channel
channels := gw.getDestChannel(&msg, dest.Account)
for _, channel := range channels {

View File

@ -37,18 +37,6 @@ Nick="matterbot"
NickServNick="nickserv"
NickServPassword="secret"
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
#The string "{PROTOCOL}" (case sensitive) will be replaced by the protocol used by the bridge
#OPTIONAL (default empty)
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#Nicks you want to ignore.
#Messages from those users will not be sent to other bridges.
#OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2"
#Flood control
#Delay in milliseconds between each message send to the IRC server
#OPTIONAL (default 1300)
@ -60,6 +48,22 @@ MessageDelay=1300
#OPTIONAL (default 30)
MessageQueue=30
#Nicks you want to ignore.
#Messages from those users will not be sent to other bridges.
#OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2"
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
#The string "{PROTOCOL}" (case sensitive) will be replaced by the protocol used by the bridge
#OPTIONAL (default empty)
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#Enable to show users joins/parts from other bridges (only from irc-bridge at the moment)
#OPTIONAL (default false)
ShowJoinPart=false
###################################################################
#XMPP section
###################################################################
@ -89,6 +93,21 @@ Muc="conference.jabber.example.com"
#REQUIRED
Nick="xmppbot"
#Nicks you want to ignore.
#Messages from those users will not be sent to other bridges.
#OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2"
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
#The string "{PROTOCOL}" (case sensitive) will be replaced by the protocol used by the bridge
#OPTIONAL (default empty)
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#Enable to show users joins/parts from other bridges (only from irc-bridge at the moment)
#OPTIONAL (default false)
ShowJoinPart=false
###################################################################
#mattermost section
@ -150,9 +169,13 @@ NoTLS=false
#OPTIONAL (default false)
SkipTLSVerify=true
#Enable to show IRC joins/parts in mattermost.
#OPTIONAL (default false)
ShowJoinPart=false
#how to format the list of IRC nicks when displayed in mattermost.
#Possible options are "table" and "plain"
#OPTIONAL (default plain)
NickFormatter="plain"
#How many nicks to list per row for formatters that support this.
#OPTIONAL (default 4)
NicksPerRow=4
#Whether to prefix messages from other bridges to mattermost with the sender's nick.
#Useful if username overrides for incoming webhooks isn't enabled on the
@ -162,6 +185,11 @@ ShowJoinPart=false
#OPTIONAL (default false)
PrefixMessagesWithNick=false
#Nicks you want to ignore.
#Messages from those users will not be sent to other bridges.
#OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2"
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@ -169,17 +197,9 @@ PrefixMessagesWithNick=false
#OPTIONAL (default empty)
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#how to format the list of IRC nicks when displayed in mattermost.
#Possible options are "table" and "plain"
#OPTIONAL (default plain)
NickFormatter="plain"
#How many nicks to list per row for formatters that support this.
#OPTIONAL (default 4)
NicksPerRow=4
#Nicks you want to ignore. Messages from those users will not be bridged.
#OPTIONAL
IgnoreNicks="mmbot spammer2"
#Enable to show users joins/parts from other bridges (only from irc-bridge at the moment)
#OPTIONAL (default false)
ShowJoinPart=false
###################################################################
#Gitter section
@ -197,9 +217,10 @@ IgnoreNicks="mmbot spammer2"
#REQUIRED
Token="Yourtokenhere"
#Nicks you want to ignore. Messages of those users will not be bridged.
#Nicks you want to ignore.
#Messages from those users will not be sent to other bridges.
#OPTIONAL
IgnoreNicks="spammer1 spammer2"
IgnoreNicks="ircspammer1 ircspammer2"
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
@ -208,6 +229,10 @@ 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)
#OPTIONAL (default false)
ShowJoinPart=false
###################################################################
#slack section
###################################################################
@ -251,21 +276,6 @@ Token="yourslacktoken"
#OPTIONAL
IconURL="https://robohash.org/{NICK}.png?size=48x48"
#Whether to prefix messages from other bridges to mattermost with RemoteNickFormat
#Useful if username overrides for incoming webhooks isn't enabled on the
#slack server. If you set PrefixMessagesWithNick to true, each message
#from bridge to Slack will by default be prefixed by "bridge-" + nick. You can,
#however, modify how the messages appear, by setting (and modifying) RemoteNickFormat
#OPTIONAL (default false)
PrefixMessagesWithNick=false
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
#The string "{PROTOCOL}" (case sensitive) will be replaced by the protocol used by the bridge
#OPTIONAL (default empty)
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#how to format the list of IRC nicks when displayed in slack
#Possible options are "table" and "plain"
#OPTIONAL (default plain)
@ -274,9 +284,29 @@ NickFormatter="plain"
#OPTIONAL (default 4)
NicksPerRow=4
#Nicks you want to ignore. Messages from those users will not be bridged.
#Whether to prefix messages from other bridges to mattermost with RemoteNickFormat
#Useful if username overrides for incoming webhooks isn't enabled on the
#slack server. If you set PrefixMessagesWithNick to true, each message
#from bridge to Slack will by default be prefixed by "bridge-" + nick. You can,
#however, modify how the messages appear, by setting (and modifying) RemoteNickFormat
#OPTIONAL (default false)
PrefixMessagesWithNick=false
#Nicks you want to ignore.
#Messages from those users will not be sent to other bridges.
#OPTIONAL
IgnoreNicks="mmbot spammer2"
IgnoreNicks="ircspammer1 ircspammer2"
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
#The string "{PROTOCOL}" (case sensitive) will be replaced by the protocol used by the bridge
#OPTIONAL (default empty)
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
#Enable to show users joins/parts from other bridges (only from irc-bridge at the moment)
#OPTIONAL (default false)
ShowJoinPart=false
###################################################################
#discord section
@ -296,9 +326,10 @@ Token="Yourtokenhere"
#REQUIRED
Server="yourservername"
#Nicks you want to ignore. Messages of those users will not be bridged.
#Nicks you want to ignore.
#Messages from those users will not be sent to other bridges.
#OPTIONAL
IgnoreNicks="spammer1 spammer2"
IgnoreNicks="ircspammer1 ircspammer2"
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
@ -307,6 +338,9 @@ 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)
#OPTIONAL (default false)
ShowJoinPart=false
###################################################################
#Gateway configuration