Example #1
0
        private Embed GenerateEmbed(TodayInWow todayInWow)
        {
            var embed = new EmbedBuilder();

            embed.Color = new Color(155, 89, 182);

            var title = $"Today in WoW";

            embed.Title = title.Length > 256 ? title.Substring(0, 256) : title;

            foreach (var section in todayInWow.Sections)
            {
                embed.AddField($"__{section.Title}__", new List <string> {
                    "Test", "Hest", "Lest"
                }, true);
                section.Entries.ForEach(e => embed.AddField($"{e}", new List <string> {
                    "Test", "Hest", "Lest"
                }, true));
            }

            // embed.AddField("__Age__", playerAge, true);
            // embed.AddField("__Country__", playerCountry, true);
            // embed.AddField("__Status__", GetIconedStatusString(application.CurrentStatusString), true);
            // embed.AddField("__Character Stats__", $"**Heart of Azeroth level:** {artifactLevel} \r\n**Avg ilvl:** {character.Items.AverageItemLevelEquipped}\r\n**Achi points:** {character.AchievementPoints} | **Total HKs:** {character.TotalHonorableKills}", false);
            // embed.AddField("__External sites__", $@"[Armory]({armoryProfileUrl}) | [RaiderIO](https://raider.io/characters/eu/{charAndRealm.realm}/{charAndRealm.name}) | [WoWProgress](https://www.wowprogress.com/character/eu/{charAndRealm.realm}/{charAndRealm.name}) | [WarcraftLogs](https://www.warcraftlogs.com/character/eu/{charAndRealm.realm}/{charAndRealm.name})", false);

            embed.Footer = new EmbedFooterBuilder();
            embed.Footer.WithIconUrl("https://render-eu.worldofwarcraft.com/character/karazhan/102/54145126-avatar.jpg");
            embed.Footer.Text = $"Requested by Veinlash - Today at {DateTimeExtensions.NowInCentralEuropeanTime().ToString("HH:mm")}";

            return(embed.Build());
        }
Example #2
0
        public TodayInWow GetTodayInWow()
        {
            string html = string.Empty;

            using (var webClient = new WebClient())
            {
                html = webClient.DownloadString("https://www.wowhead.com");
                Regex rRemScript = new Regex(@"<script[^>]*>[\s\S]*?</script>");
                html = rRemScript.Replace(html, string.Empty);
            }

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(html);

            var tiwSections = doc.DocumentNode.SelectNodes("//div[contains(@class,'tiw-region-EU')]//table[contains(@class,'tiw-group') and not( contains(@class,'tiw-blocks-warfront'))]");
            var warfronts   = doc.DocumentNode.SelectNodes("//div[contains(@class,'tiw-region-EU')]//table[contains(@class, 'tiw-group tiw-blocks-warfront')]");
            var assaults    = doc.DocumentNode.SelectNodes("//*[contains(@class,'tiw-assault-EU-wrapper')]");

            var todayInWow = new TodayInWow();

            todayInWow.Sections = tiwSections.Select(c => new TodayInWowSection {
                Title   = c.ChildNodes.First(n => n.Name == "tr").InnerText.StripTrim(),
                Entries = c.ChildNodes.Where(n => n.Name == "tr")
                          .Skip(1)
                          .Select(n => n.InnerText.StripTrim())
                          .ToList()
            }).ToList();

            var warfrontSections = warfronts.Select(n =>
                                                    new TodayInWowSection {
                Title   = n.SelectSingleChildNode("//div[contains(@class,'tiw-blocks-status-name')]").InnerText.StripTrim(),
                Entries = new List <string> {
                    n.SelectSingleChildNode("//div[contains(@class,'status-state')]").InnerText.StripTrim(),
                    n.SelectSingleChildNode("//div[contains(@class,'status-progress')]").InnerText.StripTrim()
                }
            }
                                                    );

            // var assaultSections = assaults.Select(n => new TodayInWowSection {
            //     Title = n.SelectSingleChildNode("//*[contains(@class,'tiw-blocks-status-name')]").InnerText.StripTrim(),
            //     Entries = new List<string> {
            //         ""
            //     }
            // });

            todayInWow.Sections.AddRange(warfrontSections);

            return(todayInWow);
        }