fix config + use lib muc history setting

This commit is contained in:
Martin/Geno 2019-06-27 14:30:11 +02:00
parent 33119f4e39
commit eb585cd195
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
3 changed files with 10 additions and 8 deletions

View File

@ -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]]

View File

@ -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]

View File

@ -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)},
}},
})