mirror of
				https://git.ferricyanide.solutions/A_D/irc-webhooks.git
				synced 2025-10-31 08:40:54 +00:00 
			
		
		
		
	added handling for issue comments
This commit is contained in:
		
							parent
							
								
									931fb26dbc
								
							
						
					
					
						commit
						70b1d85605
					
				| @ -78,6 +78,17 @@ type Issue struct { | ||||
|     PullRequest string   `json:"pull_request"` | ||||
| } | ||||
| 
 | ||||
| type IssueComment struct { | ||||
|     Id             float64  `json:"id"` | ||||
|     HtmlUrl        string   `json:"html_url"` | ||||
|     PullRequestUrl string   `json:"pull_request_url"` | ||||
|     IssueUrl       string   `json:"issue_url"` | ||||
|     User           RepoUser `json:"user"` | ||||
|     Body           string   `json:"body"` | ||||
|     CreatedAt      string   `json:"created_at"` | ||||
|     UpdatedAt      string   `json:"updated_at"` | ||||
| } | ||||
| 
 | ||||
| type BaseWebHook struct { | ||||
|     Secret string `json:"secret"` | ||||
| } | ||||
| @ -96,9 +107,10 @@ type Push struct { | ||||
| 
 | ||||
| type IssueAction struct { | ||||
|     BaseWebHook | ||||
|     Action     string     `json:"action"` | ||||
|     Number     float64    `json:"number"` | ||||
|     Issue      Issue      `json:"issue"` | ||||
|     Repository Repository `json:"repository"` | ||||
|     Sender     RepoUser   `json:"sender"` | ||||
|     Action     string       `json:"action"` | ||||
|     Number     float64      `json:"number"` | ||||
|     Issue      Issue        `json:"issue"` | ||||
|     Repository Repository   `json:"repository"` | ||||
|     Sender     RepoUser     `json:"sender"` | ||||
|     Comment    IssueComment `json:"comment"` | ||||
| } | ||||
|  | ||||
							
								
								
									
										21
									
								
								webhooks.go
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								webhooks.go
									
									
									
									
									
								
							| @ -42,6 +42,9 @@ func handleWebHook(writer http.ResponseWriter, request *http.Request) { | ||||
|     case "issues": | ||||
|         handleIssueAction(data) | ||||
| 
 | ||||
|     case "issue_comment": | ||||
|         handleIssueComment(data) | ||||
| 
 | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -96,3 +99,21 @@ func handleIssueAction(data []byte) { | ||||
|         action.Issue.Title, | ||||
|     ) | ||||
| } | ||||
| 
 | ||||
| func handleIssueComment(data []byte) { | ||||
|     action := IssueAction{} | ||||
|     json.Unmarshal(data, &action) | ||||
|     printSep() | ||||
|     fmt.Printf( | ||||
|         "%q (%q) performed the comment action %q on repo %q and issue %q\n", | ||||
|         action.Sender.Login, | ||||
|         action.Sender.Email, | ||||
|         action.Action, | ||||
|         action.Repository.FullName, | ||||
|         action.Issue.Title, | ||||
|     ) | ||||
| 
 | ||||
|     fmt.Printf(INDENT + "---") | ||||
|     msg := strings.Replace(action.Comment.Body, "\n", strings.Repeat(INDENT, 2), -1) | ||||
|     fmt.Printf(strings.Repeat(INDENT, 2) + msg) | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user