summaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authorWim <wim@42.be>2016-11-14 22:53:06 +0100
committerWim <wim@42.be>2016-11-14 22:53:06 +0100
commit449ed31e25f2c21ac9db258999a5a893889983eb (patch)
treefea6132df575adc0b6318475eaea5fc3e4f17ab6 /bridge
parent1f3690458885ada309be4737e4afb7bb5ecc7ad5 (diff)
downloadmatterbridge-msglm-449ed31e25f2c21ac9db258999a5a893889983eb.tar.gz
matterbridge-msglm-449ed31e25f2c21ac9db258999a5a893889983eb.tar.bz2
matterbridge-msglm-449ed31e25f2c21ac9db258999a5a893889983eb.zip
Fix ShowJoinPart from irc bridge. Closes #72
Diffstat (limited to 'bridge')
-rw-r--r--bridge/config/config.go5
-rw-r--r--bridge/irc/irc.go13
2 files changed, 18 insertions, 0 deletions
diff --git a/bridge/config/config.go b/bridge/config/config.go
index c577e340..d3d88115 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -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 {
diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go
index d6b6c5f6..1540c56f 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -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)