summaryrefslogtreecommitdiffstats
path: root/bridge/irc
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-02-17 22:12:53 +0100
committerWim <wim@42.be>2017-02-17 22:12:53 +0100
commit7558a2162e79ffa29b11881fe249ec836a8c8b3d (patch)
treec64a7e3898d7ac9e49523ed9c0b2a4eaac492886 /bridge/irc
parentfe258e1b6752f2751d7aec742a4ee20a5594dcdb (diff)
parent62b165c0b4052f96ab89c358301bf246d239eba7 (diff)
downloadmatterbridge-msglm-7558a2162e79ffa29b11881fe249ec836a8c8b3d.tar.gz
matterbridge-msglm-7558a2162e79ffa29b11881fe249ec836a8c8b3d.tar.bz2
matterbridge-msglm-7558a2162e79ffa29b11881fe249ec836a8c8b3d.zip
Merge branch 'status'
Diffstat (limited to 'bridge/irc')
-rw-r--r--bridge/irc/irc.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go
index fe8dc741..db430800 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -46,7 +46,6 @@ func New(cfg config.Protocol, account string, c chan config.Message) *Birc {
if b.Config.MessageQueue == 0 {
b.Config.MessageQueue = 30
}
- b.Local = make(chan config.Message, b.Config.MessageQueue+10)
return b
}
@@ -61,6 +60,7 @@ func (b *Birc) Command(msg *config.Message) string {
}
func (b *Birc) Connect() error {
+ b.Local = make(chan config.Message, b.Config.MessageQueue+10)
flog.Infof("Connecting %s", b.Config.Server)
i := irc.IRC(b.Config.Nick, b.Config.Nick)
if log.GetLevel() == log.DebugLevel {
@@ -91,6 +91,12 @@ func (b *Birc) Connect() error {
return nil
}
+func (b *Birc) Disconnect() error {
+ b.i.Disconnect()
+ close(b.Local)
+ return nil
+}
+
func (b *Birc) JoinChannel(channel string) error {
b.i.Join(channel)
return nil
@@ -170,7 +176,11 @@ 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 = ""
+ if event.Nick == b.Nick && strings.Contains(event.Raw, "Ping timeout") {
+ flog.Infof("%s reconnecting ..", b.Account)
+ b.Remote <- config.Message{Username: "system", Text: "reconnect", Channel: channel, Account: b.Account, Event: config.EVENT_FAILURE}
+ return
+ }
}
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)