From 13e166ffde97f2829b072b8a927887d94e7a9180 Mon Sep 17 00:00:00 2001 From: okseby Date: Wed, 30 Aug 2023 20:19:59 -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 6a5e711..2f0dd0f 100644 --- a/bot/main.go +++ b/bot/main.go @@ -1,6 +1,6 @@ package main -var version = "v0.04" +var version = "v0.05" func main() { initGitHubClient(version) From b43bd104c02ca865f9b99f9facb9d4ac8b696f3c Mon Sep 17 00:00:00 2001 From: okseby Date: Wed, 30 Aug 2023 20:35:53 -0400 Subject: [PATCH 2/3] Make bot detection more reliable --- bot/utils.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bot/utils.go b/bot/utils.go index 2967dfa..ad3f94c 100644 --- a/bot/utils.go +++ b/bot/utils.go @@ -83,10 +83,10 @@ func webhookHandler(w http.ResponseWriter, r *http.Request) { processIssuesEvent(event) break case *github.IssueCommentEvent: - eventLogin := event.GetComment().GetUser().GetLogin() + userType := strings.ToLower(event.GetComment().GetUser().GetType()) commentBody := event.GetComment().GetBody() - if !strings.Contains(eventLogin, "bot") && strings.Contains(commentBody, ":+1:") { + if !strings.Contains(userType, "bot") && strings.Contains(commentBody, ":+1:") { log.Println("Received Issue Comment Event: processing now!") processIssueCommentEvent(event) break @@ -141,10 +141,11 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) { // Check if there are thumbs up (:+1:) reactions for _, comment := range comments { + userType := strings.ToLower(event.GetComment().GetUser().GetType()) commentAuthor := comment.GetUser().GetLogin() commentBody := comment.GetBody() - if !strings.Contains(commentAuthor, "bot") && strings.Contains(commentBody, ":+1:") { + if !strings.Contains(userType, "bot") && strings.Contains(commentBody, ":+1:") { _, exists := approvals[commentAuthor] if !exists { approvals[commentAuthor] = 1 From 7928bfae7ce9eb4d948a93f6d252529f61fb9602 Mon Sep 17 00:00:00 2001 From: okseby Date: Wed, 30 Aug 2023 20:37:38 -0400 Subject: [PATCH 3/3] Add log to really see whats going on --- bot/utils.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bot/utils.go b/bot/utils.go index ad3f94c..68cfa95 100644 --- a/bot/utils.go +++ b/bot/utils.go @@ -86,6 +86,8 @@ func webhookHandler(w http.ResponseWriter, r *http.Request) { userType := strings.ToLower(event.GetComment().GetUser().GetType()) commentBody := event.GetComment().GetBody() + log.Println("User type:", userType, "Comment body:", commentBody) + if !strings.Contains(userType, "bot") && strings.Contains(commentBody, ":+1:") { log.Println("Received Issue Comment Event: processing now!") processIssueCommentEvent(event)