diff --git a/main.go b/main.go index 7e02443..7a4f89a 100644 --- a/main.go +++ b/main.go @@ -223,7 +223,11 @@ func main() { case http.MethodPost: msg = r.Form.Get("file") default: - http.Error(w, fmt.Sprintf("method %q not implemented", r.Method), http.StatusMethodNotAllowed) + http.Error( + w, + fmt.Sprintf("method %q not implemented", r.Method), + http.StatusMethodNotAllowed, + ) return } @@ -236,9 +240,13 @@ func main() { for _, line := range strings.Split(msg, "\n") { log.Printf("GOT: sending '%s'\n", line) - err = plugins.SendNotice(cli, gotRoom, line) + err = plugins.SendUnescNotice(cli, gotRoom, line) if err != nil { - http.Error(w, fmt.Sprintf("can not send commit info: %s", err), http.StatusInternalServerError) + http.Error( + w, + fmt.Sprintf("can not send commit info: %s", err), + http.StatusInternalServerError, + ) return } } @@ -259,7 +267,9 @@ func main() { errataCount, err = strconv.Atoi(storeCount) got, err := ParseRemoteErrata( - fmt.Sprintf("http://ftp.openbsd.org/pub/OpenBSD/patches/%s/common/", openbsdRelease), + fmt.Sprintf("http://ftp.openbsd.org/pub/OpenBSD/patches/%s/common/", + openbsdRelease, + ), ) if err != nil { fmt.Println(err) diff --git a/plugins/plugins.go b/plugins/plugins.go index f829066..8d11bd0 100644 --- a/plugins/plugins.go +++ b/plugins/plugins.go @@ -177,6 +177,32 @@ func SendMDNotice(c *gomatrix.Client, roomID, message string) error { return nil } +// SendUnescNotice sends an text notice to a given room. It pretends to be +// "typing" by calling UserTyping for the caller. +func SendUnescNotice(c *gomatrix.Client, roomID, message string) error { + _, err := c.UserTyping(roomID, true, 3) + if err != nil { + return err + } + + // Undo the escaping + _, err = c.SendMessageEvent(roomID, "m.room.message", gomatrix.HTMLMessage{ + Body: message, + MsgType: "m.notice", + Format: "org.matrix.custom.text", + FormattedBody: message, + }) + if err != nil { + return err + } + + _, err = c.UserTyping(roomID, false, 0) + if err != nil { + return err + } + return nil +} + // SendNotice sends an text notice to a given room. It pretends to be // "typing" by calling UserTyping for the caller. func SendNotice(c *gomatrix.Client, roomID, message string) error {