예제 #1
0
 private string[] ParseEventInfo(Event parse)
 {
     switch (parse.Type)
     {
         case "IssuesEvent":
             {
                 if (!HasIssues)
                 {
                     return new string[0];
                 }
                 IssuesPayload payload = new IssuesPayload(parse);
                 return new string[]
                 {
                     Bot.ColorGeneral + "[" + Bot.ColorHighlightMinor + parse.Repo.name + Bot.ColorGeneral + "] "
                             + Bot.ColorHighlightMajor + parse.Actor.login + Bot.ColorGeneral + " " + payload.Action + " an issue: "
                             + Bot.ColorHighlightMajor + payload.Title + Bot.ColorGeneral + " (" + Bot.ColorHighlightMajor + payload.Number
                             + Bot.ColorGeneral + ") --" + Bot.ColorLink  + " " + payload.ShortUrl
                 };
             }
         case "IssueCommentEvent":
             {
                 if (!HasIssues || !HasComments)
                 {
                     return new string[0];
                 }
                 IssuesPayload payload = new IssuesPayload(parse);
                 return new string[]
                 {
                     Bot.ColorGeneral + "[" + Bot.ColorHighlightMinor + parse.Repo.name + Bot.ColorGeneral + "] "
                             + Bot.ColorHighlightMajor + parse.Actor.login + Bot.ColorGeneral + " commented on an issue: "
                             + Bot.ColorHighlightMajor + payload.Title + Bot.ColorGeneral + " (" + Bot.ColorHighlightMajor + payload.Number
                             + Bot.ColorGeneral + ") --" + Bot.ColorLink  + " " + payload.ShortUrl
                 };
             }
         case "PullRequestEvent":
             {
                 if (!HasPulls)
                 {
                     return new string[0];
                 }
                 IssuesPayload payload = new IssuesPayload(parse);
                 return new string[]
                 {
                     Bot.ColorGeneral + "[" + Bot.ColorHighlightMinor + parse.Repo.name + Bot.ColorGeneral + "] "
                             + Bot.ColorHighlightMajor + parse.Actor.login + Bot.ColorGeneral + " " + payload.Action + " a pull request: "
                             + Bot.ColorHighlightMajor + payload.Title + Bot.ColorGeneral + " (" + Bot.ColorHighlightMajor + payload.Number
                             + Bot.ColorGeneral + ") --" + Bot.ColorLink  + " " + payload.ShortUrl
                 };
             }
         case "PullRequestReviewCommentEvent":
             {
                 if (!HasPulls || !HasComments)
                 {
                     return new string[0];
                 }
                 IssuesPayload payload = new IssuesPayload(parse);
                 return new string[]
                 {
                     Bot.ColorGeneral + "[" + Bot.ColorHighlightMinor + parse.Repo.name + Bot.ColorGeneral + "] "
                             + Bot.ColorHighlightMajor + parse.Actor.login + Bot.ColorGeneral + " commented on a pull request: "
                             + Bot.ColorHighlightMajor + payload.Title + Bot.ColorGeneral + " (" + Bot.ColorHighlightMajor + payload.Number
                             + Bot.ColorGeneral + ") --" + Bot.ColorLink  + " " + payload.ShortUrl
                 };
             }
         case "CommitCommentEvent":
             {
                 if (!HasComments)
                 {
                     return new string[0];
                 }
                 CommitCommentPayload payload = new CommitCommentPayload(parse);
                 return new string[]
                 {
                     Bot.ColorGeneral + "[" + Bot.ColorHighlightMinor + parse.Repo.name + Bot.ColorGeneral + "] "
                             + Bot.ColorHighlightMajor + parse.Actor.login + Bot.ColorGeneral + " commented on a commit: "
                             + Bot.ColorHighlightMajor + payload.CommitId + Bot.ColorGeneral + " --" + Bot.ColorLink  + " " + payload.ShortUrl
                 };
             }
         case "PushEvent":
             {
                 PushEventPayload payload = new PushEventPayload(parse);
                 string Ref = payload.Ref;
                 if (!WaitingCommits.ContainsKey(Ref))
                 {
                     WaitingCommits[Ref] = new List<Event.SimplifiedCommit>();
                 }
                 WaitingCommits[Ref].AddRange(payload.Commits);
                 return new string[0];
             }
         default:
             {
                 return new string[0];
             }
     }
 }
