Ok so PR's aren't working but I made it a little prettier.
This commit is contained in:
parent
78c8955235
commit
268caa3d52
1 changed files with 8 additions and 7 deletions
15
bot/utils.go
15
bot/utils.go
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
// Wrap the shared transport for use with the integration ID and authenticating with installation ID.
|
||||
var itr, err = ghinstallation.NewKeyFromFile(http.DefaultTransport, 381312, 41105280, "theopenestsource.2023-08-26.private-key.pem")
|
||||
var itr, _ = ghinstallation.NewKeyFromFile(http.DefaultTransport, 381312, 41105280, "theopenestsource.2023-08-26.private-key.pem")
|
||||
|
||||
// Use installation transport with client.
|
||||
var client = github.NewClient(&http.Client{Transport: itr})
|
||||
|
@ -55,6 +55,8 @@ func webhookHandler(w http.ResponseWriter, r *http.Request) {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
w.WriteHeader(200)
|
||||
|
||||
switch event := event.(type) {
|
||||
case *github.IssuesEvent:
|
||||
processIssuesEvent(event)
|
||||
|
@ -65,6 +67,9 @@ func webhookHandler(w http.ResponseWriter, r *http.Request) {
|
|||
case *github.PullRequestReviewCommentEvent:
|
||||
processPullRequestReviewCommentEvent(event)
|
||||
break
|
||||
default:
|
||||
fmt.Println("Unhandled Event!")
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,10 +88,10 @@ func processIssuesEvent(event *github.IssuesEvent) {
|
|||
}
|
||||
|
||||
func processPullRequestEvent(event *github.PullRequestEvent) {
|
||||
if event.GetAction() == "opened" {
|
||||
if event.GetAction() == "opened" || event.GetAction() == "reopened" {
|
||||
// Respond with a comment
|
||||
comment := &github.IssueComment{
|
||||
Body: github.String("React to this comment with +1 to vote for getting it merged!"),
|
||||
Body: github.String("React to this comment with :+1: to vote for getting it merged!"),
|
||||
}
|
||||
|
||||
_, _, err := client.Issues.CreateComment(ctx, event.GetRepo().GetOwner().GetLogin(), event.GetRepo().GetName(), event.GetPullRequest().GetNumber(), comment)
|
||||
|
@ -94,10 +99,6 @@ func processPullRequestEvent(event *github.PullRequestEvent) {
|
|||
log.Println("Error creating comment:", err)
|
||||
}
|
||||
}
|
||||
|
||||
if event.GetAction() == "reaction" {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func processPullRequestReviewCommentEvent(event *github.PullRequestReviewCommentEvent) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue