grafana/xmpp - try describing
This commit is contained in:
parent
cfd2694693
commit
bcfdc26bb9
|
@ -58,6 +58,7 @@ func init() {
|
||||||
logger = logger.WithFields(map[string]interface{}{
|
logger = logger.WithFields(map[string]interface{}{
|
||||||
"url": request.RuleURL,
|
"url": request.RuleURL,
|
||||||
"msg": request.String(),
|
"msg": request.String(),
|
||||||
|
"image": request.ImageURL,
|
||||||
})
|
})
|
||||||
|
|
||||||
ruleURL, err := url.Parse(request.RuleURL)
|
ruleURL, err := url.Parse(request.RuleURL)
|
||||||
|
@ -72,10 +73,11 @@ func init() {
|
||||||
if ruleURL.Hostname() != hook.URL {
|
if ruleURL.Hostname() != hook.URL {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.Notify(client, hook, request.String())
|
runtime.Notify(client, hook, request.String())
|
||||||
if request.ImageURL != "" {
|
if request.ImageURL != "" {
|
||||||
logger = logger.WithField("image", request.ImageURL)
|
runtime.NotifyImage(client, hook, request.ImageURL, request.String())
|
||||||
runtime.NotifyImage(client, hook, request.ImageURL)
|
}else{
|
||||||
}
|
}
|
||||||
logger.Infof("run hook")
|
logger.Infof("run hook")
|
||||||
ok = true
|
ok = true
|
||||||
|
|
2
main.go
2
main.go
|
@ -87,9 +87,9 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Infof("started hock2xmpp with %s", client.JID())
|
||||||
notify("startup of hock2xmpp")
|
notify("startup of hock2xmpp")
|
||||||
|
|
||||||
log.Infof("started hock2xmpp with %s", client.JID())
|
|
||||||
|
|
||||||
// Wait for system signal
|
// Wait for system signal
|
||||||
sigs := make(chan os.Signal, 1)
|
sigs := make(chan os.Signal, 1)
|
||||||
|
|
|
@ -25,13 +25,14 @@ func Start(client *xmpp.Client) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func NotifyImage(client *xmpp.Client, hook Hook, url string) {
|
func NotifyImage(client *xmpp.Client, hook Hook, url string, desc string) {
|
||||||
msg := fmt.Sprintf(`<message to='%%s' type='%%s'>
|
msg := fmt.Sprintf(`<message to='%%s' type='%%s'>
|
||||||
<body>%s</body>
|
<body>%s</body>
|
||||||
<x xmlns='jabber:x:oob'>
|
<x xmlns='jabber:x:oob'>
|
||||||
<url>%s</url>
|
<url>%s</url>
|
||||||
|
<desc>%s</desc>
|
||||||
</x>
|
</x>
|
||||||
</message>`, url, url)
|
</message>`, url, url, desc)
|
||||||
|
|
||||||
for _, muc := range hook.NotifyMuc {
|
for _, muc := range hook.NotifyMuc {
|
||||||
client.SendOrg(fmt.Sprintf(msg, muc, "groupchat"))
|
client.SendOrg(fmt.Sprintf(msg, muc, "groupchat"))
|
||||||
|
|
Loading…
Reference in New Issue