示例#1
0
        /// <summary>
        /// Gets a list of open pull requests via GetPullRequests() method and dedups against PRs already
        /// tweeted as stored in the RunHistory
        /// </summary>
        /// <param name="runHistory"> Instance of RunHistory containing a list of previously-tweeted PRs</param>
        /// <returns> List of PullRequests that haven't already been tweeted </returns>
        public virtual async Task <List <PullRequest> > GetNewPullRequests(RunHistory runHistory)
        {
            var newPRs       = new List <PullRequest>();
            var pullRequests = await GetPullRequests();

            foreach (var pr in pullRequests)
            {
                if (!runHistory.PostedTweets.Contains(pr.Number))
                {
                    newPRs.Add(pr);
                }
            }

            return(newPRs);
        }
示例#2
0
        static void Main(string[] args)
        {
            //see README.md for info on how to set secrets on your system
            var apiKey            = Environment.GetEnvironmentVariable("TwitterApiKey");
            var apiKeySecret      = Environment.GetEnvironmentVariable("TwitterApiKeySecret");
            var accessToken       = Environment.GetEnvironmentVariable("TwitterAccessToken");
            var accessTokenSecret = Environment.GetEnvironmentVariable("TwitterAccessTokenSecret");

            if (apiKey != null && apiKeySecret != null && accessToken != null && accessTokenSecret != null)
            {
                var twitterClient    = new TwitterHttpClient(apiKey, apiKeySecret, accessToken, accessTokenSecret);
                var gitHubHttpClient = new GitHubHttpClient();
                var runHistory       = new RunHistory();

                var app = new UpdateTwitterStatus(twitterClient, gitHubHttpClient, runHistory);
                app.Run().Wait();
            }
            else
            {
                Console.Error.WriteLine("Could not read Twitter secrets from environment variables. Aborting.");
            }
        }
示例#3
0
 /// <summary>
 /// Constructor sets API clients and run history
 /// </summary>
 /// <param name="twitterClient"> Twitter API client </param>
 /// <param name="gitHubClient"> Github API client </param>
 /// <param name="runHistory"> The run history of tweets posted </param>
 public UpdateTwitterStatus(TwitterHttpClient twitterClient, GitHubHttpClient gitHubClient, RunHistory runHistory)
 {
     this.twitterClient    = twitterClient;
     this.gitHubHttpClient = gitHubClient;
     this.RunHistory       = runHistory;
 }