diff options
-rw-r--r-- | account.go | 6 | ||||
-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 |
5 files changed, 14 insertions, 10 deletions
@@ -182,7 +182,7 @@ func LoadDbAccounts(mxid string, key *[32]byte) { func (a *Account) ezbrMessagef(format string, args ...interface{}) { msg := fmt.Sprintf(format, args...) - msg = fmt.Sprintf("%s: %s", a.Protocol, msg) + msg = fmt.Sprintf("%s %s: %s", a.Protocol, a.AccountName, msg) ezbrSystemSend(a.MatrixUser, msg) } @@ -231,6 +231,10 @@ func (a *Account) delAutojoin(roomId RoomID) { // ---- Begin event handlers ---- +func (a *Account) SystemMessage(msg string) { + a.ezbrMessagef("%s", msg) +} + func (a *Account) SaveConfig(config Configuration) { a.Config = config if key, ok := userKeys[a.MatrixUser]; ok { 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)) } } } |