diff options
author | Alex Auvolat <alex@adnab.me> | 2020-05-04 18:36:55 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-05-04 18:36:55 +0200 |
commit | aa6c5628e9b48303826ee0fa5fbb826e2c6cf54f (patch) | |
tree | 22ac40893f06ce91f0755844a4e70197925a5da5 /connector | |
parent | 1d54a50c31cb788bf786397ea5664bd02bfe36fb (diff) | |
download | easybridge-aa6c5628e9b48303826ee0fa5fbb826e2c6cf54f.tar.gz easybridge-aa6c5628e9b48303826ee0fa5fbb826e2c6cf54f.zip |
Notify user of stuff going on in backends (not done for FB Messenger)
Diffstat (limited to 'connector')
-rw-r--r-- | connector/connector.go | 3 | ||||
-rw-r--r-- | connector/irc/irc.go | 5 | ||||
-rw-r--r-- | connector/mattermost/mattermost.go | 2 | ||||
-rw-r--r-- | connector/xmpp/xmpp.go | 8 |
4 files changed, 9 insertions, 9 deletions
diff --git a/connector/connector.go b/connector/connector.go index fd49c7e..55e0e34 100644 --- a/connector/connector.go +++ b/connector/connector.go @@ -79,6 +79,9 @@ type Handler interface { // Called to save updated configuration parameters SaveConfig(config Configuration) + // Called to notify user of stuff going on + SystemMessage(message string) + // Called when a room was joined (automatically or by call to Connector.Join) Joined(roomId RoomID) diff --git a/connector/irc/irc.go b/connector/irc/irc.go index cf93893..bee2bca 100644 --- a/connector/irc/irc.go +++ b/connector/irc/irc.go @@ -270,8 +270,7 @@ func (irc *IRC) connectLoop(c *girc.Client) { } if err := c.Connect(); err != nil { irc.connected = false - fmt.Printf("IRC failed to connect / disconnected: %s\n", err) - fmt.Printf("Retrying in %ds\n", irc.timeout) + irc.handler.SystemMessage(fmt.Sprintf("IRC failed to connect / disconnected (%s), reconnecting in %ds", err, irc.timeout)) time.Sleep(time.Duration(irc.timeout) * time.Second) irc.timeout *= 2 if irc.timeout > 600 { @@ -284,7 +283,7 @@ func (irc *IRC) connectLoop(c *girc.Client) { } func (irc *IRC) ircConnected(c *girc.Client, e girc.Event) { - fmt.Printf("ircConnected ^^^^\n") + irc.handler.SystemMessage("Connected to IRC.") irc.timeout = 10 irc.connected = true } diff --git a/connector/mattermost/mattermost.go b/connector/mattermost/mattermost.go index 5ec76d0..c42521f 100644 --- a/connector/mattermost/mattermost.go +++ b/connector/mattermost/mattermost.go @@ -345,7 +345,7 @@ func (mm *Mattermost) Close() { } func (mm *Mattermost) handleConnected() { - log.Debugf("(Re-)connected to mattermost: %s@%s ; doing channel sync\n", mm.username, mm.server) + mm.handler.SystemMessage(fmt.Sprintf("(Re-)connected to mattermost (%s@%s), doing channel sync", mm.username, mm.server)) // Initial channel sync chans := mm.conn.GetChannels() diff --git a/connector/xmpp/xmpp.go b/connector/xmpp/xmpp.go index a25a31b..64c53d9 100644 --- a/connector/xmpp/xmpp.go +++ b/connector/xmpp/xmpp.go @@ -124,8 +124,7 @@ func (xm *XMPP) connectLoop(num int) { xm.conn, err = options.NewClient() if err != nil { xm.connected = false - log.Debugf("XMPP failed to connect / disconnected: %s\n", err) - log.Debugf("Retrying in %ds\n", xm.timeout) + xm.handler.SystemMessage(fmt.Sprintf("XMPP failed to connect (%s). Retrying in %ds", err, xm.timeout)) time.Sleep(time.Duration(xm.timeout) * time.Second) xm.timeout *= 2 if xm.timeout > 600 { @@ -139,7 +138,7 @@ func (xm *XMPP) connectLoop(num int) { if joined { _, err := xm.conn.JoinMUCNoHistory(muc, xm.nickname) if err != nil { - log.Warnf("Could not rejoin MUC %s after reconnection: %s", muc, err) + xm.handler.SystemMessage(fmt.Sprintf("Could not rejoin MUC %s after reconnection: %s", muc, err)) xm.handler.Left(RoomID(muc)) delete(xm.joinedMUC, muc) } @@ -149,8 +148,7 @@ func (xm *XMPP) connectLoop(num int) { err = xm.handleXMPP() xm.connected = false - log.Debugf("XMPP disconnected: %s\n", err) - log.Debugf("Reconnecting.\n") + xm.handler.SystemMessage(fmt.Sprintf("XMPP disconnected (%s), reconnecting)", err)) } } } |