/// <summary> /// Build an <see cref="Embed"/>. /// </summary> public static void SendEmbed(string product, VersionsInfo oldVersion, VersionsInfo newVersion) { var isEncrypted = (product == "wowdev" || product == "wowv" || product == "wowv2"); var embed = new EmbedBuilder { Title = $"New Build for `{product}`", Description = $"⚠️ There is a new build for `{product}`! **{oldVersion.BuildId}** <:arrowJoin:740705934644609024> **{newVersion.BuildId}**\n" + $"{(isEncrypted ? "\n⛔ This build is **NOT** datamineable\n" : "")}" + $"\n**Build Config**:\n" + $"`{oldVersion.BuildConfig.Substring(0, 6)}` <:arrowJoin:740705934644609024> `{newVersion.BuildConfig.Substring(0, 6)}`" + $"\n**CDN Config**:\n" + $"`{oldVersion.CDNConfig.Substring(0, 6)}` <:arrowJoin:740705934644609024> `{newVersion.CDNConfig.Substring(0, 6)}`" + $"\n**Product Config**:\n" + $"`{oldVersion.ProductConfig.Substring(0, 6)}` <:arrowJoin:740705934644609024> `{newVersion.ProductConfig.Substring(0, 6)}`", Timestamp = DateTime.Now, // ThumbnailUrl = "https://www.clipartmax.com/png/middle/307-3072138_world-of-warcraft-2-discord-emoji-world-of-warcraft-w.png" }; // Send the message. Webhook.SendMessageAsync(embeds: new List <Embed>() { embed.Build() }); MrGMHook?.SendMessageAsync(embeds: new List <Embed>() { embed.Build() }); }
/// <summary> /// Handle the new version for the product. /// </summary> /// <param name="versions"></param> /// <param name="product"></param> /// <param name="stream"></param> static void HandleNewVersion(VersionsInfo versions, string product, string file) { var buildId = versionsIds[product]; var oldVersion = versionsInfo[buildId]; // Send the embed. DiscordServer.SendEmbed(product, oldVersion, versions); // Check if the products are not encrypted.. if (product == "wowdev" || product == "wowv" || product == "wowv2" || product == "wow_classic") { return; } Console.WriteLine($"Getting 'root' from '{versions.BuildConfig}'"); var oldRoot = BuildConfigToRoot(RequestCDN($"tpr/wow/config/{oldVersion.BuildConfig.Substring(0, 2)}/{oldVersion.BuildConfig.Substring(2, 2)}/{oldVersion.BuildConfig}")); var newRoot = BuildConfigToRoot(RequestCDN($"tpr/wow/config/{versions.BuildConfig.Substring(0, 2)}/{versions.BuildConfig.Substring(2, 2)}/{versions.BuildConfig}")); var addedFiles = Root.DiffRoot(oldRoot.Item1, newRoot.Item1).ToList(); if (addedFiles.Count > 1) { FilenameGuesser.ProcessFiles(product, addedFiles, oldVersion.BuildConfig, oldVersion.CDNConfig, versions.BuildId); } File.Delete($"cache/{product}_{oldVersion.BuildId}"); File.WriteAllText($"cache/{product}_{versions.BuildId}", File.ReadAllText(file)); }
/// <summary> /// Parse the 'versions' file from the servers. /// </summary> static void ParseVersions(string product, string file) { using (var reader = new StreamReader(file)) { // Skip the first 2 lines. reader.ReadLine(); reader.ReadLine(); var versions = new VersionsInfo(); var line = reader.ReadLine(); var lineSplit = line.Split('|'); versions.Region = lineSplit[0]; versions.BuildConfig = lineSplit[1]; versions.CDNConfig = lineSplit[2]; if (lineSplit[3] != string.Empty) { versions.KeyRing = lineSplit[3]; } versions.BuildId = uint.Parse(lineSplit[4]); versions.VersionsName = lineSplit[5]; versions.ProductConfig = lineSplit[6]; if (!versionsInfo.ContainsKey(versions.BuildId)) { versionsInfo.Add(versions.BuildId, versions); } if (!versionsIds.ContainsKey(product)) { versionsIds.Add(product, versions.BuildId); } if (versionsIds[product] != versions.BuildId) { HandleNewVersion(versions, product, file); // Update the product with the new Build Id versionsIds[product] = versions.BuildId; } } }