fix config + use lib muc history setting
This commit is contained in:
parent
33119f4e39
commit
eb585cd195
|
@ -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]]
|
||||
|
|
8
main.go
8
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]
|
||||
|
|
3
xmpp.go
3
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)},
|
||||
}},
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue