-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.go
36 lines (31 loc) · 827 Bytes
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main // (c) 2020 ken pepple ([email protected])
import (
"fmt"
"strings"
)
func createMsg(c map[string]string) string {
icon := map[string]string{
"success": "👍",
"failure": "👎",
"cancelled": "🤚",
}
if c["msg"] != "" {
return c["msg"]
}
m := fmt.Sprintf("%s <b>%s</b> %s from %s status: %s",
icon[c["status"]], fixName(c["name"]), c["ref"], c["repo"], c["status"])
return m
}
func createTitle(c map[string]string) string {
if c["title"] != "" {
return c["title"]
}
return fmt.Sprintf("%s %s on %s", fixName(c["name"]), c["ref"], c["repo"])
}
func createURL(c map[string]string) string {
return "https://github.com/" + c["repo"]
}
// fixName restyles the github event name into proper english
func fixName(s string) string {
return strings.Title(strings.ReplaceAll(s, "_", " "))
}