From 2a54c81da1863592f4844438fdf08bad1a5d0a60 Mon Sep 17 00:00:00 2001 From: A_D Date: Sat, 17 Nov 2018 21:22:39 +0200 Subject: [PATCH] refined messages slightly --- src/webhooks.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/webhooks.go b/src/webhooks.go index 3b716a3..dffd240 100644 --- a/src/webhooks.go +++ b/src/webhooks.go @@ -68,7 +68,7 @@ func handlePush(data []byte, msgChan chan string) { outIrcMessage := strings.Builder{} outIrcMessage.WriteString(fmt.Sprintf( - "[%s] %s pushed %d commits", + "[%s] %s pushed %d commit(s)", pushData.Repository.FullName, pushData.Pusher.Login, len(pushData.Commits), @@ -81,16 +81,17 @@ func handlePush(data []byte, msgChan chan string) { func handleIssueAction(data []byte, msgChan chan string) { action := IssueAction{} json.Unmarshal(data, &action) - printSep() - fmt.Printf( - "%q (%q) performed the action %q on repo %q and issue %q\n", - action.Sender.Login, - action.Sender.Email, - action.Action, - action.Repository.FullName, - action.Issue.Title, - ) - msgChan <- fmt.Sprintf("[%s] %s performed the action %s on issue %f (%s)", action.Repository.FullName, action.Sender.Login, action.Action, action.Issue.Id, action.Issue.Title) + outMsg := strings.Builder{} + outMsg.WriteString(fmt.Sprintf("[%s] ", action.Repository.FullName)) + switch action.Action { + case "opened": + outMsg.WriteString(fmt.Sprintf("%s opened an issue: %q", action.Sender.Login, action.Issue.Title)) + case "closed": + outMsg.WriteString(fmt.Sprintf("%s closed issue %q", action.Sender.Login, action.Issue.Title)) + default: + outMsg.WriteString(fmt.Sprintf("%s performed an unknown action (%s) on issue %f", action.Sender.Login, action.Action, action.Issue.Id)) + } + msgChan <- outMsg.String() } func handleIssueComment(data []byte, msgChan chan string) {