Compare commits

...

2 commits

3 changed files with 68 additions and 57 deletions
CHANGELOG.md
src/EllieBot
EllieBot.csproj
Modules/Administration/Protection

View file

@ -2,6 +2,13 @@
*a,c,f,r,o* *a,c,f,r,o*
## [6.0.12] - 20.03.2025
### Fixed
- `.antispamignore` fixed for the last time hopefully
- protection commands are some of the oldest commands, and they might get overhauled in future updates
- please report if you find any other weird issue with them
## [6.0.11] - 20.03.2025 ## [6.0.11] - 20.03.2025
### Changed ### Changed

View file

@ -4,7 +4,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings> <ImplicitUsings>true</ImplicitUsings>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<Version>6.0.11</Version> <Version>6.0.12</Version>
<!-- Output/build --> <!-- Output/build -->
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> <RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>

View file

@ -27,6 +27,7 @@ public class ProtectionService : IReadyExecutor, IEService
private readonly UserPunishService _punishService; private readonly UserPunishService _punishService;
private readonly INotifySubscriber _notifySub; private readonly INotifySubscriber _notifySub;
private readonly ShardData _shardData; private readonly ShardData _shardData;
private readonly Channel<PunishQueueItem> _punishUserQueue = private readonly Channel<PunishQueueItem> _punishUserQueue =
Channel.CreateUnbounded<PunishQueueItem>(new() Channel.CreateUnbounded<PunishQueueItem>(new()
{ {
@ -176,10 +177,7 @@ public class ProtectionService : IReadyExecutor, IEService
try try
{ {
if (!_antiSpamGuilds.TryGetValue(channel.Guild.Id, out var spamSettings) if (!_antiSpamGuilds.TryGetValue(channel.Guild.Id, out var spamSettings)
|| spamSettings.AntiSpamSettings.IgnoredChannels.Contains(new() || spamSettings.AntiSpamSettings.IgnoredChannels.Any(x => x.ChannelId == channel.Id))
{
ChannelId = channel.Id
}))
return; return;
var stats = spamSettings.UserStats.AddOrUpdate(msg.Author.Id, var stats = spamSettings.UserStats.AddOrUpdate(msg.Author.Id,
@ -282,13 +280,15 @@ public class ProtectionService : IReadyExecutor, IEService
Seconds = seconds, Seconds = seconds,
UserThreshold = userThreshold, UserThreshold = userThreshold,
PunishDuration = minutesDuration PunishDuration = minutesDuration
}, _ => new() },
_ => new()
{ {
Action = action, Action = action,
Seconds = seconds, Seconds = seconds,
UserThreshold = userThreshold, UserThreshold = userThreshold,
PunishDuration = minutesDuration PunishDuration = minutesDuration
}, () => new() },
() => new()
{ {
GuildId = guildId GuildId = guildId
}); });
@ -370,14 +370,16 @@ public class ProtectionService : IReadyExecutor, IEService
MessageThreshold = stats.AntiSpamSettings.MessageThreshold, MessageThreshold = stats.AntiSpamSettings.MessageThreshold,
MuteTime = stats.AntiSpamSettings.MuteTime, MuteTime = stats.AntiSpamSettings.MuteTime,
RoleId = stats.AntiSpamSettings.RoleId RoleId = stats.AntiSpamSettings.RoleId
}, (old) => new() },
(old) => new()
{ {
GuildId = guildId, GuildId = guildId,
Action = stats.AntiSpamSettings.Action, Action = stats.AntiSpamSettings.Action,
MessageThreshold = stats.AntiSpamSettings.MessageThreshold, MessageThreshold = stats.AntiSpamSettings.MessageThreshold,
MuteTime = stats.AntiSpamSettings.MuteTime, MuteTime = stats.AntiSpamSettings.MuteTime,
RoleId = stats.AntiSpamSettings.RoleId RoleId = stats.AntiSpamSettings.RoleId
}, () => new() },
() => new()
{ {
GuildId = guildId GuildId = guildId
}); });
@ -405,7 +407,7 @@ public class ProtectionService : IReadyExecutor, IEService
if (spam.IgnoredChannels.All(x => x.ChannelId != channelId)) if (spam.IgnoredChannels.All(x => x.ChannelId != channelId))
{ {
if (_antiSpamGuilds.TryGetValue(guildId, out var temp)) if (_antiSpamGuilds.TryGetValue(guildId, out var temp))
temp.AntiSpamSettings.IgnoredChannels.Add(obj); // add to local cache temp.AntiSpamSettings.IgnoredChannels.Add(obj);
spam.IgnoredChannels.Add(obj); spam.IgnoredChannels.Add(obj);
added = true; added = true;
@ -417,7 +419,7 @@ public class ProtectionService : IReadyExecutor, IEService
uow.Set<AntiSpamIgnore>().Remove(toRemove); uow.Set<AntiSpamIgnore>().Remove(toRemove);
if (_antiSpamGuilds.TryGetValue(guildId, out var temp)) if (_antiSpamGuilds.TryGetValue(guildId, out var temp))
temp.AntiSpamSettings.IgnoredChannels.Remove(toRemove); // remove from local cache temp.AntiSpamSettings.IgnoredChannels.RemoveAll(x => x.ChannelId == channelId);
added = false; added = false;
} }
@ -468,13 +470,15 @@ public class ProtectionService : IReadyExecutor, IEService
ActionDurationMinutes = actionDurationMinutes, ActionDurationMinutes = actionDurationMinutes,
MinAge = TimeSpan.FromMinutes(minAgeMinutes), MinAge = TimeSpan.FromMinutes(minAgeMinutes),
RoleId = roleId RoleId = roleId
}, _ => new() },
_ => new()
{ {
Action = action, Action = action,
ActionDurationMinutes = actionDurationMinutes, ActionDurationMinutes = actionDurationMinutes,
MinAge = TimeSpan.FromMinutes(minAgeMinutes), MinAge = TimeSpan.FromMinutes(minAgeMinutes),
RoleId = roleId RoleId = roleId
}, () => new() },
() => new()
{ {
GuildId = guildId GuildId = guildId
}); });