Beispiel #1
0
            public async Task ExecuteGroupAsync(CommandContext ctx,
                                                [Description("URL.")] Uri url,
                                                [RemainingText, Description("Friendly name.")] string name = null)
            {
                if (!RssService.IsValidFeedUrl(url.AbsoluteUri))
                {
                    throw new InvalidCommandUsageException("Given URL isn't a valid RSS feed URL.");
                }

                await this.Database.SubscribeAsync(ctx.Guild.Id, ctx.Channel.Id, url.AbsoluteUri, name);

                await this.InformAsync(ctx, $"Subscribed to {url}!", important : false);
            }
Beispiel #2
0
        public Task RssAsync(CommandContext ctx, [Description("RSS feed URL.")] Uri url)
        {
            if (!RssService.IsValidFeedUrl(url.AbsoluteUri))
            {
                throw new InvalidCommandUsageException("No results found for given URL (maybe forbidden?).");
            }

            var res = RssService.GetFeedResults(url.AbsoluteUri);

            if (res is null)
            {
                throw new CommandFailedException("Error getting feed from given URL.");
            }

            return(RssService.SendFeedResultsAsync(ctx.Channel, res));
        }