Compare commits
2 commits
4ec6396c87
...
339237b351
Author | SHA1 | Date | |
---|---|---|---|
339237b351 | |||
91d464b041 |
3 changed files with 23 additions and 17 deletions
src/EllieBot/Modules
Administration
Permissions/Filter
Searches/StreamNotification
|
@ -107,12 +107,12 @@ public class AdministrationService : IEService, IReadyExecutor
|
||||||
.UpdateWithOutputAsync(x => new()
|
.UpdateWithOutputAsync(x => new()
|
||||||
{
|
{
|
||||||
DeleteMessageOnCommand = !x.DeleteMessageOnCommand
|
DeleteMessageOnCommand = !x.DeleteMessageOnCommand
|
||||||
});
|
}, (old, newVal) => newVal);
|
||||||
|
|
||||||
if (conf.Length == 0)
|
if (conf.Length == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var val = conf[0].Inserted.DeleteMessageOnCommand;
|
var val = conf[0].DeleteMessageOnCommand;
|
||||||
|
|
||||||
if (val)
|
if (val)
|
||||||
deleteMessagesOnCommand.Add(guildId);
|
deleteMessagesOnCommand.Add(guildId);
|
||||||
|
|
|
@ -52,12 +52,12 @@ public sealed class FilterService : IExecOnMessage, IReadyExecutor
|
||||||
await using var uow = _db.GetDbContext();
|
await using var uow = _db.GetDbContext();
|
||||||
|
|
||||||
var confs = await uow.GetTable<GuildFilterConfig>()
|
var confs = await uow.GetTable<GuildFilterConfig>()
|
||||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||||
.LoadWith(x => x.FilterInvitesChannelIds)
|
.LoadWith(x => x.FilterInvitesChannelIds)
|
||||||
.LoadWith(x => x.FilterWordsChannelIds)
|
.LoadWith(x => x.FilterWordsChannelIds)
|
||||||
.LoadWith(x => x.FilterLinksChannelIds)
|
.LoadWith(x => x.FilterLinksChannelIds)
|
||||||
.LoadWith(x => x.FilteredWords)
|
.LoadWith(x => x.FilteredWords)
|
||||||
.ToListAsyncLinqToDB();
|
.ToListAsyncLinqToDB();
|
||||||
|
|
||||||
foreach (var conf in confs)
|
foreach (var conf in confs)
|
||||||
{
|
{
|
||||||
|
@ -97,7 +97,7 @@ public sealed class FilterService : IExecOnMessage, IReadyExecutor
|
||||||
await using var uow = _db.GetDbContext();
|
await using var uow = _db.GetDbContext();
|
||||||
var fc = uow.FilterConfigForId(guildId,
|
var fc = uow.FilterConfigForId(guildId,
|
||||||
set => set.Include(x => x.FilteredWords)
|
set => set.Include(x => x.FilteredWords)
|
||||||
.Include(x => x.FilterWordsChannelIds));
|
.Include(x => x.FilterWordsChannelIds));
|
||||||
|
|
||||||
WordFilteringServers.TryRemove(guildId);
|
WordFilteringServers.TryRemove(guildId);
|
||||||
ServerFilteredWords.TryRemove(guildId, out _);
|
ServerFilteredWords.TryRemove(guildId, out _);
|
||||||
|
@ -140,7 +140,8 @@ public sealed class FilterService : IExecOnMessage, IReadyExecutor
|
||||||
var filteredChannelWords =
|
var filteredChannelWords =
|
||||||
FilteredWordsForChannel(usrMsg.Channel.Id, guild.Id) ?? new ConcurrentHashSet<string>();
|
FilteredWordsForChannel(usrMsg.Channel.Id, guild.Id) ?? new ConcurrentHashSet<string>();
|
||||||
var filteredServerWords = FilteredWordsForServer(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)
|
if (filteredChannelWords.Count != 0 || filteredServerWords.Count != 0)
|
||||||
{
|
{
|
||||||
foreach (var word in wordsInMessage)
|
foreach (var word in wordsInMessage)
|
||||||
|
@ -183,7 +184,8 @@ public sealed class FilterService : IExecOnMessage, IReadyExecutor
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((InviteFilteringChannels.Contains(usrMsg.Channel.Id) || InviteFilteringServers.Contains(guild.Id))
|
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",
|
Log.Information("User {UserName} [{UserId}] sent a filtered invite to {ChannelId} channel",
|
||||||
usrMsg.Author.ToString(),
|
usrMsg.Author.ToString(),
|
||||||
|
@ -219,7 +221,8 @@ public sealed class FilterService : IExecOnMessage, IReadyExecutor
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((LinkFilteringChannels.Contains(usrMsg.Channel.Id) || LinkFilteringServers.Contains(guild.Id))
|
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",
|
Log.Information("User {UserName} [{UserId}] sent a filtered link to {ChannelId} channel",
|
||||||
usrMsg.Author.ToString(),
|
usrMsg.Author.ToString(),
|
||||||
|
@ -246,10 +249,10 @@ public sealed class FilterService : IExecOnMessage, IReadyExecutor
|
||||||
await using var uow = _db.GetDbContext();
|
await using var uow = _db.GetDbContext();
|
||||||
|
|
||||||
var conf = await uow.GetTable<GuildFilterConfig>()
|
var conf = await uow.GetTable<GuildFilterConfig>()
|
||||||
.Where(fi => fi.GuildId == guildId)
|
.Where(fi => fi.GuildId == guildId)
|
||||||
.LoadWith(x => x.FilterInvitesChannelIds)
|
.LoadWith(x => x.FilterInvitesChannelIds)
|
||||||
.LoadWith(x => x.FilterLinksChannelIds)
|
.LoadWith(x => x.FilterLinksChannelIds)
|
||||||
.FirstOrDefaultAsyncLinqToDB();
|
.FirstOrDefaultAsyncLinqToDB();
|
||||||
|
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,7 +48,10 @@ public partial class Searches
|
||||||
return;
|
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]
|
[Cmd]
|
||||||
|
|
Loading…
Add table
Reference in a new issue