Make bot detection more reliable
This commit is contained in:
parent
13e166ffde
commit
b43bd104c0
1 changed files with 4 additions and 3 deletions
|
@ -83,10 +83,10 @@ func webhookHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
processIssuesEvent(event)
|
processIssuesEvent(event)
|
||||||
break
|
break
|
||||||
case *github.IssueCommentEvent:
|
case *github.IssueCommentEvent:
|
||||||
eventLogin := event.GetComment().GetUser().GetLogin()
|
userType := strings.ToLower(event.GetComment().GetUser().GetType())
|
||||||
commentBody := event.GetComment().GetBody()
|
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!")
|
log.Println("Received Issue Comment Event: processing now!")
|
||||||
processIssueCommentEvent(event)
|
processIssueCommentEvent(event)
|
||||||
break
|
break
|
||||||
|
@ -141,10 +141,11 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) {
|
||||||
|
|
||||||
// Check if there are thumbs up (:+1:) reactions
|
// Check if there are thumbs up (:+1:) reactions
|
||||||
for _, comment := range comments {
|
for _, comment := range comments {
|
||||||
|
userType := strings.ToLower(event.GetComment().GetUser().GetType())
|
||||||
commentAuthor := comment.GetUser().GetLogin()
|
commentAuthor := comment.GetUser().GetLogin()
|
||||||
commentBody := comment.GetBody()
|
commentBody := comment.GetBody()
|
||||||
|
|
||||||
if !strings.Contains(commentAuthor, "bot") && strings.Contains(commentBody, ":+1:") {
|
if !strings.Contains(userType, "bot") && strings.Contains(commentBody, ":+1:") {
|
||||||
_, exists := approvals[commentAuthor]
|
_, exists := approvals[commentAuthor]
|
||||||
if !exists {
|
if !exists {
|
||||||
approvals[commentAuthor] = 1
|
approvals[commentAuthor] = 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue