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{}{
|
||||
"url": request.RuleURL,
|
||||
"msg": request.String(),
|
||||
"image": request.ImageURL,
|
||||
})
|
||||
|
||||
ruleURL, err := url.Parse(request.RuleURL)
|
||||
|
@ -72,10 +73,11 @@ func init() {
|
|||
if ruleURL.Hostname() != hook.URL {
|
||||
continue
|
||||
}
|
||||
|
||||
runtime.Notify(client, hook, request.String())
|
||||
if request.ImageURL != "" {
|
||||
logger = logger.WithField("image", request.ImageURL)
|
||||
runtime.NotifyImage(client, hook, request.ImageURL)
|
||||
runtime.NotifyImage(client, hook, request.ImageURL, request.String())
|
||||
}else{
|
||||
}
|
||||
logger.Infof("run hook")
|
||||
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")
|
||||
|
||||
log.Infof("started hock2xmpp with %s", client.JID())
|
||||
|
||||
// Wait for system signal
|
||||
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'>
|
||||
<body>%s</body>
|
||||
<x xmlns='jabber:x:oob'>
|
||||
<url>%s</url>
|
||||
<desc>%s</desc>
|
||||
</x>
|
||||
</message>`, url, url)
|
||||
</message>`, url, url, desc)
|
||||
|
||||
for _, muc := range hook.NotifyMuc {
|
||||
client.SendOrg(fmt.Sprintf(msg, muc, "groupchat"))
|
||||
|
|
Loading…
Reference in New Issue