mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-18 07:13:50 +01:00
* implement ntfy notification * fix notification fields order * fix schema for ntfy --------- Co-authored-by: yusing <yusing@6uo.me>
27 lines
484 B
Go
27 lines
484 B
Go
package notif
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
)
|
|
|
|
func formatMarkdown(extras LogFields) string {
|
|
msg := bytes.NewBufferString("")
|
|
for _, field := range extras {
|
|
msg.WriteString("#### ")
|
|
msg.WriteString(field.Name)
|
|
msg.WriteRune('\n')
|
|
msg.WriteString(field.Value)
|
|
msg.WriteRune('\n')
|
|
}
|
|
return msg.String()
|
|
}
|
|
|
|
func formatDiscord(extras LogFields) (string, error) {
|
|
fields, err := json.Marshal(extras)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return string(fields), nil
|
|
}
|