summaryrefslogtreecommitdiffstats
path: root/bridge/irc
diff options
context:
space:
mode:
authorLiam Stanley <me@liamstanley.io>2018-06-09 06:47:40 -0400
committerWim <wim@42.be>2018-06-09 12:47:40 +0200
commit51327a405651442ac47c4ce75363442fa323b592 (patch)
tree4011309b5c748f7e5e717a5a7fc62a4026c6f421 /bridge/irc
parent33bd60528be4eaf28ffd1065517ea41fde9ea62b (diff)
downloadmatterbridge-msglm-51327a405651442ac47c4ce75363442fa323b592.tar.gz
matterbridge-msglm-51327a405651442ac47c4ce75363442fa323b592.tar.bz2
matterbridge-msglm-51327a405651442ac47c4ce75363442fa323b592.zip
Reconnect on quit. (irc) See #431 (#445)
* potential fixes for #431 * go: fix formatting/gofmt/goreturns
Diffstat (limited to 'bridge/irc')
-rw-r--r--bridge/irc/irc.go38
1 files changed, 20 insertions, 18 deletions
diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go
index 4919c85d..fe1e0d3b 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -4,14 +4,6 @@ import (
"bytes"
"crypto/tls"
"fmt"
- "github.com/42wim/matterbridge/bridge"
- "github.com/42wim/matterbridge/bridge/config"
- "github.com/42wim/matterbridge/bridge/helper"
- "github.com/dfordsoft/golib/ic"
- "github.com/lrstanley/girc"
- "github.com/paulrosania/go-charset/charset"
- _ "github.com/paulrosania/go-charset/data"
- "github.com/saintfish/chardet"
"hash/crc32"
"io"
"io/ioutil"
@@ -22,6 +14,15 @@ import (
"strings"
"time"
"unicode/utf8"
+
+ "github.com/42wim/matterbridge/bridge"
+ "github.com/42wim/matterbridge/bridge/config"
+ "github.com/42wim/matterbridge/bridge/helper"
+ "github.com/dfordsoft/golib/ic"
+ "github.com/lrstanley/girc"
+ "github.com/paulrosania/go-charset/charset"
+ _ "github.com/paulrosania/go-charset/data"
+ "github.com/saintfish/chardet"
)
type Birc struct {
@@ -114,18 +115,19 @@ func (b *Birc) Connect() error {
go func() {
for {
if err := i.Connect(); err != nil {
- b.Log.Errorf("error: %s", err)
- b.Log.Info("reconnecting in 30 seconds...")
- time.Sleep(30 * time.Second)
- i.Handlers.Clear(girc.RPL_WELCOME)
- i.Handlers.Add(girc.RPL_WELCOME, func(client *girc.Client, event girc.Event) {
- b.Remote <- config.Message{Username: "system", Text: "rejoin", Channel: "", Account: b.Account, Event: config.EVENT_REJOIN_CHANNELS}
- // set our correct nick on reconnect if necessary
- b.Nick = event.Source.Name
- })
+ b.Log.Errorf("disconnect: error: %s", err)
} else {
- return
+ b.Log.Info("disconnect: client requested quit")
}
+
+ b.Log.Info("reconnecting in 30 seconds...")
+ time.Sleep(30 * time.Second)
+ i.Handlers.Clear(girc.RPL_WELCOME)
+ i.Handlers.Add(girc.RPL_WELCOME, func(client *girc.Client, event girc.Event) {
+ b.Remote <- config.Message{Username: "system", Text: "rejoin", Channel: "", Account: b.Account, Event: config.EVENT_REJOIN_CHANNELS}
+ // set our correct nick on reconnect if necessary
+ b.Nick = event.Source.Name
+ })
}
}()
b.i = i