mirror of
https://git.ferricyanide.solutions/A_D/irc-webhooks.git
synced 2024-12-22 17:57:05 +00:00
switched out prints for irc messages
This commit is contained in:
parent
47c2d78b62
commit
246da11334
@ -66,13 +66,7 @@ func handlePush(data []byte, msgChan chan string) {
|
||||
pushData := Push{}
|
||||
json.Unmarshal(data, &pushData)
|
||||
outIrcMessage := strings.Builder{}
|
||||
fmt.Printf(
|
||||
"Got a push for repo %q owned by %q. Pushed by %q (%q)\n",
|
||||
pushData.Repository.FullName,
|
||||
pushData.Repository.Owner.Login,
|
||||
pushData.Pusher.Login,
|
||||
pushData.Pusher.Email,
|
||||
)
|
||||
|
||||
outIrcMessage.WriteString(fmt.Sprintf(
|
||||
"[%s] %s pushed %d commits",
|
||||
pushData.Repository.FullName,
|
||||
@ -80,20 +74,6 @@ func handlePush(data []byte, msgChan chan string) {
|
||||
len(pushData.Commits),
|
||||
))
|
||||
|
||||
for _, commit := range pushData.Commits {
|
||||
fmt.Println(INDENT + "--")
|
||||
fmt.Printf(
|
||||
INDENT+"Commit added by %q (%q), made by %q (%q), with hash %q and message:\n",
|
||||
commit.Committer.Name,
|
||||
commit.Committer.Email,
|
||||
commit.Author.Name,
|
||||
commit.Author.Email,
|
||||
commit.Hash,
|
||||
)
|
||||
|
||||
msg := strings.Replace(commit.Message, "\n", strings.Repeat(INDENT, 2)+"\n", -1)
|
||||
fmt.Println(strings.Repeat(INDENT, 2) + msg)
|
||||
}
|
||||
msgChan <- outIrcMessage.String()
|
||||
|
||||
}
|
||||
@ -110,25 +90,13 @@ func handleIssueAction(data []byte, msgChan chan string) {
|
||||
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)
|
||||
}
|
||||
|
||||
func handleIssueComment(data []byte, msgChan chan string) {
|
||||
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 + "---\n")
|
||||
stripped := strings.Replace(action.Comment.Body, "\r", "", -1)
|
||||
msg := strings.Replace(stripped, "\n", strings.Repeat(INDENT, 2) + "\n", -1)
|
||||
fmt.Printf(strings.Repeat(INDENT, 2) + msg)
|
||||
msgChan <- fmt.Sprintf("[%s] %s commented on issue %f (%s)", action.Repository.FullName, action.Sender.Login, action.Issue.Id, action.Issue.Title)
|
||||
}
|
||||
|
||||
func handleCreate(data []byte, msgChan chan string) {
|
||||
@ -144,13 +112,5 @@ func handleCreate(data []byte, msgChan chan string) {
|
||||
}
|
||||
|
||||
func handleBranchCreate(branchAction CreateAction, msgChan chan string) {
|
||||
printSep()
|
||||
fmt.Printf(
|
||||
"%q (%q) created branch %q on repo %q (owned by %q)\n",
|
||||
branchAction.Sender.Login,
|
||||
branchAction.Sender.Email,
|
||||
branchAction.Ref,
|
||||
branchAction.Repository.FullName,
|
||||
branchAction.Repository.Owner.Login,
|
||||
)
|
||||
msgChan <- fmt.Sprintf("[%s] %s created branch %s", branchAction.Repository.FullName, branchAction.Sender.Login, branchAction.Ref)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user