Пример #1
0
        /// <summary>
        /// Adds a new feed to the list of feeds.
        /// The feed is downloaded and the articles are added to the list of articles as well.
        /// </summary>
        /// <param name="url">The url of the feed to be added</param>
        public async void AddFeed(string url)
        {
            var favorites = FavoritesManager.Instance.GetFavorites();

            var result = await RssManager.Instance.GetFeeds(url);

            var feed = result.First();

            RssFeeds.Add(feed);

            List <EasyNewsFeedItem> easyFeedItems = new List <EasyNewsFeedItem>();

            foreach (var feedItem in feed.Items)
            {
                var isFav        = favorites.Contains(feedItem);
                var easyFeedItem = new EasyNewsFeedItem(feedItem, isFav);
                // Parse Image URL
                easyFeedItem.ImageLink = RssManager.Instance.GetImageUrl(feedItem);
                // Strip HTML tags
                easyFeedItem.Description = RssManager.Instance.StripHtml(feedItem.Description);
                // Add the item at the correct position;
                easyFeedItems.Add(easyFeedItem);
            }
            AddFeedItems(easyFeedItems);
        }
 public void UpdateRssFeeds()
 {
     if (isolatedStorageSettings.Contains(RssFeedKey))
     {
         var rssFeed = isolatedStorageSettings[RssFeedKey] as RssFeed;
         if (!RssFeeds.Contains(rssFeed))
         {
             RssFeeds.Add(rssFeed);
             var rssFeeds = isolatedStorageSettings[RssFeedsKey] as Collection <RssFeed>;
             rssFeeds.Add(rssFeed);
         }
         isolatedStorageSettings.Remove(RssFeedKey);
     }
     RssFeeds = new ObservableCollection <RssFeed>(_rssFeeds);
 }
Пример #3
0
        public async Task Initialise()
        {
            if (RssFeeds.Any(x => x.GuildId == Context.Guild.Id))
            {
                await ReplyAsync("", false, new EmbedBuilder
                {
                    Description = $"Server Already Initialised",
                    Color       = Color.Red
                });

                return;
            }
            var server = new RssObject
            {
                GuildId    = Context.Guild.Id,
                ChannelId  = Context.Channel.Id,
                Embed      = true,
                Formatting = "New Post in $postroot\n" +
                             "[$posttitle]($postlink)\n\n" +
                             "$postcontent"
            };

            if (RssFeeds.Any(x => x.GuildId == Context.Guild.Id))
            {
                RssFeeds.Remove(RssFeeds.First(x => x.GuildId == Context.Guild.Id));
            }
            RssFeeds.Add(server);

            await ReplyAsync("", false, new EmbedBuilder
            {
                Description = $"Server Initialised",
                Color       = Color.Blue
            });

            if (RssFeeds != null)
            {
                var feeds = JsonConvert.SerializeObject(RssFeeds, Newtonsoft.Json.Formatting.Indented);
                File.WriteAllText(Path.Combine(AppContext.BaseDirectory, "setup/RSS.json"), feeds);
            }
        }