예제 #2
0
        private string[] ParseEventInfo(Event parse)
        {
            switch (parse.Type)
            {
            case "IssuesEvent":
            {
                if (!HasIssues)
                {
                    return(new string[0]);
                }
                IssuesPayload payload = new IssuesPayload(parse);
                return(new string[]
                    {
                        Bot.ColorGeneral + "[" + Bot.ColorHighlightMinor + parse.Repo.name + Bot.ColorGeneral + "] "
                        + Bot.ColorHighlightMajor + parse.Actor.login + Bot.ColorGeneral + " " + payload.Action + " an issue: "
                        + Bot.ColorHighlightMajor + payload.Title + Bot.ColorGeneral + " (" + Bot.ColorHighlightMajor + payload.Number
                        + Bot.ColorGeneral + ") --" + Bot.ColorLink + " " + payload.ShortUrl
                    });
            }

            case "IssueCommentEvent":
            {
                if (!HasIssues || !HasComments)
                {
                    return(new string[0]);
                }
                IssuesPayload payload = new IssuesPayload(parse);
                return(new string[]
                    {
                        Bot.ColorGeneral + "[" + Bot.ColorHighlightMinor + parse.Repo.name + Bot.ColorGeneral + "] "
                        + Bot.ColorHighlightMajor + parse.Actor.login + Bot.ColorGeneral + " commented on an issue: "
                        + Bot.ColorHighlightMajor + payload.Title + Bot.ColorGeneral + " (" + Bot.ColorHighlightMajor + payload.Number
                        + Bot.ColorGeneral + ") --" + Bot.ColorLink + " " + payload.ShortUrl
                    });
            }

            case "PullRequestEvent":
            {
                if (!HasPulls)
                {
                    return(new string[0]);
                }
                IssuesPayload payload = new IssuesPayload(parse);
                return(new string[]
                    {
                        Bot.ColorGeneral + "[" + Bot.ColorHighlightMinor + parse.Repo.name + Bot.ColorGeneral + "] "
                        + Bot.ColorHighlightMajor + parse.Actor.login + Bot.ColorGeneral + " " + payload.Action + " a pull request: "
                        + Bot.ColorHighlightMajor + payload.Title + Bot.ColorGeneral + " (" + Bot.ColorHighlightMajor + payload.Number
                        + Bot.ColorGeneral + ") --" + Bot.ColorLink + " " + payload.ShortUrl
                    });
            }

            case "PullRequestReviewCommentEvent":
            {
                if (!HasPulls || !HasComments)
                {
                    return(new string[0]);
                }
                IssuesPayload payload = new IssuesPayload(parse);
                return(new string[]
                    {
                        Bot.ColorGeneral + "[" + Bot.ColorHighlightMinor + parse.Repo.name + Bot.ColorGeneral + "] "
                        + Bot.ColorHighlightMajor + parse.Actor.login + Bot.ColorGeneral + " commented on a pull request: "
                        + Bot.ColorHighlightMajor + payload.Title + Bot.ColorGeneral + " (" + Bot.ColorHighlightMajor + payload.Number
                        + Bot.ColorGeneral + ") --" + Bot.ColorLink + " " + payload.ShortUrl
                    });
            }

            case "CommitCommentEvent":
            {
                if (!HasComments)
                {
                    return(new string[0]);
                }
                CommitCommentPayload payload = new CommitCommentPayload(parse);
                return(new string[]
                    {
                        Bot.ColorGeneral + "[" + Bot.ColorHighlightMinor + parse.Repo.name + Bot.ColorGeneral + "] "
                        + Bot.ColorHighlightMajor + parse.Actor.login + Bot.ColorGeneral + " commented on a commit: "
                        + Bot.ColorHighlightMajor + payload.CommitId + Bot.ColorGeneral + " --" + Bot.ColorLink + " " + payload.ShortUrl
                    });
            }

            case "PushEvent":
            {
                PushEventPayload payload = new PushEventPayload(parse);
                string           Ref     = payload.Ref;
                if (!WaitingCommits.ContainsKey(Ref))
                {
                    WaitingCommits[Ref] = new List <Event.SimplifiedCommit>();
                }
                WaitingCommits[Ref].AddRange(payload.Commits);
                return(new string[0]);
            }

            default:
            {
                return(new string[0]);
            }
            }
        }