| 81 | } |
| 82 | |
| 83 | func (b *Birc) handleJoinPart(client *girc.Client, event girc.Event) { |
| 84 | if len(event.Params) == 0 { |
| 85 | b.Log.Debugf("handleJoinPart: empty Params? %#v", event) |
| 86 | return |
| 87 | } |
| 88 | channel := strings.ToLower(event.Params[0]) |
| 89 | if event.Command == "KICK" && event.Params[1] == b.Nick { |
| 90 | b.Log.Infof("Got kicked from %s by %s", channel, event.Source.Name) |
| 91 | time.Sleep(time.Duration(b.GetInt("RejoinDelay")) * time.Second) |
| 92 | b.Remote <- config.Message{Username: "system", Text: "rejoin", Channel: channel, Account: b.Account, Event: config.EventRejoinChannels} |
| 93 | return |
| 94 | } |
| 95 | if event.Command == "QUIT" { |
| 96 | if event.Source.Name == b.Nick && strings.Contains(event.Last(), "Ping timeout") { |
| 97 | b.Log.Infof("%s reconnecting ..", b.Account) |
| 98 | b.Remote <- config.Message{Username: "system", Text: "reconnect", Channel: channel, Account: b.Account, Event: config.EventFailure} |
| 99 | return |
| 100 | } |
| 101 | } |
| 102 | if event.Source.Name != b.Nick { |
| 103 | if b.GetBool("nosendjoinpart") { |
| 104 | return |
| 105 | } |
| 106 | msg := config.Message{Username: "system", Text: event.Source.Name + " " + strings.ToLower(event.Command) + "s", Channel: channel, Account: b.Account, Event: config.EventJoinLeave} |
| 107 | if b.GetBool("verbosejoinpart") { |
| 108 | b.Log.Debugf("<= Sending verbose JOIN_LEAVE event from %s to gateway", b.Account) |
| 109 | msg = config.Message{Username: "system", Text: event.Source.Name + " (" + event.Source.Ident + "@" + event.Source.Host + ") " + strings.ToLower(event.Command) + "s", Channel: channel, Account: b.Account, Event: config.EventJoinLeave} |
| 110 | } else { |
| 111 | b.Log.Debugf("<= Sending JOIN_LEAVE event from %s to gateway", b.Account) |
| 112 | } |
| 113 | b.Log.Debugf("<= Message is %#v", msg) |
| 114 | b.Remote <- msg |
| 115 | return |
| 116 | } |
| 117 | b.Log.Debugf("handle %#v", event) |
| 118 | } |
| 119 | |
| 120 | func (b *Birc) handleNewConnection(client *girc.Client, event girc.Event) { |
| 121 | b.Log.Debug("Registering callbacks") |