public void RemoveRssFeed(RssFeed rssFeed)
        {
            var rssFeeds = isolatedStorageSettings[RssFeedsKey] as Collection <RssFeed>;

            rssFeeds.Remove(rssFeed);
            RssFeeds.Remove(rssFeed);
            isolatedStorageSettings.Save();
            NotifyPropertyChanged("RssFeeds");
        }
示例#2
0
        /// <summary>
        /// Removes a feed from the list of feeds.
        /// After that the articles from that feed are also removed from the list of articles.
        /// </summary>
        /// <param name="url">URL of the feed to be removed</param>
        public void RemoveFeed(string url)
        {
            Feed feedToBeRemoved = null;

            for (var i = 0; i < RssFeeds.Count; i++)
            {
                if (RssFeeds[i].Link == url)
                {
                    feedToBeRemoved = RssFeeds[i];
                    RssFeeds.Remove(feedToBeRemoved);
                }
            }

            if (feedToBeRemoved == null)
            {
                return;
            }

            RemoveFeedItems(feedToBeRemoved);
        }
示例#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);
            }
        }