Seem to finally get it all working as intended
This commit is contained in:
parent
d0e32757b9
commit
f502fe0858
1 changed files with 9 additions and 7 deletions
16
bot/utils.go
16
bot/utils.go
|
@ -7,6 +7,7 @@ import (
|
|||
"golang.org/x/net/context"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -62,7 +63,10 @@ func webhookHandler(w http.ResponseWriter, r *http.Request) {
|
|||
processIssuesEvent(event)
|
||||
break
|
||||
case *github.IssueCommentEvent:
|
||||
processIssueCommentEvent(event)
|
||||
if event.GetComment().GetUser().GetLogin() != "openest-source-bot[bot]" {
|
||||
processIssueCommentEvent(event)
|
||||
break
|
||||
}
|
||||
break
|
||||
case *github.PullRequestEvent:
|
||||
processPullRequestEvent(event)
|
||||
|
@ -100,8 +104,6 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) {
|
|||
reactionCount := 0
|
||||
reactionCountGoal := 2
|
||||
|
||||
fmt.Println("Owner:", owner, "Repo:", repo, "PR Number:", prNumber)
|
||||
|
||||
if event.GetIssue().IsPullRequest() {
|
||||
comments, _, err := client.Issues.ListComments(ctx, owner, repo, prNumber, nil)
|
||||
if err != nil {
|
||||
|
@ -129,9 +131,9 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) {
|
|||
|
||||
return
|
||||
} else {
|
||||
commentText := "Current thumbs up count: (#{reactionCount}) need (#{reactionRemainingCount}) more to merge."
|
||||
commentText = strings.Replace(commentText, "(#{reactionCount})", string(reactionCount), 1)
|
||||
commentText = strings.Replace(commentText, "(#{reactionRemainingCount})", string(reactionCountGoal-reactionCount), 1)
|
||||
commentText := "Current :+1: count is (#{reactionCount}) need (#{reactionRemainingCount}) more to merge"
|
||||
commentText = strings.Replace(commentText, "(#{reactionCount})", strconv.Itoa(reactionCount), 1)
|
||||
commentText = strings.Replace(commentText, "(#{reactionRemainingCount})", strconv.Itoa(reactionCountGoal-reactionCount), 1)
|
||||
|
||||
// Respond with a comment
|
||||
comment := &github.IssueComment{
|
||||
|
@ -152,7 +154,7 @@ func processPullRequestEvent(event *github.PullRequestEvent) {
|
|||
if event.GetAction() == "opened" || event.GetAction() == "reopened" {
|
||||
// Respond with a comment
|
||||
comment := &github.IssueComment{
|
||||
Body: github.String("React to this PR with :+1: to vote for getting it merged!"),
|
||||
Body: github.String("Comment on this PR with :+1: to vote for getting it merged!"),
|
||||
}
|
||||
|
||||
_, _, err := client.Issues.CreateComment(ctx, event.GetRepo().GetOwner().GetLogin(), event.GetRepo().GetName(), event.GetPullRequest().GetNumber(), comment)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue