Compare commits

...

1 Commits

Author SHA1 Message Date
0be6cc8d88
Render formatting
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
2021-12-05 17:59:18 +00:00
2 changed files with 10 additions and 3 deletions

View File

@ -8,6 +8,8 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/prometheus/alertmanager/template"
"maunium.net/go/mautrix"
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/format"
"maunium.net/go/mautrix/id"
)
@ -32,13 +34,17 @@ func HandleAlertmanagerPayloadPost(c *fiber.Ctx) error {
case "warning":
message = fmt.Sprintf("⚠️ %s", rendered.String())
case "notify":
message = fmt.Sprintf("@room - %s", rendered.String())
message = fmt.Sprintf("🔥 @room - %s", rendered.String())
}
} else {
message = fmt.Sprintf("☑️ %s", rendered.String())
message = fmt.Sprintf(" %s", rendered.String())
}
_, err := matrixClient.SendText(id.RoomID(getRoom(*defaultRoom)), message)
_, err := matrixClient.SendMessageEvent(
id.RoomID(getRoom(*defaultRoom)),
event.EventMessage,
format.RenderMarkdown(message, true, true),
)
if err != nil {
fmt.Println("Failed sending to Matrix", err)
if httpErr, ok := err.(mautrix.HTTPError); ok {

1
go.sum
View File

@ -411,6 +411,7 @@ github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=