static void Main(string[] args) { try { var platformNames = new[] { "CleverQQ", "MPQ", "CQP", "QQLight" }; foreach (var name in platformNames) { if (Path.GetFileNameWithoutExtension(name) .Equals(MahuaPlatformValueProvider.CurrentPlatform.Value.ToString(), StringComparison.OrdinalIgnoreCase)) { var webClient = new GammaLibrary.Enhancements.WebClientEx(); if (File.Exists(name)) { File.Delete(name); } webClient.Headers.Add("Authorization", "Bearer 6k1w2i924vgqpylm547l"); webClient.Headers.Add("Content-Type", "application/json"); webClient.Encoding = Encoding.UTF8; var content = webClient.DownloadString("https://ci.appveyor.com/api/projects/TRKS-Team/WFBot"); dynamic jsonInfo = (JObject)JsonConvert.DeserializeObject(content); try { webClient.DownloadFile($"http://cy.origind.ac.cn:8000/builds/{jsonInfo.build.version}/{name}.zip", name); Unzip(ZipFile.OpenRead(name)); } catch (Exception e) { Console.WriteLine(e); try { webClient.DownloadFile($"http://origind.ddns.net:8000/builds/{jsonInfo.build.version}/{name}.zip", name); Unzip(ZipFile.OpenRead(name)); } catch (Exception e2) { Console.WriteLine(e2); } } //Directory.Delete("YUELUO", true); } } } catch (Exception e) { Console.WriteLine(e); Console.WriteLine("自动更新失败. 请手动下载. https://github.com/TRKS-Team/WFBot"); Console.ReadKey(); } }
static void Main(string[] args) { var platformNames = new[] { "CleverQQ", "MPQ", "CQP", "QQLight" }; foreach (var name in platformNames) { if (Path.GetFileNameWithoutExtension(name) .Equals(MahuaPlatformValueProvider.CurrentPlatform.Value.ToString(), StringComparison.OrdinalIgnoreCase)) { var webClient = new GammaLibrary.Enhancements.WebClientEx(); if (File.Exists(name)) { File.Delete(name); } webClient.Headers.Add("Authorization", "Bearer 6k1w2i924vgqpylm547l"); webClient.Headers.Add("Content-Type", "application/json"); webClient.Encoding = Encoding.UTF8; var content = webClient.DownloadString("https://ci.appveyor.com/api/projects/TRKS-Team/WFBot"); dynamic jsonInfo = (JObject)JsonConvert.DeserializeObject(content); var value = webClient.DownloadString( $"https://ci.appveyor.com/api/buildjobs/{jsonInfo.build.jobs[0].jobId.Value}/artifacts"); dynamic jsonArt = new JArray(JsonConvert.DeserializeObject(value)); foreach (dynamic art in jsonArt[0]) { string n = art.fileName; if (Path.GetFileNameWithoutExtension(n).Equals(name, StringComparison.OrdinalIgnoreCase)) { a: try { webClient.DownloadFile($"https://ci.appveyor.com/api/buildjobs/{jsonInfo.build.jobs[0].jobId.Value}/artifacts/{art.fileName.Value}", name); } catch (Exception e) { Console.WriteLine(e); goto a; } //Directory.Delete("YUELUO", true); Unzip(ZipFile.OpenRead(name)); } } } } }