diff --git a/src/EllieBot/Modules/Permissions/Filter/FilterService.cs b/src/EllieBot/Modules/Permissions/Filter/FilterService.cs index f596f1b..27c80b7 100644 --- a/src/EllieBot/Modules/Permissions/Filter/FilterService.cs +++ b/src/EllieBot/Modules/Permissions/Filter/FilterService.cs @@ -52,12 +52,12 @@ public sealed class FilterService : IExecOnMessage, IReadyExecutor await using var uow = _db.GetDbContext(); var confs = await uow.GetTable<GuildFilterConfig>() - .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) - .LoadWith(x => x.FilterInvitesChannelIds) - .LoadWith(x => x.FilterWordsChannelIds) - .LoadWith(x => x.FilterLinksChannelIds) - .LoadWith(x => x.FilteredWords) - .ToListAsyncLinqToDB(); + .Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId)) + .LoadWith(x => x.FilterInvitesChannelIds) + .LoadWith(x => x.FilterWordsChannelIds) + .LoadWith(x => x.FilterLinksChannelIds) + .LoadWith(x => x.FilteredWords) + .ToListAsyncLinqToDB(); foreach (var conf in confs) { @@ -97,7 +97,7 @@ public sealed class FilterService : IExecOnMessage, IReadyExecutor await using var uow = _db.GetDbContext(); var fc = uow.FilterConfigForId(guildId, set => set.Include(x => x.FilteredWords) - .Include(x => x.FilterWordsChannelIds)); + .Include(x => x.FilterWordsChannelIds)); WordFilteringServers.TryRemove(guildId); ServerFilteredWords.TryRemove(guildId, out _); @@ -140,7 +140,8 @@ public sealed class FilterService : IExecOnMessage, IReadyExecutor var filteredChannelWords = FilteredWordsForChannel(usrMsg.Channel.Id, guild.Id) ?? new ConcurrentHashSet<string>(); var filteredServerWords = FilteredWordsForServer(guild.Id) ?? new ConcurrentHashSet<string>(); - var wordsInMessage = usrMsg.Content.ToLowerInvariant().Split(' '); + var wordsInMessage = (usrMsg.Content + " " + usrMsg.ForwardedMessages.FirstOrDefault().Message?.Content) + .ToLowerInvariant().Split(' '); if (filteredChannelWords.Count != 0 || filteredServerWords.Count != 0) { foreach (var word in wordsInMessage) @@ -183,7 +184,8 @@ public sealed class FilterService : IExecOnMessage, IReadyExecutor return false; if ((InviteFilteringChannels.Contains(usrMsg.Channel.Id) || InviteFilteringServers.Contains(guild.Id)) - && usrMsg.Content.IsDiscordInvite()) + && (usrMsg.Content.IsDiscordInvite() || + usrMsg.ForwardedMessages.Any(x => x.Message?.Content.IsDiscordInvite() ?? false))) { Log.Information("User {UserName} [{UserId}] sent a filtered invite to {ChannelId} channel", usrMsg.Author.ToString(), @@ -219,7 +221,8 @@ public sealed class FilterService : IExecOnMessage, IReadyExecutor return false; if ((LinkFilteringChannels.Contains(usrMsg.Channel.Id) || LinkFilteringServers.Contains(guild.Id)) - && usrMsg.Content.TryGetUrlPath(out _)) + && (usrMsg.Content.TryGetUrlPath(out _) || + usrMsg.ForwardedMessages.Any(x => x.Message?.Content.TryGetUrlPath(out _) ?? false))) { Log.Information("User {UserName} [{UserId}] sent a filtered link to {ChannelId} channel", usrMsg.Author.ToString(), @@ -246,10 +249,10 @@ public sealed class FilterService : IExecOnMessage, IReadyExecutor await using var uow = _db.GetDbContext(); var conf = await uow.GetTable<GuildFilterConfig>() - .Where(fi => fi.GuildId == guildId) - .LoadWith(x => x.FilterInvitesChannelIds) - .LoadWith(x => x.FilterLinksChannelIds) - .FirstOrDefaultAsyncLinqToDB(); + .Where(fi => fi.GuildId == guildId) + .LoadWith(x => x.FilterInvitesChannelIds) + .LoadWith(x => x.FilterLinksChannelIds) + .FirstOrDefaultAsyncLinqToDB(); return new() { diff --git a/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationCommands.cs b/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationCommands.cs index 48fdd5b..2c14537 100644 --- a/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationCommands.cs +++ b/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationCommands.cs @@ -48,7 +48,10 @@ public partial class Searches return; } - await Response().Confirm(strs.stream_removed(Format.Bold(fs.Username), fs.Type)).SendAsync(); + await Response() + .Confirm(strs.stream_removed( + Format.Bold(string.IsNullOrWhiteSpace(fs.PrettyName) ? fs.Username : fs.PrettyName), + fs.Type)).SendAsync(); } [Cmd]