diff --git a/output/xmpp/main.go b/output/xmpp/main.go index 903015c..8503440 100644 --- a/output/xmpp/main.go +++ b/output/xmpp/main.go @@ -65,6 +65,8 @@ func Init(configInterface interface{}, db *database.DB, bot *bot.Bot) output.Out return nil } cm := xmpp.NewStreamManager(client, func(c xmpp.Sender) { + out.client = c + for to, muc := range config.Defaults { def := &database.Notify{ Protocol: proto, @@ -84,7 +86,6 @@ func Init(configInterface interface{}, db *database.DB, bot *bot.Bot) output.Out } } logger.Info("join muc after connect") - out.client = c }) go func() { cm.Run() diff --git a/output/xmpp/send.go b/output/xmpp/send.go index 9c15a8b..17a673c 100644 --- a/output/xmpp/send.go +++ b/output/xmpp/send.go @@ -31,6 +31,10 @@ func (out *Output) Join(to string) { } func (out *Output) Send(e *log.Entry, to *database.Notify) bool { + if out.client == nil { + logger.Error("xmpp not connected (yet)") + return false + } html, text := formatLog(e) if html == "" || text == "" { logger.Error("during format notify")