From eb585cd19570c8e42a0e78e3b7b47bc33dd8005e Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Thu, 27 Jun 2019 14:30:11 +0200 Subject: [PATCH] fix config + use lib muc history setting --- config_example.toml | 7 +++++-- main.go | 8 ++++---- xmpp.go | 3 +-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/config_example.toml b/config_example.toml index b8d1d22..e2ddfba 100644 --- a/config_example.toml +++ b/config_example.toml @@ -1,12 +1,15 @@ log_level = 50 webserver_bind = ":8080" +startup_notify_user = ["user@fireorbit.de"] +startup_notify_muc = [] + +nickname = "logbot" + [xmpp] address = "fireorbit.de" jid = "bot@fireorbit.de" password = "example" -startup_notify_user = ["user@fireorbit.de"] -startup_notify_muc = [] # suported hooks are, which could be declared multiple times with different `secrets` (see [[hooks.grafana]]): [[hooks.grafana]] diff --git a/main.go b/main.go index 5385e37..170f87f 100644 --- a/main.go +++ b/main.go @@ -19,14 +19,14 @@ import ( "dev.sum7.eu/genofire/hook2xmpp/runtime" ) -var config *runtime.Config +var config = runtime.Config{} func main() { configFile := "config.conf" flag.StringVar(&configFile, "config", configFile, "path of configuration file") flag.Parse() - if err := file.ReadTOML(configFile, config); err != nil { + if err := file.ReadTOML(configFile, &config); err != nil { log.WithField("tip", "maybe call me with: hook2xmpp--config /etc/hook2xmpp.conf").Panicf("error on read config: %s", err) } @@ -45,8 +45,8 @@ func main() { cm := xmpp.NewStreamManager(client, postStartup) go func() { - cm.Run() - log.Panic("closed connection") + err := cm.Run() + log.Panic("closed connection:", err) }() for hookType, getHandler := range runtime.HookRegister { hooks, ok := config.Hooks[hookType] diff --git a/xmpp.go b/xmpp.go index e964bdb..34c3545 100644 --- a/xmpp.go +++ b/xmpp.go @@ -29,7 +29,6 @@ func notify(text string) { func joinMUC(to, nick string) error { - maxstanzas := 0 toJID, err := xmpp.NewJid(to) if err != nil { return err @@ -42,7 +41,7 @@ func joinMUC(to, nick string) error { return client.Send(xmpp.Presence{Attrs: xmpp.Attrs{To: jid}, Extensions: []xmpp.PresExtension{ xmpp.MucPresence{ - History: xmpp.History{MaxStanzas: &maxstanzas}, + History: xmpp.History{MaxStanzas: xmpp.NewNullableInt(0)}, }}, })