commit
7d36f5cad1
2 changed files with 13 additions and 3 deletions
0
bot/test
0
bot/test
16
bot/utils.go
16
bot/utils.go
|
@ -44,7 +44,12 @@ func listenForWebhook() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func webHandle(w http.ResponseWriter, r *http.Request) {
|
func webHandle(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintf(w, "Turn back!")
|
_, err := fmt.Fprintf(w, "Turn back!")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println("Request received to / endpoint:", r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func webhookHandler(w http.ResponseWriter, r *http.Request) {
|
func webhookHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -58,21 +63,26 @@ func webhookHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.WriteHeader(200)
|
||||||
|
|
||||||
switch event := event.(type) {
|
switch event := event.(type) {
|
||||||
case *github.IssuesEvent:
|
case *github.IssuesEvent:
|
||||||
|
log.Println("Received Issues Event: processing now!")
|
||||||
processIssuesEvent(event)
|
processIssuesEvent(event)
|
||||||
break
|
break
|
||||||
case *github.IssueCommentEvent:
|
case *github.IssueCommentEvent:
|
||||||
if !strings.Contains(event.GetComment().GetUser().GetLogin(), "bot") {
|
if !strings.Contains(event.GetComment().GetUser().GetLogin(), "bot") {
|
||||||
|
log.Println("Received Issue Comment Event: processing now!")
|
||||||
processIssueCommentEvent(event)
|
processIssueCommentEvent(event)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case *github.PullRequestEvent:
|
case *github.PullRequestEvent:
|
||||||
|
log.Println("Received Pull Request Event: processing now!")
|
||||||
processPullRequestEvent(event)
|
processPullRequestEvent(event)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
fmt.Println("Unhandled Event!")
|
log.Println("Received Unhandled Event!")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +153,7 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) {
|
||||||
|
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
commentText := "Votes: (#{reactionCount})/(#{reactionRemainingCount})"
|
commentText := "Votes: (#{reactionCount}) Needed: (#{reactionRemainingCount})"
|
||||||
commentText = strings.Replace(commentText, "(#{reactionCount})", strconv.Itoa(reactionCount), 1)
|
commentText = strings.Replace(commentText, "(#{reactionCount})", strconv.Itoa(reactionCount), 1)
|
||||||
commentText = strings.Replace(commentText, "(#{reactionRemainingCount})", strconv.Itoa(reactionCountGoal-reactionCount), 1)
|
commentText = strings.Replace(commentText, "(#{reactionRemainingCount})", strconv.Itoa(reactionCountGoal-reactionCount), 1)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue