public static async Task <List <ScriptInfo> > GetScripts(ScriptRepo repo) { using (RBotWebClient wc = new RBotWebClient()) { return(JsonConvert.DeserializeObject <List <ScriptInfo> >(await wc.DownloadStringTaskAsync(repo.ContentsUrl)).Where(x => x.FileName.EndsWith(".cs") && (x.Parent = repo) != null).ToList()); } }
public static async Task <List <ScriptRepo> > GetRepos() { using RBotWebClient wc = new RBotWebClient(); return((await wc.DownloadStringTaskAsync(BaseUrl)).Split('\n').Select(l => l.Trim().Split('|')).Where(p => p.Length == 4).Select(p => new ScriptRepo() { Username = p[0], Name = p[1], Extension = p[2], Author = p[3] }).ToList()); }
private async Task _DownloadScript(ScriptInfo info, DataGridViewRow row) { DirectoryInfo parent = Directory.GetParent(info.LocalFile); if (!parent.Exists) { parent.Create(); } using (RBotWebClient wc = new RBotWebClient()) { await wc.DownloadFileTaskAsync(info.DownloadUrl, info.LocalFile); File.WriteAllText(info.LocalShaFile, info.Hash); row.DefaultCellStyle.BackColor = Color.LightGreen; } }
private async Task <byte[]> Fix301(SessionEventArgs e) { byte[] data = null; using (RBotWebClient wc = new RBotWebClient()) { try { data = await wc.DownloadDataTaskAsync(e.HttpClient.Response.Headers.GetHeaders("Location")[0].Value); } catch (Exception ex) { Debug.WriteLine(ex); } } e.HttpClient.Response.StatusCode = 200; e.HttpClient.Response.Headers.RemoveHeader("Location"); return(data); }
public static async Task <List <WikiItem> > FindMethods(string url) { using (RBotWebClient wc = new RBotWebClient()) { string html = await wc.DownloadStringTaskAsync(url); string stripped = Regex.Replace(html, "(?!<a.*>|<\\/a>)(<.*?>)|((?! )\\s)", string.Empty); List <WikiItem> methods = new List <WikiItem>(); Regex shop = new Regex(ShopRegex, RegexOptions.IgnoreCase); Match match = shop.Match(html); if (match.Success) { methods.Add(new ShopReference() { Url = match.Groups[1].Value, Name = match.Groups[2].Value, Price = int.TryParse(match.Groups[3].Value.Replace(",", ""), out int i) ? i : 0, Coins = match.Groups[4].Value == "AC" });
public static async Task <List <UpdateInfo> > GetReleases() { using (RBotWebClient wc = new RBotWebClient()) return(JsonConvert.DeserializeObject <List <UpdateInfo> >(await wc.DownloadStringTaskAsync(ApiUrl))); }