diff options
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/config/config.go | 5 | ||||
-rw-r--r-- | bridge/irc/irc.go | 13 |
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) |