fix config + use lib muc history setting
This commit is contained in:
parent
33119f4e39
commit
eb585cd195
|
@ -1,12 +1,15 @@
|
||||||
log_level = 50
|
log_level = 50
|
||||||
webserver_bind = ":8080"
|
webserver_bind = ":8080"
|
||||||
|
|
||||||
|
startup_notify_user = ["user@fireorbit.de"]
|
||||||
|
startup_notify_muc = []
|
||||||
|
|
||||||
|
nickname = "logbot"
|
||||||
|
|
||||||
[xmpp]
|
[xmpp]
|
||||||
address = "fireorbit.de"
|
address = "fireorbit.de"
|
||||||
jid = "bot@fireorbit.de"
|
jid = "bot@fireorbit.de"
|
||||||
password = "example"
|
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]]):
|
# suported hooks are, which could be declared multiple times with different `secrets` (see [[hooks.grafana]]):
|
||||||
[[hooks.grafana]]
|
[[hooks.grafana]]
|
||||||
|
|
8
main.go
8
main.go
|
@ -19,14 +19,14 @@ import (
|
||||||
"dev.sum7.eu/genofire/hook2xmpp/runtime"
|
"dev.sum7.eu/genofire/hook2xmpp/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
var config *runtime.Config
|
var config = runtime.Config{}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
configFile := "config.conf"
|
configFile := "config.conf"
|
||||||
flag.StringVar(&configFile, "config", configFile, "path of configuration file")
|
flag.StringVar(&configFile, "config", configFile, "path of configuration file")
|
||||||
flag.Parse()
|
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)
|
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)
|
cm := xmpp.NewStreamManager(client, postStartup)
|
||||||
go func() {
|
go func() {
|
||||||
cm.Run()
|
err := cm.Run()
|
||||||
log.Panic("closed connection")
|
log.Panic("closed connection:", err)
|
||||||
}()
|
}()
|
||||||
for hookType, getHandler := range runtime.HookRegister {
|
for hookType, getHandler := range runtime.HookRegister {
|
||||||
hooks, ok := config.Hooks[hookType]
|
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 {
|
func joinMUC(to, nick string) error {
|
||||||
|
|
||||||
maxstanzas := 0
|
|
||||||
toJID, err := xmpp.NewJid(to)
|
toJID, err := xmpp.NewJid(to)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -42,7 +41,7 @@ func joinMUC(to, nick string) error {
|
||||||
return client.Send(xmpp.Presence{Attrs: xmpp.Attrs{To: jid},
|
return client.Send(xmpp.Presence{Attrs: xmpp.Attrs{To: jid},
|
||||||
Extensions: []xmpp.PresExtension{
|
Extensions: []xmpp.PresExtension{
|
||||||
xmpp.MucPresence{
|
xmpp.MucPresence{
|
||||||
History: xmpp.History{MaxStanzas: &maxstanzas},
|
History: xmpp.History{MaxStanzas: xmpp.NewNullableInt(0)},
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue