Exemple #1
0
		/// <summary>
		/// Executes the syndication result on the given context.
		/// </summary>
		/// <param name="context">The current context.</param>
		public virtual void Write(IStreamResponse response) {
			var writer = new XmlTextWriter(response.OutputStream, Encoding.UTF8);
			var ui = new Client.Helpers.UIHelper();

			// Write headers
			response.ContentType = ContentType;
			response.ContentEncoding = Encoding.UTF8;

			var feed = new SyndicationFeed() { 
				Title = new TextSyndicationContent(Config.Site.Title),
				LastUpdatedTime = Posts.First().Published.Value,
				Description = new TextSyndicationContent(Config.Site.Description),
			};
			feed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(App.Env.AbsoluteUrl("~/"))));

			var items = new List<SyndicationItem>();
			foreach (var post in Posts) {
				var item = new SyndicationItem() { 
					Title = SyndicationContent.CreatePlaintextContent(post.Title),
					PublishDate = post.Published.Value,
					Summary = SyndicationContent.CreateHtmlContent(post.Body)
				};
				item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(App.Env.AbsoluteUrl("~/" + post.Type.Slug + "/" + post.Slug))));
				items.Add(item);
			}
			feed.Items = items;

			var formatter = GetFormatter(feed);
			formatter.WriteTo(writer);

			writer.Flush();
			writer.Close();
		}
Exemple #2
0
        public EmbedBuilder GetEmbed(FollowedStream fs, IStreamResponse status, ulong guildId)
        {
            var embed = new EmbedBuilder()
                        .WithTitle(fs.Username)
                        .WithUrl(GetLink(fs))
                        .WithDescription(GetLink(fs))
                        .AddField(efb => efb.WithName(GetText(fs, "status"))
                                  .WithValue(status.Live ? "Online" : "Offline")
                                  .WithIsInline(true))
                        .AddField(efb => efb.WithName(GetText(fs, "viewers"))
                                  .WithValue(status.Live ? status.Viewers.ToString() : "-")
                                  .WithIsInline(true))
                        .WithColor(status.Live ? NadekoBot.OkColor : NadekoBot.ErrorColor);


            if (!string.IsNullOrWhiteSpace(status.Title))
            {
                embed.WithAuthor(status.Title);
            }

            if (!string.IsNullOrWhiteSpace(status.Game))
            {
                embed.AddField(GetText(fs, "streaming"),
                               status.Game,
                               true);
            }

            embed.AddField(GetText(fs, "followers"),
                           status.Followers.ToString(),
                           true);

            if (!string.IsNullOrWhiteSpace(status.Icon))
            {
                embed.WithThumbnailUrl(status.Icon);
            }

            if (!string.IsNullOrWhiteSpace(status.StreamThumbnail))
            {
                embed.WithImageUrl(status.StreamThumbnail);
            }
            if (status.AdultStream == true)
            {
                embed.WithImageUrl("https://i.imgur.com/IvTOV9v.jpg");
            }

            return(embed);
        }
Exemple #3
0
        /// <summary>
        /// Executes the syndication result on the given context.
        /// </summary>
        /// <param name="context">The current context.</param>
        public virtual void Write(IStreamResponse response)
        {
            var writer = new XmlTextWriter(response.OutputStream, Encoding.UTF8);
            var ui     = new Client.Helpers.UIHelper();

            // Write headers
            response.ContentType     = ContentType;
            response.ContentEncoding = Encoding.UTF8;

            var feed = new SyndicationFeed()
            {
                Title           = new TextSyndicationContent(Config.Site.Title),
                LastUpdatedTime = Posts.First().Published.Value,
                Description     = new TextSyndicationContent(Config.Site.Description),
            };

            feed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(App.Env.AbsoluteUrl("~/"))));

            var items = new List <SyndicationItem>();

            foreach (var post in Posts)
            {
                var item = new SyndicationItem()
                {
                    Title       = SyndicationContent.CreatePlaintextContent(post.Title),
                    PublishDate = post.Published.Value,
                    Summary     = SyndicationContent.CreateHtmlContent(post.Body)
                };
                item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(App.Env.AbsoluteUrl("~/" + post.Type.Slug + "/" + post.Slug))));
                items.Add(item);
            }
            feed.Items = items;

            var formatter = GetFormatter(feed);

            formatter.WriteTo(writer);

            writer.Flush();
            writer.Close();
        }