public void Construct(PathGenericTuple <ModConfig> mod)
        {
            _modTuple = mod;
            string path = GithubConfig.GetFilePath(GetModDirectory(mod));

            _githubConfig     = GithubConfig.FromPath(path);
            _githubUserConfig = GithubUserConfig.FromPath(path);
        }
示例#2
0
 public GithubIssuesProvider(GithubConfig config)
 {
     _config = config;
     _client = new HttpClient
     {
         BaseAddress = new Uri(_config.BaseApiUrl)
     };
     _client.DefaultRequestHeaders.UserAgent.ParseAdd("Fiddler");
 }
示例#3
0
 public GithubHookController(IOptions <Config> config)
 {
     try
     {
         _config = config.Value.GithubConfig;
     }
     catch (ArgumentException e)
     {
         Console.WriteLine(e.Message);
     }
 }
        private async Task <IReadOnlyList <Release> > GetReleases(GithubConfig configuration)
        {
            try
            {
                var releases = await GithubClient.Repository.Release.GetAll(configuration.UserName, configuration.RepositoryName);

                ValidRateLimit = false;
                if (!_githubUserConfig.EnablePrereleases)
                {
                    releases = releases.Where(x => x.Prerelease == false).ToList();
                }

                return(releases);
            }
            catch { return(null); }
        }
        public bool IsCompatible(PathGenericTuple <ModConfig> mod)
        {
            try
            {
                if (Task.Run(AssertGithubOK).Result)
                {
                    string path = GithubConfig.GetFilePath(GetModDirectory(mod));

                    if (File.Exists(path) && AllowedMods.Contains(mod.Object))
                    {
                        return(true);
                    }
                }
            }
            catch (Exception) { }

            return(false);
        }
示例#6
0
        public ReadFromGithub(GithubConfig config, IEnumerable <GithubRepo> repos)
        {
            _config = config;

            Trace.Information("Logging into Github as {0}", _config.Login);

            _cli.Credentials = _config.GetCredentials();

            Trace.Information("Rate limit remaining: {0}", _cli.Miscellaneous.GetRateLimits().GetAwaiter().GetResult().Resources.Core.Remaining);

            _repos.AddRange(_config.Repos);

            Trace.Information("Using repos from config: {0}", String.Join(", ", _config.RepoPaths));

            _repos.AddRange(repos);

            Trace.Information("Using repos passed to constructor: {0}", String.Join(", ", repos));
        }
        static GithubLatestUpdateResolver()
        {
            try
            {
                GithubClient = new GitHubClient(new ProductHeaderValue("Reloaded-II"));

                // Get list of mods allowed to be updated this time around.
                var allMods            = ModConfig.GetAllMods();
                var allModsWithConfigs = allMods.Where(x => File.Exists(GithubConfig.GetFilePath(GetModDirectory(x))));

                MakeTimestampsIfNotExist(allModsWithConfigs);

                var orderedModsWithConfigs = allModsWithConfigs.OrderBy(x => GithubUserConfig.FromPath(GithubUserConfig.GetFilePath(GetModDirectory(x))).LastCheckTimestamp);
                var allowedMods            = orderedModsWithConfigs.Take(UnregisteredRateLimit).Select(x => x.Object);
                AllowedMods = new HashSet <ModConfig>(allowedMods);
            }
            catch (Exception)
            {
                Debugger.Break();
            }
        }
示例#8
0
 public RSGitService(GithubConfig config)
 {
     _config = config;
 }
示例#9
0
        static void getTweet()
        {
            JSON tweets = new JSON();

            var client = new GitHubClient(new ProductHeaderValue("what-the-repo"));

            GithubConfig githubConfig = new GithubConfig();

            var tokenAuth = new Credentials(githubConfig.ACCESS_TOKEN); // Can also authenticate using username and password

            client.Credentials = tokenAuth;

            string key = tweets.GetKeyword();

            // Search for repos
            var request = new SearchRepositoriesRequest(key)
            {
                // sort by the number of stars
                SortField = RepoSearchSort.Stars
            };

            Task.Run(async() =>
            {
                // Do any async anything you need here without worry
                var result = await client.Search.SearchRepo(request);

                Console.WriteLine("Fetching repos...");

                long repo_id;
                string date;
                string time;
                string body;

                int i = 0;

                while (true)
                {
                    var obj = result.Items[i];

                    DateTime today = DateTime.Today;
                    DateTime now   = DateTime.Now;

                    repo_id = obj.Id;
                    date    = today.ToString("dd/MM/yyyy");
                    time    = now.ToString("h:mm:ss tt");

                    body = getTweetBody(obj.HtmlUrl, obj.Name, obj.Description, obj.StargazersCount, obj.Language);

                    if (tweets.SearchTweets(repo_id) == false)
                    {
                        try
                        {
                            tweets.AddTweet(repo_id, date, time, body);
                            Global.tweetBody = body;
                            Console.WriteLine("Added tweet to json");
                            Global.counter += 1;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("An Error occurred : " + ex.Message.ToString());
                        }
                        break;
                    }
                    else
                    {
                        i += 1;                 // keep searching for repos that've not been tweeted so far
                    }
                }
            }).GetAwaiter().GetResult();

            //tweets.AddTweet(32423, "11/04/20", "11:00:00 a.m", "wtf");



            Console.WriteLine("------------");

            return;
        }
示例#10
0
 public RepositoryProvider(GithubConfig config)
 {
     _config = config;
 }
示例#11
0
 public ReadFromGithub(GithubConfig config, params (string owner, string name)[] repos)
 public GithubUpdateUploader(GithubConfig config)
 {
     Config = config;
 }