Compare commits
3 commits
ba1f5afa01
...
775d77e94e
Author | SHA1 | Date | |
---|---|---|---|
775d77e94e | |||
f2820c980e | |||
947b3794e9 |
3 changed files with 55 additions and 65 deletions
src/EllieBot
|
@ -2,6 +2,8 @@
|
|||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using LinqToDB.Mapping;
|
||||
using DataType = LinqToDB.DataType;
|
||||
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ public class ProtectionService : IReadyExecutor, IEService
|
|||
private readonly UserPunishService _punishService;
|
||||
private readonly INotifySubscriber _notifySub;
|
||||
private readonly ShardData _shardData;
|
||||
|
||||
private readonly Channel<PunishQueueItem> _punishUserQueue =
|
||||
Channel.CreateUnbounded<PunishQueueItem>(new()
|
||||
{
|
||||
|
@ -276,25 +275,23 @@ public class ProtectionService : IReadyExecutor, IEService
|
|||
await using var uow = _db.GetDbContext();
|
||||
|
||||
await uow.GetTable<AntiRaidSetting>()
|
||||
.InsertOrUpdateAsync(() => new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
Action = action,
|
||||
Seconds = seconds,
|
||||
UserThreshold = userThreshold,
|
||||
PunishDuration = minutesDuration
|
||||
},
|
||||
_ => new()
|
||||
{
|
||||
Action = action,
|
||||
Seconds = seconds,
|
||||
UserThreshold = userThreshold,
|
||||
PunishDuration = minutesDuration
|
||||
},
|
||||
() => new()
|
||||
{
|
||||
GuildId = guildId
|
||||
});
|
||||
.InsertOrUpdateAsync(() => new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
Action = action,
|
||||
Seconds = seconds,
|
||||
UserThreshold = userThreshold,
|
||||
PunishDuration = minutesDuration
|
||||
}, _ => new()
|
||||
{
|
||||
Action = action,
|
||||
Seconds = seconds,
|
||||
UserThreshold = userThreshold,
|
||||
PunishDuration = minutesDuration
|
||||
}, () => new()
|
||||
{
|
||||
GuildId = guildId
|
||||
});
|
||||
|
||||
|
||||
return stats;
|
||||
|
@ -365,25 +362,23 @@ public class ProtectionService : IReadyExecutor, IEService
|
|||
await using var uow = _db.GetDbContext();
|
||||
await uow.GetTable<AntiSpamSetting>()
|
||||
.InsertOrUpdateAsync(() => new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
Action = stats.AntiSpamSettings.Action,
|
||||
MessageThreshold = stats.AntiSpamSettings.MessageThreshold,
|
||||
MuteTime = stats.AntiSpamSettings.MuteTime,
|
||||
RoleId = stats.AntiSpamSettings.RoleId
|
||||
},
|
||||
(old) => new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
Action = stats.AntiSpamSettings.Action,
|
||||
MessageThreshold = stats.AntiSpamSettings.MessageThreshold,
|
||||
MuteTime = stats.AntiSpamSettings.MuteTime,
|
||||
RoleId = stats.AntiSpamSettings.RoleId
|
||||
},
|
||||
() => new()
|
||||
{
|
||||
GuildId = guildId
|
||||
});
|
||||
{
|
||||
GuildId = guildId,
|
||||
Action = stats.AntiSpamSettings.Action,
|
||||
MessageThreshold = stats.AntiSpamSettings.MessageThreshold,
|
||||
MuteTime = stats.AntiSpamSettings.MuteTime,
|
||||
RoleId = stats.AntiSpamSettings.RoleId
|
||||
}, (old) => new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
Action = stats.AntiSpamSettings.Action,
|
||||
MessageThreshold = stats.AntiSpamSettings.MessageThreshold,
|
||||
MuteTime = stats.AntiSpamSettings.MuteTime,
|
||||
RoleId = stats.AntiSpamSettings.RoleId
|
||||
}, () => new()
|
||||
{
|
||||
GuildId = guildId
|
||||
});
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
@ -464,24 +459,22 @@ public class ProtectionService : IReadyExecutor, IEService
|
|||
|
||||
await uow.GetTable<AntiAltSetting>()
|
||||
.InsertOrUpdateAsync(() => new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
Action = action,
|
||||
ActionDurationMinutes = actionDurationMinutes,
|
||||
MinAge = TimeSpan.FromMinutes(minAgeMinutes),
|
||||
RoleId = roleId
|
||||
},
|
||||
_ => new()
|
||||
{
|
||||
Action = action,
|
||||
ActionDurationMinutes = actionDurationMinutes,
|
||||
MinAge = TimeSpan.FromMinutes(minAgeMinutes),
|
||||
RoleId = roleId
|
||||
},
|
||||
() => new()
|
||||
{
|
||||
GuildId = guildId
|
||||
});
|
||||
{
|
||||
GuildId = guildId,
|
||||
Action = action,
|
||||
ActionDurationMinutes = actionDurationMinutes,
|
||||
MinAge = TimeSpan.FromMinutes(minAgeMinutes),
|
||||
RoleId = roleId
|
||||
}, _ => new()
|
||||
{
|
||||
Action = action,
|
||||
ActionDurationMinutes = actionDurationMinutes,
|
||||
MinAge = TimeSpan.FromMinutes(minAgeMinutes),
|
||||
RoleId = roleId
|
||||
}, () => new()
|
||||
{
|
||||
GuildId = guildId
|
||||
});
|
||||
|
||||
_antiAltGuilds[guildId] = new(new()
|
||||
{
|
||||
|
@ -509,9 +502,9 @@ public class ProtectionService : IReadyExecutor, IEService
|
|||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
|
||||
var gids = _client.GetGuildIds();
|
||||
var configs = await uow.Set<AntiAltSetting>()
|
||||
.AsNoTracking()
|
||||
.Where(x => x.GuildId / 4194304 % (ulong)_shardData.TotalShards == (ulong)_shardData.ShardId)
|
||||
.Where(x => gids.Contains(x.GuildId))
|
||||
.ToListAsyncEF();
|
||||
|
||||
foreach (var config in configs)
|
||||
|
@ -532,7 +525,7 @@ public class ProtectionService : IReadyExecutor, IEService
|
|||
var spamConfigs = await uow.GetTable<AntiSpamSetting>()
|
||||
.AsNoTracking()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncEF();
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
foreach (var config in spamConfigs)
|
||||
{
|
||||
|
|
|
@ -227,11 +227,6 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
|||
var oldStats = new LevelStats(u.Xp - data.Xp);
|
||||
var newStats = new LevelStats(u.Xp);
|
||||
|
||||
Log.Information("User {User} xp updated from {OldLevel} to {NewLevel}",
|
||||
u.UserId,
|
||||
oldStats.TotalXp,
|
||||
newStats.TotalXp);
|
||||
|
||||
if (oldStats.Level < newStats.Level)
|
||||
{
|
||||
await _levelUpQueue.EnqueueAsync(NotifyUser(u.GuildId,
|
||||
|
|
Loading…
Add table
Reference in a new issue