From 007bd63db7768b8db5b736e0c5345156c324b1e9 Mon Sep 17 00:00:00 2001 From: okseby Date: Mon, 28 Aug 2023 22:32:38 -0400 Subject: [PATCH 1/3] Remove test file --- bot/test | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 bot/test diff --git a/bot/test b/bot/test deleted file mode 100644 index e69de29..0000000 From b8413bf448103938151fd5ce1564c6fcfafdb928 Mon Sep 17 00:00:00 2001 From: okseby Date: Mon, 28 Aug 2023 23:19:25 -0400 Subject: [PATCH 2/3] Add some logging for the console when events are handled, and add logging for requests to root endpoint --- bot/utils.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bot/utils.go b/bot/utils.go index 66329eb..d84a00c 100644 --- a/bot/utils.go +++ b/bot/utils.go @@ -44,7 +44,12 @@ func listenForWebhook() { } 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) { @@ -58,21 +63,26 @@ func webhookHandler(w http.ResponseWriter, r *http.Request) { panic(err) } + w.WriteHeader(200) + switch event := event.(type) { case *github.IssuesEvent: + log.Println("Received Issues Event: processing now!") processIssuesEvent(event) break case *github.IssueCommentEvent: if !strings.Contains(event.GetComment().GetUser().GetLogin(), "bot") { + log.Println("Received Issue Comment Event: processing now!") processIssueCommentEvent(event) break } break case *github.PullRequestEvent: + log.Println("Received Pull Request Event: processing now!") processPullRequestEvent(event) break default: - fmt.Println("Unhandled Event!") + log.Println("Received Unhandled Event!") break } } From 40b64a43ef524989a7a61aef51a764f89845b308 Mon Sep 17 00:00:00 2001 From: okseby Date: Mon, 28 Aug 2023 23:21:25 -0400 Subject: [PATCH 3/3] Why is the vote counting broken now? --- bot/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/utils.go b/bot/utils.go index d84a00c..cd1837b 100644 --- a/bot/utils.go +++ b/bot/utils.go @@ -153,7 +153,7 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) { return } else { - commentText := "Votes: (#{reactionCount})/(#{reactionRemainingCount})" + commentText := "Votes: (#{reactionCount}) Needed: (#{reactionRemainingCount})" commentText = strings.Replace(commentText, "(#{reactionCount})", strconv.Itoa(reactionCount), 1) commentText = strings.Replace(commentText, "(#{reactionRemainingCount})", strconv.Itoa(reactionCountGoal-reactionCount), 1)