@@ -18,6 +18,7 @@ import (
18
18
"context"
19
19
"encoding/json"
20
20
"fmt"
21
+ "strings"
21
22
22
23
"github.com/google/go-github/github"
23
24
"github.com/pkg/errors"
@@ -65,16 +66,21 @@ func (h *PRCommentHandler) Handle(ctx context.Context, eventType, deliveryID str
65
66
66
67
repoOwner := repo .GetOwner ().GetLogin ()
67
68
repoName := repo .GetName ()
68
- author := event .GetComment ().GetUser ()
69
+ author := event .GetComment ().GetUser (). GetLogin ()
69
70
body := event .GetComment ().GetBody ()
70
71
72
+ if strings .HasSuffix (author , "[bot]" ) {
73
+ logger .Debug ().Msg ("Issue comment was created by a bot" )
74
+ return nil
75
+ }
76
+
71
77
logger .Debug ().Msgf ("Echoing comment on %s/%s#%d by %s" , repoOwner , repoName , prNum , author )
72
- msg := fmt .Sprintf ("%s\n %s said\n ```%s\n ```\n " , h .preamble , author , body )
73
- prComment := github.PullRequestComment {
78
+ msg := fmt .Sprintf ("%s\n %s said\n ```\n %s\n ```\n " , h .preamble , author , body )
79
+ prComment := github.IssueComment {
74
80
Body : & msg ,
75
81
}
76
82
77
- if _ , _ , err := client .PullRequests .CreateComment (ctx , repoOwner , repoName , prNum , & prComment ); err != nil {
83
+ if _ , _ , err := client .Issues .CreateComment (ctx , repoOwner , repoName , prNum , & prComment ); err != nil {
78
84
logger .Error ().Err (err ).Msg ("Failed to comment on pull request" )
79
85
}
80
86
0 commit comments