Reconnect on quit. (irc) See #431 (#445)

* potential fixes for #431
* go: fix formatting/gofmt/goreturns
This commit is contained in:
Liam Stanley 2018-06-09 06:47:40 -04:00 committed by Wim
parent 33bd60528b
commit 51327a4056
15 changed files with 69 additions and 54 deletions

View File

@ -2,14 +2,15 @@ package api
import (
"encoding/json"
"net/http"
"sync"
"time"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
"github.com/zfjagann/golang-ring"
"net/http"
"sync"
"time"
)
type Api struct {

View File

@ -3,13 +3,14 @@ package bdiscord
import (
"bytes"
"fmt"
"regexp"
"strings"
"sync"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
"github.com/bwmarrin/discordgo"
"regexp"
"strings"
"sync"
)
type Bdiscord struct {

View File

@ -2,11 +2,12 @@ package bgitter
import (
"fmt"
"strings"
"github.com/42wim/go-gitter"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
"strings"
)
type Bgitter struct {

View File

@ -3,12 +3,13 @@ package helper
import (
"bytes"
"fmt"
"github.com/42wim/matterbridge/bridge/config"
log "github.com/sirupsen/logrus"
"io"
"net/http"
"strings"
"time"
"github.com/42wim/matterbridge/bridge/config"
log "github.com/sirupsen/logrus"
)
func DownloadFile(url string) (*[]byte, error) {

View File

@ -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,7 +115,11 @@ func (b *Birc) Connect() error {
go func() {
for {
if err := i.Connect(); err != nil {
b.Log.Errorf("error: %s", err)
b.Log.Errorf("disconnect: error: %s", err)
} else {
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)
@ -123,9 +128,6 @@ func (b *Birc) Connect() error {
// set our correct nick on reconnect if necessary
b.Nick = event.Source.Name
})
} else {
return
}
}
}()
b.i = i

View File

@ -3,14 +3,15 @@ package bmatrix
import (
"bytes"
"fmt"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
matrix "github.com/matterbridge/gomatrix"
"mime"
"regexp"
"strings"
"sync"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
matrix "github.com/matterbridge/gomatrix"
)
type Bmatrix struct {

View File

@ -3,13 +3,14 @@ package bmattermost
import (
"errors"
"fmt"
"strings"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
"github.com/42wim/matterbridge/matterclient"
"github.com/42wim/matterbridge/matterhook"
"github.com/rs/xid"
"strings"
)
type Bmattermost struct {

View File

@ -2,13 +2,14 @@ package bsshchat
import (
"bufio"
"io"
"strings"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
"github.com/shazow/ssh-chat/sshd"
log "github.com/sirupsen/logrus"
"io"
"strings"
)
type Bsshchat struct {

View File

@ -2,8 +2,9 @@ package btelegram
import (
"bytes"
"github.com/russross/blackfriday"
"html"
"github.com/russross/blackfriday"
)
type customHTML struct {

View File

@ -2,14 +2,15 @@ package bxmpp
import (
"crypto/tls"
"strings"
"time"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
"github.com/jpillora/backoff"
"github.com/rs/xid"
"github.com/matterbridge/go-xmpp"
"strings"
"time"
"github.com/rs/xid"
)
type Bxmpp struct {

View File

@ -10,18 +10,18 @@ import (
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/api"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/discord"
"github.com/42wim/matterbridge/bridge/gitter"
"github.com/42wim/matterbridge/bridge/irc"
"github.com/42wim/matterbridge/bridge/matrix"
"github.com/42wim/matterbridge/bridge/mattermost"
"github.com/42wim/matterbridge/bridge/rocketchat"
"github.com/42wim/matterbridge/bridge/slack"
"github.com/42wim/matterbridge/bridge/sshchat"
"github.com/42wim/matterbridge/bridge/steam"
"github.com/42wim/matterbridge/bridge/telegram"
"github.com/42wim/matterbridge/bridge/xmpp"
"github.com/42wim/matterbridge/bridge/zulip"
bdiscord "github.com/42wim/matterbridge/bridge/discord"
bgitter "github.com/42wim/matterbridge/bridge/gitter"
birc "github.com/42wim/matterbridge/bridge/irc"
bmatrix "github.com/42wim/matterbridge/bridge/matrix"
bmattermost "github.com/42wim/matterbridge/bridge/mattermost"
brocketchat "github.com/42wim/matterbridge/bridge/rocketchat"
bslack "github.com/42wim/matterbridge/bridge/slack"
bsshchat "github.com/42wim/matterbridge/bridge/sshchat"
bsteam "github.com/42wim/matterbridge/bridge/steam"
btelegram "github.com/42wim/matterbridge/bridge/telegram"
bxmpp "github.com/42wim/matterbridge/bridge/xmpp"
bzulip "github.com/42wim/matterbridge/bridge/zulip"
"github.com/hashicorp/golang-lru"
log "github.com/sirupsen/logrus"
// "github.com/davecgh/go-spew/spew"

View File

@ -2,9 +2,10 @@ package gateway
import (
"fmt"
"strconv"
"github.com/42wim/matterbridge/bridge/config"
"github.com/stretchr/testify/assert"
"strconv"
"testing"
)

View File

@ -2,9 +2,10 @@ package gateway
import (
"fmt"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/gateway/samechannel"
samechannelgateway "github.com/42wim/matterbridge/gateway/samechannel"
// "github.com/davecgh/go-spew/spew"
"time"
)

View File

@ -2,6 +2,7 @@ package samechannelgateway
import (
"fmt"
"github.com/42wim/matterbridge/bridge/config"
"github.com/BurntSushi/toml"
"github.com/stretchr/testify/assert"

View File

@ -6,14 +6,15 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"github.com/gorilla/schema"
"github.com/nlopes/slack"
"io"
"io/ioutil"
"log"
"net"
"net/http"
"time"
"github.com/gorilla/schema"
"github.com/nlopes/slack"
)
// OMessage for mattermost incoming webhook. (send to mattermost)