mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00

* chore: replace gopkg.in/yaml.v3 vs goccy/go-yaml; replace encoding/json with bytedance/sonic * fix: yaml unmarshal panic * feat: custom json marshaler implementation * chore: fix import and err marshal handling --------- Co-authored-by: yusing <yusing@6uo.me>
27 lines
507 B
Go
27 lines
507 B
Go
package notif
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"github.com/yusing/go-proxy/pkg/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
|
|
}
|