1
Fork 0
mirror of https://gitlab.com/Kwoth/nadekobot.git synced 2024-10-02 20:13:13 +00:00

.feed should now correctly display the message (if any)

This commit is contained in:
Kwoth 2024-04-24 23:48:43 +00:00
parent 006fa1a9fe
commit b34f383649
3 changed files with 34 additions and 5 deletions

View file

@ -23,6 +23,11 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
- You can now target a different channel with .repeat, for example `.repeat #some-other 1h Hello every hour`
- `.cmds <module name>` looks better / simpler
### Fixed
- `.feed` should now correctly accept (and show) the message which can be passed as the third parameter
## [4.3.22] - 23.04.2023
### Added

View file

@ -16,12 +16,23 @@ public partial class Searches
[Cmd]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)]
[Priority(1)]
public Task YtUploadNotif(string url, [Leftover] string message = null)
=> YtUploadNotif(url, null, message);
[Cmd]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)]
[Priority(2)]
public Task YtUploadNotif(string url, ITextChannel channel = null, [Leftover] string message = null)
{
var m = _ytChannelRegex.Match(url);
if (!m.Success)
return ReplyErrorLocalizedAsync(strs.invalid_input);
if (!((IGuildUser)ctx.User).GetPermissions(channel).MentionEveryone)
message = message?.SanitizeAllMentions();
var channelId = m.Groups["channelid"].Value;
return Feed($"https://www.youtube.com/feeds/videos.xml?channel_id={channelId}", channel, message);
@ -30,6 +41,15 @@ public partial class Searches
[Cmd]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)]
[Priority(0)]
public Task Feed(string url, [Leftover] string message = null)
=> Feed(url, null, message);
[Cmd]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ManageMessages)]
[Priority(1)]
public async Task Feed(string url, ITextChannel channel = null, [Leftover] string message = null)
{
if (!Uri.TryCreate(url, UriKind.Absolute, out var uri)
@ -39,6 +59,9 @@ public partial class Searches
return;
}
if (!((IGuildUser)ctx.User).GetPermissions(channel).MentionEveryone)
message = message?.SanitizeAllMentions();
channel ??= (ITextChannel)ctx.Channel;
try
{

View file

@ -173,7 +173,7 @@ public class FeedsService : INService
.Where(x => x.GuildConfig is not null)
.Select(x => _client.GetGuild(x.GuildConfig.GuildId)
?.GetTextChannel(x.ChannelId)
?.EmbedAsync(embed, x.Message))
?.EmbedAsync(embed, string.IsNullOrWhiteSpace(x.Message) ? "" : x.Message))
.Where(x => x is not null);
allSendTasks.Add(feedSendTasks.WhenAll());
@ -213,7 +213,8 @@ public class FeedsService : INService
var fs = new FeedSub
{
ChannelId = channelId,
Url = rssFeed.Trim()
Url = rssFeed.Trim(),
Message = message
};
using var uow = _db.GetDbContext();