From 54a969a4dad3af37d819605ae06bdb15ba58c88b Mon Sep 17 00:00:00 2001 From: okseby Date: Wed, 30 Aug 2023 19:47:41 -0400 Subject: [PATCH 1/3] version bump --- bot/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/main.go b/bot/main.go index fd955af..6a5e711 100644 --- a/bot/main.go +++ b/bot/main.go @@ -1,6 +1,6 @@ package main -var version = "v0.03" +var version = "v0.04" func main() { initGitHubClient(version) From 9513ba8897cbddf97520964545cfd4e79bd4bc64 Mon Sep 17 00:00:00 2001 From: okseby Date: Wed, 30 Aug 2023 20:02:34 -0400 Subject: [PATCH 2/3] Only merge if the comment body contains a thumbs up emoji --- bot/utils.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bot/utils.go b/bot/utils.go index 9961a98..e3352d2 100644 --- a/bot/utils.go +++ b/bot/utils.go @@ -86,7 +86,7 @@ func webhookHandler(w http.ResponseWriter, r *http.Request) { eventLogin := event.GetComment().GetUser().GetLogin() commentBody := event.GetComment().GetBody() - if !strings.Contains(eventLogin, "bot") && strings.Contains(commentBody, "+1") { + if !strings.Contains(eventLogin, "bot") && strings.Contains(commentBody, ":+1:") { log.Println("Received Issue Comment Event: processing now!") processIssueCommentEvent(event) break @@ -142,8 +142,9 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) { // Check if there are thumbs up (:+1:) reactions for _, comment := range comments { commentAuthor := comment.GetUser().GetLogin() + commentBody := comment.GetBody() - if !strings.Contains(commentAuthor, "bot") { + if !strings.Contains(commentAuthor, "bot") && strings.Contains(commentBody, ":+1:") { _, exists := approvals[commentAuthor] if !exists { approvals[commentAuthor] = 1 From ce75c723fa1eb99b208ec4b545bdb11c2ace7bce Mon Sep 17 00:00:00 2001 From: okseby Date: Wed, 30 Aug 2023 20:05:58 -0400 Subject: [PATCH 3/3] Fix placeholder not being replaced with username --- bot/utils.go | 1 + 1 file changed, 1 insertion(+) diff --git a/bot/utils.go b/bot/utils.go index e3352d2..2967dfa 100644 --- a/bot/utils.go +++ b/bot/utils.go @@ -195,6 +195,7 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) { } } else { commentText := "@(#{commentAuthor}) voted! :tada:\n" + "Votes: (#{reactionCount})/(#{reactionCountGoal})" + commentText = strings.Replace(commentText, "(#{commentAuthor})", eventSender, 1) commentText = strings.Replace(commentText, "(#{reactionCount})", strconv.Itoa(len(approvals)), 1) commentText = strings.Replace(commentText, "(#{reactionCountGoal})", strconv.Itoa(reactionCountGoal), 1)