public Task <OrdbokResponse> GetResponseOverrideAsync()
        {
            var article = new OrdbokArticle()
            {
                Forklaring = _mainResponse,
            };

            article.Tydinger.Add(new Tyding("1", _definition, new string[] {}));
            var rickRoll = new Uri("https://www.youtube.com/watch?v=dQw4w9WgXcQ");

            return(Task.FromResult(new OrdbokResponse(new List <OrdbokArticle> {
                article
            }, link: rickRoll)));
        }
Exemple #2
0
        private SlackAttachment CreateAtt(OrdbokArticle ordbokArticle)
        {
            var text = !ordbokArticle.Tydinger.Any() ? ordbokArticle.Forklaring : "";
            var att  = new SlackAttachment("", "")
            {
                Color    = "#aa6a0a",
                Fallback = ordbokArticle.Oppslagsord + " :: " + ordbokArticle.Forklaring + ". " + string.Join(",", ordbokArticle.Tydinger.Select(d => d.ToString())),
                Text     = text
            };

            foreach (var tyding in ordbokArticle.Tydinger)
            {
                var sf = new SlackField($"{tyding.Nummer}. {tyding.Tekst}", string.Join(", ", tyding.Eksempler));
                att.Fields.Add(sf);
            }

            return(att);
        }
        public List <OrdbokArticle> GetArticles()
        {
            var tables = HtmlDocument.DocumentNode.Descendants("table");
            var table  = tables.FirstOrDefault(n => n.HasAttributes && n.Attributes.Contains("id") && n.Attributes["id"].Value == "byttutBM");

            var articles = new List <OrdbokArticle>();

            if (table != null)
            {
                var rows = table.Descendants("tr").Skip(1); // skip header row
                foreach (var rowNode in rows)
                {
                    var article = new OrdbokArticle
                    {
                        Oppslagsord = GetOppslagsord(rowNode),
                        Tydinger    = GetTydinger(rowNode)
                    };

                    article.Forklaring = !article.Tydinger.Any() ? GetForklaring(rowNode) : article.Oppslagsord;
                    articles.Add(article);
                }
            }
            return(articles);
        }