refined messages slightly

This commit is contained in:
A_D 2018-11-17 21:22:39 +02:00
parent 246da11334
commit 2a54c81da1
No known key found for this signature in database
GPG Key ID: C242F3DD220FA945
1 changed files with 12 additions and 11 deletions

View File

@ -68,7 +68,7 @@ func handlePush(data []byte, msgChan chan string) {
outIrcMessage := strings.Builder{} outIrcMessage := strings.Builder{}
outIrcMessage.WriteString(fmt.Sprintf( outIrcMessage.WriteString(fmt.Sprintf(
"[%s] %s pushed %d commits", "[%s] %s pushed %d commit(s)",
pushData.Repository.FullName, pushData.Repository.FullName,
pushData.Pusher.Login, pushData.Pusher.Login,
len(pushData.Commits), len(pushData.Commits),
@ -81,16 +81,17 @@ func handlePush(data []byte, msgChan chan string) {
func handleIssueAction(data []byte, msgChan chan string) { func handleIssueAction(data []byte, msgChan chan string) {
action := IssueAction{} action := IssueAction{}
json.Unmarshal(data, &action) json.Unmarshal(data, &action)
printSep() outMsg := strings.Builder{}
fmt.Printf( outMsg.WriteString(fmt.Sprintf("[%s] ", action.Repository.FullName))
"%q (%q) performed the action %q on repo %q and issue %q\n", switch action.Action {
action.Sender.Login, case "opened":
action.Sender.Email, outMsg.WriteString(fmt.Sprintf("%s opened an issue: %q", action.Sender.Login, action.Issue.Title))
action.Action, case "closed":
action.Repository.FullName, outMsg.WriteString(fmt.Sprintf("%s closed issue %q", action.Sender.Login, action.Issue.Title))
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 <- 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) }
msgChan <- outMsg.String()
} }
func handleIssueComment(data []byte, msgChan chan string) { func handleIssueComment(data []byte, msgChan chan string) {