adjustments for hookshot
This commit is contained in:
parent
9e83028509
commit
adc896a4ca
23
main.go
23
main.go
@ -50,7 +50,6 @@ func loadPatches(pl *patchList, url string) {
|
|||||||
func notify(ptch patch, url string) {
|
func notify(ptch patch, url string) {
|
||||||
type Payload struct {
|
type Payload struct {
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
Format string `json:"format"`
|
|
||||||
DisplayName string `json:"displayName"`
|
DisplayName string `json:"displayName"`
|
||||||
AvatarURL string `json:"avatar_url"`
|
AvatarURL string `json:"avatar_url"`
|
||||||
}
|
}
|
||||||
@ -67,14 +66,8 @@ func notify(ptch patch, url string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if url != "" {
|
if url != "" {
|
||||||
data := struct {
|
data := Payload{
|
||||||
Text string `json:"text"`
|
|
||||||
Format string `json:"format"`
|
|
||||||
DisplayName string `json:"displayName"`
|
|
||||||
AvatarURL string `json:"avatar_url"`
|
|
||||||
}{
|
|
||||||
msg,
|
msg,
|
||||||
"plain",
|
|
||||||
"DotaPatchBot",
|
"DotaPatchBot",
|
||||||
"https://i.pinimg.com/originals/8a/8b/50/8a8b50da2bc4afa933718061fe291520.jpg",
|
"https://i.pinimg.com/originals/8a/8b/50/8a8b50da2bc4afa933718061fe291520.jpg",
|
||||||
}
|
}
|
||||||
@ -84,20 +77,12 @@ func notify(ptch patch, url string) {
|
|||||||
log.Fatalf("Can't create webhook notice; failing since that means drastic data format change")
|
log.Fatalf("Can't create webhook notice; failing since that means drastic data format change")
|
||||||
}
|
}
|
||||||
body := bytes.NewReader(payloadBytes)
|
body := bytes.NewReader(payloadBytes)
|
||||||
|
resp, err := http.Post(url, "application/json", body)
|
||||||
req, err := http.NewRequest("POST", url, body)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Either POST was mispelled or couldn't create a context")
|
|
||||||
}
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
|
||||||
|
|
||||||
resp, err := http.DefaultClient.Do(req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("error posting to webhook")
|
log.Println("error posting to webhook")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if resp.Body != nil {
|
defer resp.Body.Close()
|
||||||
resp.Body.Close()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user