diff --git a/CHANGELOG.md b/CHANGELOG.md index f2a7a5002..f47c9a880 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog. ### Added - Added `.massban` to ban multiple people at once. 30 second cooldown +- Added `.youtubeuploadnotif` / `.yun` as a shortcut to a subscribing channel's rss feed ### Changed diff --git a/src/NadekoBot/Modules/Searches/FeedCommands.cs b/src/NadekoBot/Modules/Searches/FeedCommands.cs index 24b08ccfc..c884a92da 100644 --- a/src/NadekoBot/Modules/Searches/FeedCommands.cs +++ b/src/NadekoBot/Modules/Searches/FeedCommands.cs @@ -5,6 +5,7 @@ using NadekoBot.Extensions; using NadekoBot.Modules.Searches.Services; using System; using System.Linq; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Serilog; @@ -15,6 +16,25 @@ namespace NadekoBot.Modules.Searches [Group] public class FeedCommands : NadekoSubmodule { + private static readonly Regex YtChannelRegex = + new Regex(@"youtube\.com\/(?:c\/|channel\/|user\/)?(?[a-zA-Z0-9\-]{1,})"); + + [NadekoCommand, Aliases] + [RequireContext(ContextType.Guild)] + [UserPerm(GuildPerm.ManageMessages)] + public Task YtUploadNotif(string url, [Leftover] ITextChannel channel = null) + { + var m = YtChannelRegex.Match(url); + if (!m.Success) + { + return ReplyErrorLocalizedAsync(strs.invalid_input); + } + + var channelId = m.Groups["channelid"].Value; + + return Feed("https://www.youtube.com/feeds/videos.xml?channel_id=" + channelId, channel); + } + [NadekoCommand, Aliases] [RequireContext(ContextType.Guild)] [UserPerm(GuildPerm.ManageMessages)] diff --git a/src/NadekoBot/data/aliases.yml b/src/NadekoBot/data/aliases.yml index 4acca5e01..7436cc789 100644 --- a/src/NadekoBot/data/aliases.yml +++ b/src/NadekoBot/data/aliases.yml @@ -1140,6 +1140,9 @@ autobutts: eightball: - eightball - 8ball +ytuploadnotif: +- ytuploadnotif +- yun feed: - feed - feedadd diff --git a/src/NadekoBot/data/strings/commands/commands.en-US.yml b/src/NadekoBot/data/strings/commands/commands.en-US.yml index a721a662b..3cc008414 100644 --- a/src/NadekoBot/data/strings/commands/commands.en-US.yml +++ b/src/NadekoBot/data/strings/commands/commands.en-US.yml @@ -1912,6 +1912,12 @@ eightball: desc: "Ask the 8ball a yes/no question." args: - "Is b1nzy a nice guy?" +youtubeuploadnotif: + desc: |- + Subscribe to a youtube channel's upload rss feed. + Shortcut for `.feed https://www.youtube.com/feeds/videos.xml?channel_id=%3Cyoutube_channel_id` + args: + - "https://www.youtube.com/channel/UCSJ4gkVC6NrvII8umztf0Ow" feed: desc: "Subscribes to a feed. Bot will post an update up to once every 10 seconds. You can have up to 10 feeds on one server. All feeds must have unique URLs. Set a channel as a second optional parameter to specify where to send the updates." args: