Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Commit

Permalink
add Github订阅对Issues的支持
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoo committed Jun 18, 2021
1 parent 955e4de commit c7c542a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion githubManager/hookManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func NewManager(app *iris.Application, bot *OPQBot.BotManager) Manager {
ctx.StatusCode(404)
return
}
payload, err := h.WebHook.Parse((*ctx).Request(), github.RepositoryEvent, github.PushEvent, github.PingEvent, github.ReleaseEvent, github.PullRequestEvent)
payload, err := h.WebHook.Parse((*ctx).Request(), github.IssuesEvent, github.RepositoryEvent, github.PushEvent, github.PingEvent, github.ReleaseEvent, github.PullRequestEvent)
if err != nil {
log.Println(err)
if err == github.ErrEventNotFound {
Expand All @@ -108,13 +108,27 @@ func NewManager(app *iris.Application, bot *OPQBot.BotManager) Manager {
switch v := payload.(type) {
case github.PingPayload:
log.Println(v)
case github.IssuesPayload:
switch v.Action {
case "open":
r, _ := requests.Get(v.Sender.AvatarURL)
for _, v1 := range h.Groups {
m.b.SendGroupPicMsg(v1, fmt.Sprintf("%s在%s发布了新的Issues: %s\n欢迎各位大佬前往解答!", v.Sender.Login, v.Repository.FullName, v.Issue.Title), r.Content())
}
}

case github.RepositoryPayload:
switch v.Action {
case "created":
r, _ := requests.Get(v.Sender.AvatarURL)
for _, v1 := range h.Groups {
m.b.SendGroupPicMsg(v1, fmt.Sprintf("%s在%s发布了新的仓库: %s\n欢迎Star哟", v.Sender.Login, v.Organization.Login, v.Repository.FullName), r.Content())
}
case "transferred":
r, _ := requests.Get(v.Sender.AvatarURL)
for _, v1 := range h.Groups {
m.b.SendGroupPicMsg(v1, fmt.Sprintf("%s在%s发布了新的仓库: %s\n欢迎Star哟", v.Sender.Login, v.Organization.Login, v.Repository.FullName), r.Content())
}
}

case github.PushPayload:
Expand Down

0 comments on commit c7c542a

Please sign in to comment.