Compare commits
14 commits
Author | SHA1 | Date | |
---|---|---|---|
b9b53ef3e8 | |||
988d8c0250 | |||
082cf79736 | |||
612c230b7b | |||
775d77e94e | |||
f2820c980e | |||
947b3794e9 | |||
ba1f5afa01 | |||
8fa6b0c999 | |||
1cd02222b9 | |||
9af44d2220 | |||
cce4795f9b | |||
35d5b068be | |||
c0d2fb297e |
28 changed files with 259 additions and 299 deletions
CHANGELOG.md
src
EllieBot.GrpcApiBase/protos
EllieBot
Db
EllieBot.csprojMigrations/Sqlite
Modules
Administration
Mute
Notify
Protection
UserPunish
Gambling
Games/ChatterBot
Utility
Xp
Services/GrpcApi
_common
data
strings/responses
|
@ -2,7 +2,7 @@
|
|||
|
||||
*a,c,f,r,o*
|
||||
|
||||
## [6.0.3] - [12.03.2025]
|
||||
## [6.0.4] - 14.03.2025
|
||||
|
||||
### Added
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ service GrpcOther {
|
|||
rpc GetRoles(GetRolesRequest) returns (GetRolesReply);
|
||||
|
||||
rpc GetCurrencyLb(GetLbRequest) returns (CurrencyLbReply);
|
||||
rpc GetXpLb(GetLbRequest) returns (XpLbReply);
|
||||
rpc GetWaifuLb(GetLbRequest) returns (WaifuLbReply);
|
||||
|
||||
rpc GetShardStats(google.protobuf.Empty) returns (stream ShardStatsReply);
|
||||
|
@ -78,17 +77,6 @@ message GetLbRequest {
|
|||
int32 perPage = 2;
|
||||
}
|
||||
|
||||
message XpLbReply {
|
||||
repeated XpLbEntryReply entries = 1;
|
||||
}
|
||||
|
||||
message XpLbEntryReply {
|
||||
string user = 1;
|
||||
uint64 userId = 2;
|
||||
int64 totalXp = 3;
|
||||
int64 level = 4;
|
||||
}
|
||||
|
||||
message WaifuLbReply {
|
||||
repeated WaifuLbEntry entries = 1;
|
||||
}
|
||||
|
|
|
@ -10,22 +10,8 @@ service GrpcXp {
|
|||
|
||||
rpc GetXpSettings(GetXpSettingsRequest) returns (GetXpSettingsReply);
|
||||
|
||||
rpc AddExclusion(AddExclusionRequest) returns (AddExclusionReply);
|
||||
rpc DeleteExclusion(DeleteExclusionRequest) returns (DeleteExclusionReply);
|
||||
|
||||
rpc AddReward(AddRewardRequest) returns (AddRewardReply);
|
||||
rpc DeleteReward(DeleteRewardRequest) returns (DeleteRewardReply);
|
||||
|
||||
rpc SetServerExclusion(SetServerExclusionRequest) returns (SetServerExclusionReply);
|
||||
}
|
||||
|
||||
message SetServerExclusionRequest {
|
||||
uint64 guildId = 1;
|
||||
bool serverExcluded = 2;
|
||||
}
|
||||
|
||||
message SetServerExclusionReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message GetXpLbRequest {
|
||||
|
@ -57,47 +43,19 @@ message ResetUserXpReply {
|
|||
}
|
||||
|
||||
message GetXpSettingsReply {
|
||||
repeated ExclItemReply exclusions = 1;
|
||||
repeated RewItemReply rewards = 2;
|
||||
bool serverExcluded = 3;
|
||||
}
|
||||
|
||||
message GetXpSettingsRequest {
|
||||
uint64 guildId = 1;
|
||||
}
|
||||
|
||||
message ExclItemReply {
|
||||
string type = 1;
|
||||
uint64 id = 2;
|
||||
string name = 3;
|
||||
}
|
||||
|
||||
message RewItemReply {
|
||||
int32 level = 1;
|
||||
string type = 2;
|
||||
string value = 3;
|
||||
}
|
||||
|
||||
message AddExclusionRequest {
|
||||
uint64 guildId = 1;
|
||||
string type = 2;
|
||||
uint64 id = 3;
|
||||
}
|
||||
|
||||
message AddExclusionReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message DeleteExclusionRequest {
|
||||
uint64 guildId = 1;
|
||||
string type = 2;
|
||||
uint64 id = 3;
|
||||
}
|
||||
|
||||
message DeleteExclusionReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message AddRewardRequest {
|
||||
uint64 guildId = 1;
|
||||
int32 level = 2;
|
||||
|
|
|
@ -272,9 +272,6 @@ public abstract class EllieContext : DbContext
|
|||
du.Property(x => x.IsClubAdmin)
|
||||
.HasDefaultValue(false);
|
||||
|
||||
du.Property(x => x.NotifyOnLevelUp)
|
||||
.HasDefaultValue(XpNotificationLocation.None);
|
||||
|
||||
du.Property(x => x.TotalXp)
|
||||
.HasDefaultValue(0);
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
namespace EllieBot.Db.Models;
|
||||
|
||||
|
||||
// FUTURE remove LastLevelUp from here and UserXpStats
|
||||
public class DiscordUser : DbEntity
|
||||
{
|
||||
public const string DEFAULT_USERNAME = "??Unknown";
|
||||
|
@ -15,7 +13,6 @@ public class DiscordUser : DbEntity
|
|||
public bool IsClubAdmin { get; set; }
|
||||
|
||||
public long TotalXp { get; set; }
|
||||
public XpNotificationLocation NotifyOnLevelUp { get; set; }
|
||||
|
||||
public long CurrencyAmount { get; set; }
|
||||
|
||||
|
|
|
@ -21,4 +21,5 @@ public enum NotifyType
|
|||
Protection = 1, Prot = 1,
|
||||
AddRoleReward = 2,
|
||||
RemoveRoleReward = 3,
|
||||
// BigWin = 4,
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>true</ImplicitUsings>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
<Version>6.0.3</Version>
|
||||
<Version>6.0.4</Version>
|
||||
|
||||
<!-- Output/build -->
|
||||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BEGIN TRANSACTION;
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
DROP INDEX "IX_XpSettings_GuildConfigId";
|
||||
|
||||
|
@ -142,7 +142,8 @@ DELETE FROM VcRoleInfo WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELE
|
|||
UPDATE VcRoleInfo
|
||||
SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = VcRoleInfo.GuildConfigId);
|
||||
|
||||
DELETE FROM UnroleTimer WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs);
|
||||
DELETE FROM UnroleTimer WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs)
|
||||
OR (GuildId, UserId) IN (SELECT GuildId, UserId FROM UnroleTimer GROUP BY GuildId, UserId HAVING COUNT(*) > 1);
|
||||
UPDATE UnroleTimer
|
||||
SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = UnroleTimer.GuildConfigId);
|
||||
|
||||
|
@ -170,7 +171,8 @@ DELETE FROM Permissions WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SEL
|
|||
UPDATE Permissions
|
||||
SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = Permissions.GuildConfigId);
|
||||
|
||||
DELETE FROM MutedUserId WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs);
|
||||
DELETE FROM MutedUserId WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs)
|
||||
OR (GuildId, UserId) IN (SELECT GuildId, UserId FROM MutedUserId GROUP BY GuildId, UserId HAVING COUNT(*) > 1);
|
||||
UPDATE MutedUserId
|
||||
SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE GuildConfigs.Id = MutedUserId.GuildConfigId);
|
||||
|
||||
|
@ -761,4 +763,3 @@ INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
|
|||
VALUES ('20250126062816_cleanup', '8.0.8');
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
|
|
@ -15,7 +15,12 @@ public enum MuteType
|
|||
|
||||
public class MuteService : IEService, IReadyExecutor
|
||||
{
|
||||
public enum TimerType { Mute, Ban, AddRole }
|
||||
public enum TimerType
|
||||
{
|
||||
Mute,
|
||||
Ban,
|
||||
AddRole
|
||||
}
|
||||
|
||||
private static readonly OverwritePermissions _denyOverwrite = new(addReactions: PermValue.Deny,
|
||||
sendMessages: PermValue.Deny,
|
||||
|
@ -57,12 +62,12 @@ public class MuteService : IEService, IReadyExecutor
|
|||
return;
|
||||
|
||||
_ = Task.Run(() => _sender.Response(user)
|
||||
.Embed(_sender.CreateEmbed(user?.GuildId)
|
||||
.WithDescription($"You've been muted in {user.Guild} server")
|
||||
.AddField("Mute Type", type.ToString())
|
||||
.AddField("Moderator", mod.ToString())
|
||||
.AddField("Reason", reason))
|
||||
.SendAsync());
|
||||
.Embed(_sender.CreateEmbed(user?.GuildId)
|
||||
.WithDescription($"You've been muted in {user.Guild} server")
|
||||
.AddField("Mute Type", type.ToString())
|
||||
.AddField("Moderator", mod.ToString())
|
||||
.AddField("Reason", reason))
|
||||
.SendAsync());
|
||||
}
|
||||
|
||||
private void OnUserUnmuted(
|
||||
|
@ -75,12 +80,12 @@ public class MuteService : IEService, IReadyExecutor
|
|||
return;
|
||||
|
||||
_ = Task.Run(() => _sender.Response(user)
|
||||
.Embed(_sender.CreateEmbed(user.GuildId)
|
||||
.WithDescription($"You've been unmuted in {user.Guild} server")
|
||||
.AddField("Unmute Type", type.ToString())
|
||||
.AddField("Moderator", mod.ToString())
|
||||
.AddField("Reason", reason))
|
||||
.SendAsync());
|
||||
.Embed(_sender.CreateEmbed(user.GuildId)
|
||||
.WithDescription($"You've been unmuted in {user.Guild} server")
|
||||
.AddField("Unmute Type", type.ToString())
|
||||
.AddField("Moderator", mod.ToString())
|
||||
.AddField("Reason", reason))
|
||||
.SendAsync());
|
||||
}
|
||||
|
||||
private Task Client_UserJoined(IGuildUser usr)
|
||||
|
@ -105,8 +110,8 @@ public class MuteService : IEService, IReadyExecutor
|
|||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
var config = uow.GetTable<GuildConfig>()
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.FirstOrDefault();
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.FirstOrDefault();
|
||||
config.MuteRoleName = name;
|
||||
_guildMuteRoles.AddOrUpdate(guildId, name, (_, _) => name);
|
||||
await uow.SaveChangesAsync();
|
||||
|
@ -121,8 +126,12 @@ public class MuteService : IEService, IReadyExecutor
|
|||
if (type == MuteType.All)
|
||||
{
|
||||
try
|
||||
{ await usr.ModifyAsync(x => x.Mute = true); }
|
||||
catch { }
|
||||
{
|
||||
await usr.ModifyAsync(x => x.Mute = true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
var muteRole = await GetMuteRole(usr.Guild);
|
||||
if (!usr.RoleIds.Contains(muteRole.Id))
|
||||
|
@ -131,19 +140,19 @@ public class MuteService : IEService, IReadyExecutor
|
|||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
await uow.GetTable<MutedUserId>()
|
||||
.InsertOrUpdateAsync(() => new()
|
||||
{
|
||||
GuildId = usr.GuildId,
|
||||
UserId = usr.Id
|
||||
},
|
||||
(_) => new()
|
||||
{
|
||||
},
|
||||
() => new()
|
||||
{
|
||||
GuildId = usr.GuildId,
|
||||
UserId = usr.Id
|
||||
});
|
||||
.InsertOrUpdateAsync(() => new()
|
||||
{
|
||||
GuildId = usr.GuildId,
|
||||
UserId = usr.Id
|
||||
},
|
||||
(_) => new()
|
||||
{
|
||||
},
|
||||
() => new()
|
||||
{
|
||||
GuildId = usr.GuildId,
|
||||
UserId = usr.Id
|
||||
});
|
||||
|
||||
if (_mutedUsers.TryGetValue(usr.Guild.Id, out var muted))
|
||||
muted.Add(usr.Id);
|
||||
|
@ -160,7 +169,9 @@ public class MuteService : IEService, IReadyExecutor
|
|||
await usr.ModifyAsync(x => x.Mute = true);
|
||||
UserMuted(usr, mod, MuteType.Voice, reason);
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (type == MuteType.Chat)
|
||||
{
|
||||
|
@ -183,12 +194,12 @@ public class MuteService : IEService, IReadyExecutor
|
|||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
await uow.GetTable<MutedUserId>()
|
||||
.Where(x => x.GuildId == guildId && x.UserId == usrId)
|
||||
.DeleteAsync();
|
||||
.Where(x => x.GuildId == guildId && x.UserId == usrId)
|
||||
.DeleteAsync();
|
||||
|
||||
await uow.GetTable<UnmuteTimer>()
|
||||
.Where(x => x.GuildId == guildId && x.UserId == usrId)
|
||||
.DeleteAsync();
|
||||
.Where(x => x.GuildId == guildId && x.UserId == usrId)
|
||||
.DeleteAsync();
|
||||
|
||||
if (_mutedUsers.TryGetValue(guildId, out var muted))
|
||||
muted.TryRemove(usrId);
|
||||
|
@ -197,11 +208,17 @@ public class MuteService : IEService, IReadyExecutor
|
|||
if (usr is not null)
|
||||
{
|
||||
try
|
||||
{ await usr.ModifyAsync(x => x.Mute = false); }
|
||||
catch { }
|
||||
{
|
||||
await usr.ModifyAsync(x => x.Mute = false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{ await usr.RemoveRoleAsync(await GetMuteRole(usr.Guild)); }
|
||||
{
|
||||
await usr.RemoveRoleAsync(await GetMuteRole(usr.Guild));
|
||||
}
|
||||
catch
|
||||
{
|
||||
/*ignore*/
|
||||
|
@ -240,7 +257,9 @@ public class MuteService : IEService, IReadyExecutor
|
|||
//if it doesn't exist, create it
|
||||
{
|
||||
try
|
||||
{ muteRole = await guild.CreateRoleAsync(muteRoleName, isMentionable: false); }
|
||||
{
|
||||
muteRole = await guild.CreateRoleAsync(muteRoleName, isMentionable: false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
//if creations fails, maybe the name is not correct, find default one, if doesn't work, create default one
|
||||
|
@ -282,12 +301,12 @@ public class MuteService : IEService, IReadyExecutor
|
|||
{
|
||||
var unmuteAt = DateTime.UtcNow + after;
|
||||
await uow.GetTable<UnmuteTimer>()
|
||||
.InsertAsync(() => new()
|
||||
{
|
||||
GuildId = user.GuildId,
|
||||
UserId = user.Id,
|
||||
UnmuteAt = unmuteAt
|
||||
});
|
||||
.InsertAsync(() => new()
|
||||
{
|
||||
GuildId = user.GuildId,
|
||||
UserId = user.Id,
|
||||
UnmuteAt = unmuteAt
|
||||
});
|
||||
}
|
||||
|
||||
StartUn_Timer(user.GuildId, user.Id, after, TimerType.Mute); // start the timer
|
||||
|
@ -305,12 +324,12 @@ public class MuteService : IEService, IReadyExecutor
|
|||
{
|
||||
var unbanAt = DateTime.UtcNow + after;
|
||||
await uow.GetTable<UnbanTimer>()
|
||||
.InsertAsync(() => new()
|
||||
{
|
||||
GuildId = guild.Id,
|
||||
UserId = userId,
|
||||
UnbanAt = unbanAt
|
||||
});
|
||||
.InsertAsync(() => new()
|
||||
{
|
||||
GuildId = guild.Id,
|
||||
UserId = userId,
|
||||
UnbanAt = unbanAt
|
||||
});
|
||||
}
|
||||
|
||||
StartUn_Timer(guild.Id, userId, after, TimerType.Ban); // start the timer
|
||||
|
@ -415,83 +434,80 @@ public class MuteService : IEService, IReadyExecutor
|
|||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
var configs = await uow.Set<GuildConfig>()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
_guildMuteRoles = configs.Where(c => !string.IsNullOrWhiteSpace(c.MuteRoleName))
|
||||
.ToDictionary(c => c.GuildId, c => c.MuteRoleName)
|
||||
.ToConcurrent();
|
||||
.ToDictionary(c => c.GuildId, c => c.MuteRoleName)
|
||||
.ToConcurrent();
|
||||
|
||||
_mutedUsers = await uow.GetTable<MutedUserId>()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB()
|
||||
.Fmap(x => x.GroupBy(x => x.GuildId)
|
||||
.ToDictionary(g => g.Key, g => new ConcurrentHashSet<ulong>(g.Select(x => x.UserId)))
|
||||
.ToConcurrent());
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB()
|
||||
.Fmap(x => x.GroupBy(x => x.GuildId)
|
||||
.ToDictionary(g => g.Key, g => new ConcurrentHashSet<ulong>(g.Select(x => x.UserId)))
|
||||
.ToConcurrent());
|
||||
|
||||
var max = TimeSpan.FromDays(49);
|
||||
|
||||
var unmuteTimers = await uow.GetTable<UnmuteTimer>()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
var unbanTimers = await uow.GetTable<UnbanTimer>()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
var unroleTimers = await uow.GetTable<UnroleTimer>()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
foreach (var conf in configs)
|
||||
foreach (var x in unmuteTimers)
|
||||
{
|
||||
foreach (var x in unmuteTimers)
|
||||
TimeSpan after;
|
||||
if (x.UnmuteAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow)
|
||||
{
|
||||
TimeSpan after;
|
||||
if (x.UnmuteAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow)
|
||||
{
|
||||
after = TimeSpan.FromMinutes(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var unmute = x.UnmuteAt - DateTime.UtcNow;
|
||||
after = unmute > max ? max : unmute;
|
||||
}
|
||||
|
||||
StartUn_Timer(conf.GuildId, x.UserId, after, TimerType.Mute);
|
||||
after = TimeSpan.FromMinutes(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var unmute = x.UnmuteAt - DateTime.UtcNow;
|
||||
after = unmute > max ? max : unmute;
|
||||
}
|
||||
|
||||
foreach (var x in unbanTimers)
|
||||
{
|
||||
TimeSpan after;
|
||||
if (x.UnbanAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow)
|
||||
{
|
||||
after = TimeSpan.FromMinutes(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var unban = x.UnbanAt - DateTime.UtcNow;
|
||||
after = unban > max ? max : unban;
|
||||
}
|
||||
StartUn_Timer(x.GuildId, x.UserId, after, TimerType.Mute);
|
||||
}
|
||||
|
||||
StartUn_Timer(conf.GuildId, x.UserId, after, TimerType.Ban);
|
||||
foreach (var x in unbanTimers)
|
||||
{
|
||||
TimeSpan after;
|
||||
if (x.UnbanAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow)
|
||||
{
|
||||
after = TimeSpan.FromMinutes(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var unban = x.UnbanAt - DateTime.UtcNow;
|
||||
after = unban > max ? max : unban;
|
||||
}
|
||||
|
||||
foreach (var x in unroleTimers)
|
||||
{
|
||||
TimeSpan after;
|
||||
if (x.UnbanAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow)
|
||||
{
|
||||
after = TimeSpan.FromMinutes(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var unban = x.UnbanAt - DateTime.UtcNow;
|
||||
after = unban > max ? max : unban;
|
||||
}
|
||||
StartUn_Timer(x.GuildId, x.UserId, after, TimerType.Ban);
|
||||
}
|
||||
|
||||
StartUn_Timer(conf.GuildId, x.UserId, after, TimerType.AddRole, x.RoleId);
|
||||
foreach (var x in unroleTimers)
|
||||
{
|
||||
TimeSpan after;
|
||||
if (x.UnbanAt - TimeSpan.FromMinutes(2) <= DateTime.UtcNow)
|
||||
{
|
||||
after = TimeSpan.FromMinutes(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
var unban = x.UnbanAt - DateTime.UtcNow;
|
||||
after = unban > max ? max : unban;
|
||||
}
|
||||
|
||||
StartUn_Timer(x.GuildId, x.UserId, after, TimerType.AddRole, x.RoleId);
|
||||
}
|
||||
|
||||
_client.UserJoined += Client_UserJoined;
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
// using System.Globalization;
|
||||
// using EllieBot.Db.Models;
|
||||
// using EllieBot.Modules.Administration;
|
||||
//
|
||||
// namespace EllieBot.Modules.Gambling;
|
||||
//
|
||||
// public readonly record struct BigWinNotifyModel(
|
||||
// string GuildName,
|
||||
// ulong ChannelId,
|
||||
// ulong UserId,
|
||||
// string Amount)
|
||||
// : INotifyModel<BigWinNotifyModel>
|
||||
// {
|
||||
// public const string PH_USER = "user";
|
||||
// public const string PH_GUILD = "server";
|
||||
// public const string PH_AMOUNT = "amount";
|
||||
//
|
||||
// public static string KeyName
|
||||
// => "notify.bigwin";
|
||||
//
|
||||
// public static NotifyType NotifyType
|
||||
// => NotifyType.BigWin;
|
||||
//
|
||||
// public static bool SupportsOriginTarget
|
||||
// => true;
|
||||
//
|
||||
// public static IReadOnlyList<NotifyModelPlaceholderData<BigWinNotifyModel>> GetReplacements()
|
||||
// =>
|
||||
// [
|
||||
// new(PH_USER, static (data, g) => g.GetUser(data.UserId)?.ToString() ?? data.UserId.ToString()),
|
||||
// new(PH_AMOUNT, static (data, g) => data.Amount),
|
||||
// new(PH_GUILD, static (data, g) => data.GuildName)
|
||||
// ];
|
||||
//
|
||||
// public bool TryGetChannelId(out ulong channelId)
|
||||
// {
|
||||
// channelId = ChannelId;
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// public bool TryGetUserId(out ulong userId)
|
||||
// {
|
||||
// userId = UserId;
|
||||
// return true;
|
||||
// }
|
||||
// }
|
|
@ -4,6 +4,7 @@ using EllieBot.Common.ModuleBehaviors;
|
|||
using EllieBot.Db.Models;
|
||||
using EllieBot.Generators;
|
||||
using EllieBot.Modules.Administration.Services;
|
||||
using EllieBot.Modules.Gambling;
|
||||
using EllieBot.Modules.Xp.Services;
|
||||
|
||||
namespace EllieBot.Modules.Administration;
|
||||
|
|
|
@ -502,9 +502,10 @@ public class ProtectionService : IReadyExecutor, IEService
|
|||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
|
||||
var configs = await uow.GetTable<AntiAltSetting>()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
var gids = _client.GetGuildIds();
|
||||
var configs = await uow.Set<AntiAltSetting>()
|
||||
.Where(x => gids.Contains(x.GuildId))
|
||||
.ToListAsyncEF();
|
||||
|
||||
foreach (var config in configs)
|
||||
_antiAltGuilds[config.GuildId] = new(config);
|
||||
|
@ -522,6 +523,7 @@ public class ProtectionService : IReadyExecutor, IEService
|
|||
}
|
||||
|
||||
var spamConfigs = await uow.GetTable<AntiSpamSetting>()
|
||||
.AsNoTracking()
|
||||
.Where(x => Queries.GuildOnShard(x.GuildId, _shardData.TotalShards, _shardData.ShardId))
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
|
|
|
@ -716,8 +716,13 @@ public partial class Administration
|
|||
var banPrune = await _service.GetBanPruneAsync(ctx.Guild.Id) ?? 7;
|
||||
await ctx.Guild.AddBanAsync(user, banPrune, ("Softban | " + ctx.User + " | " + msg).TrimTo(512));
|
||||
try
|
||||
{ await ctx.Guild.RemoveBanAsync(user); }
|
||||
catch { await ctx.Guild.RemoveBanAsync(user); }
|
||||
{
|
||||
await ctx.Guild.RemoveBanAsync(user);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
var toSend = CreateEmbed()
|
||||
.WithOkColor()
|
||||
|
|
|
@ -15,13 +15,6 @@ using EllieBot.Modules.Gambling.Rps;
|
|||
using EllieBot.Common.TypeReaders;
|
||||
using EllieBot.Modules.Games;
|
||||
using EllieBot.Modules.Patronage;
|
||||
using SixLabors.Fonts;
|
||||
using SixLabors.Fonts.Unicode;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Drawing.Processing;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
using Color = SixLabors.ImageSharp.Color;
|
||||
|
||||
namespace EllieBot.Modules.Gambling;
|
||||
|
||||
|
|
|
@ -25,13 +25,11 @@ public class PlantPickService : IEService, IExecNoCommand, IReadyExecutor
|
|||
private readonly FontProvider _fonts;
|
||||
private readonly ICurrencyService _cs;
|
||||
private readonly CommandHandler _cmdHandler;
|
||||
private readonly EllieRandom _rng;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly GamblingConfigService _gss;
|
||||
private readonly GamblingService _gs;
|
||||
|
||||
private ConcurrentHashSet<ulong> _generationChannels;
|
||||
private readonly SemaphoreSlim _pickLock = new(1, 1);
|
||||
private ConcurrentHashSet<ulong> _generationChannels = [];
|
||||
|
||||
public PlantPickService(
|
||||
DbService db,
|
||||
|
@ -50,13 +48,9 @@ public class PlantPickService : IEService, IExecNoCommand, IReadyExecutor
|
|||
_fonts = fonts;
|
||||
_cs = cs;
|
||||
_cmdHandler = cmdHandler;
|
||||
_rng = new();
|
||||
_client = client;
|
||||
_gss = gss;
|
||||
_gs = gs;
|
||||
|
||||
using var uow = db.GetDbContext();
|
||||
var guildIds = client.Guilds.Select(x => x.Id).ToList();
|
||||
}
|
||||
|
||||
public Task ExecOnNoCommandAsync(IGuild guild, IUserMessage msg)
|
||||
|
@ -416,7 +410,6 @@ public class PlantPickService : IEService, IExecNoCommand, IReadyExecutor
|
|||
|
||||
public async Task OnReadyAsync()
|
||||
{
|
||||
|
||||
await using var uow = _db.GetDbContext();
|
||||
_generationChannels = (await uow.GetTable<GCChannelId>()
|
||||
.Select(x => x.ChannelId)
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace EllieBot.Modules.Games.Services;
|
|||
|
||||
public class ChatterBotService : IExecOnMessage, IReadyExecutor
|
||||
{
|
||||
private ConcurrentDictionary<ulong, Lazy<IChatterBotSession>> _chatterBotGuilds;
|
||||
private ConcurrentDictionary<ulong, Lazy<IChatterBotSession>> _chatterBotGuilds = [];
|
||||
|
||||
public int Priority
|
||||
=> 1;
|
||||
|
@ -165,8 +165,8 @@ public class ChatterBotService : IExecOnMessage, IReadyExecutor
|
|||
(inTokens) + (result.TokensOut / 2 * 3));
|
||||
|
||||
await _sender.Response(channel)
|
||||
.Confirm(result.Text)
|
||||
.SendAsync();
|
||||
.Confirm(result.Text)
|
||||
.SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -204,12 +204,12 @@ public class ChatterBotService : IExecOnMessage, IReadyExecutor
|
|||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
await uow.Set<GuildConfig>()
|
||||
.ToLinqToDBTable()
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.UpdateAsync((gc) => new GuildConfig()
|
||||
{
|
||||
CleverbotEnabled = false
|
||||
});
|
||||
.ToLinqToDBTable()
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.UpdateAsync((gc) => new GuildConfig()
|
||||
{
|
||||
CleverbotEnabled = false
|
||||
});
|
||||
await uow.SaveChangesAsync();
|
||||
return false;
|
||||
}
|
||||
|
@ -219,12 +219,12 @@ public class ChatterBotService : IExecOnMessage, IReadyExecutor
|
|||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
await uow.Set<GuildConfig>()
|
||||
.ToLinqToDBTable()
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.UpdateAsync((gc) => new GuildConfig()
|
||||
{
|
||||
CleverbotEnabled = true
|
||||
});
|
||||
.ToLinqToDBTable()
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.UpdateAsync((gc) => new GuildConfig()
|
||||
{
|
||||
CleverbotEnabled = true
|
||||
});
|
||||
|
||||
await uow.SaveChangesAsync();
|
||||
}
|
||||
|
@ -235,12 +235,13 @@ public class ChatterBotService : IExecOnMessage, IReadyExecutor
|
|||
public async Task OnReadyAsync()
|
||||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
_chatterBotGuilds = uow.GuildConfigs
|
||||
.AsNoTracking()
|
||||
.Where(gc => gc.CleverbotEnabled)
|
||||
.AsEnumerable()
|
||||
.ToDictionary(gc => gc.GuildId,
|
||||
_ => new Lazy<IChatterBotSession>(() => CreateSession(), true))
|
||||
.ToConcurrent();
|
||||
_chatterBotGuilds = await uow.GuildConfigs
|
||||
.AsNoTracking()
|
||||
.Where(gc => gc.CleverbotEnabled)
|
||||
.ToListAsyncLinqToDB()
|
||||
.Fmap(x => x
|
||||
.ToDictionary(gc => gc.GuildId,
|
||||
_ => new Lazy<IChatterBotSession>(() => CreateSession(), true))
|
||||
.ToConcurrent());
|
||||
}
|
||||
}
|
|
@ -642,9 +642,13 @@ public partial class Utility : EllieModule
|
|||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[OwnerOnly]
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
[Ratelimit(3600)]
|
||||
public async Task SaveChat(int cnt)
|
||||
{
|
||||
if (cnt > 1000)
|
||||
return;
|
||||
|
||||
var msgs = new List<IMessage>(cnt);
|
||||
await ctx.Channel.GetMessagesAsync(cnt).ForEachAsync(dled => msgs.AddRange(dled));
|
||||
|
||||
|
|
|
@ -314,8 +314,6 @@ public partial class Xp : EllieModule<XpService>
|
|||
$"""
|
||||
`{prefix}xpshop bgs`
|
||||
`{prefix}xpshop frames`
|
||||
|
||||
*{GetText(strs.xpshop_website)}*
|
||||
""")
|
||||
.SendAsync();
|
||||
}
|
||||
|
@ -372,11 +370,6 @@ public partial class Xp : EllieModule<XpService>
|
|||
if (!string.IsNullOrWhiteSpace(item.Desc))
|
||||
eb.AddField(GetText(strs.desc), item.Desc);
|
||||
|
||||
#if GLOBAL_NADEKO
|
||||
if (key == "default")
|
||||
eb.WithDescription(GetText(strs.xpshop_website));
|
||||
#endif
|
||||
|
||||
var tier = _service.GetXpShopTierRequirement(type);
|
||||
if (tier != PatronTier.None)
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -119,7 +119,7 @@ public class XpTemplate
|
|||
Pos = new()
|
||||
{
|
||||
X = 394,
|
||||
Y = 35
|
||||
Y = 40
|
||||
},
|
||||
Show = true
|
||||
}
|
||||
|
|
|
@ -111,31 +111,6 @@ public sealed class OtherSvc : GrpcOther.GrpcOtherBase, IGrpcSvc, IEService
|
|||
return reply;
|
||||
}
|
||||
|
||||
[GrpcNoAuthRequired]
|
||||
public override async Task<XpLbReply> GetXpLb(GetLbRequest request, ServerCallContext context)
|
||||
{
|
||||
var users = await _xp.GetGlobalUserXps(request.Page);
|
||||
|
||||
var reply = new XpLbReply();
|
||||
|
||||
var entries = users.Select(x =>
|
||||
{
|
||||
var lvl = new LevelStats(x.TotalXp);
|
||||
|
||||
return new XpLbEntryReply()
|
||||
{
|
||||
Level = lvl.Level,
|
||||
TotalXp = x.TotalXp,
|
||||
User = x.Username,
|
||||
UserId = x.UserId
|
||||
};
|
||||
});
|
||||
|
||||
reply.Entries.AddRange(entries);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
[GrpcNoAuthRequired]
|
||||
public override async Task<WaifuLbReply> GetWaifuLb(GetLbRequest request, ServerCallContext context)
|
||||
{
|
||||
|
|
|
@ -35,27 +35,10 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, IEService
|
|||
if (guild is null)
|
||||
throw new RpcException(new Status(StatusCode.NotFound, "Guild not found"));
|
||||
|
||||
var excludedChannels = new List<ulong>();
|
||||
var excludedRoles = new List<ulong>();
|
||||
var isServerExcluded = false;
|
||||
|
||||
var reply = new GetXpSettingsReply();
|
||||
|
||||
reply.Exclusions.AddRange(excludedChannels
|
||||
.Select(x => new ExclItemReply()
|
||||
{
|
||||
Id = x,
|
||||
Type = "Channel",
|
||||
Name = guild.GetChannel(x)?.Name ?? "????"
|
||||
})
|
||||
.Concat(excludedRoles
|
||||
.Select(x => new ExclItemReply()
|
||||
{
|
||||
Id = x,
|
||||
Type = "Role",
|
||||
Name = guild.GetRole(x)?.Name ?? "????"
|
||||
})));
|
||||
|
||||
var settings = await _xp.GetFullXpSettingsFor(request.GuildId);
|
||||
var curRews = settings.CurrencyRewards;
|
||||
var roleRews = settings.RoleRewards;
|
||||
|
@ -77,8 +60,6 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, IEService
|
|||
|
||||
reply.Rewards.AddRange(rews);
|
||||
|
||||
reply.ServerExcluded = isServerExcluded;
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ public class Localization : ILocalization, IReadyExecutor, IEService
|
|||
JsonConvert.DeserializeObject<Dictionary<string, CommandData>>(
|
||||
File.ReadAllText("./strings/commands/commands.en-US.json"));
|
||||
|
||||
private ConcurrentDictionary<ulong, CultureInfo> _guildCultureInfos;
|
||||
private ConcurrentDictionary<ulong, CultureInfo> _guildCultureInfos = [];
|
||||
|
||||
public IDictionary<ulong, CultureInfo> GuildCultureInfos
|
||||
=> _guildCultureInfos;
|
||||
|
|
|
@ -6,6 +6,8 @@ using EllieBot.Services.Currency;
|
|||
using EllieBot.Db.Models;
|
||||
using EllieBot.Modules.Gambling;
|
||||
using System.Collections.Concurrent;
|
||||
using EllieBot.Modules.Administration;
|
||||
using EllieBot.Modules.Gambling.Services;
|
||||
|
||||
namespace EllieBot.Services;
|
||||
|
||||
|
@ -20,10 +22,14 @@ public sealed class GamblingTxTracker : ITxTracker, IEService, IReadyExecutor
|
|||
private ConcurrentBag<UserBetStats> userStats = new();
|
||||
|
||||
private readonly DbService _db;
|
||||
private readonly GamblingConfigService _gcs;
|
||||
private readonly INotifySubscriber _notify;
|
||||
|
||||
public GamblingTxTracker(DbService db)
|
||||
public GamblingTxTracker(DbService db, GamblingConfigService gcs, INotifySubscriber notify)
|
||||
{
|
||||
_db = db;
|
||||
_gcs = gcs;
|
||||
_notify = notify;
|
||||
}
|
||||
|
||||
public async Task OnReadyAsync()
|
||||
|
@ -184,6 +190,12 @@ public sealed class GamblingTxTracker : ITxTracker, IEService, IReadyExecutor
|
|||
if (mType is not { } type)
|
||||
return Task.CompletedTask;
|
||||
|
||||
// var bigWin = _gcs.Data.BigWin;
|
||||
// if (bigWin > 0 && amount >= bigWin)
|
||||
// {
|
||||
// _notify.NotifyAsync<BigWinNotifyModel>(new())
|
||||
// }
|
||||
|
||||
if (txData.Type == "lula")
|
||||
{
|
||||
if (txData.Extra == "lose")
|
||||
|
|
|
@ -21,7 +21,7 @@ dice:
|
|||
- https://cdn.nadeko.bot/other/dice/8.png
|
||||
- https://cdn.nadeko.bot/other/dice/9.png
|
||||
xp:
|
||||
bg: https://cdn.nadeko.bot/xp/bgs/v6.png
|
||||
bg: https://cdn.nadeko.bot/other/xp/bg6_mini.png
|
||||
slots:
|
||||
emojis:
|
||||
- https://cdn.nadeko.bot/slots/10.png
|
||||
|
|
|
@ -8,21 +8,21 @@
|
|||
"Name": {
|
||||
"Color": "ffffffff",
|
||||
"Show": true,
|
||||
"FontSize": 50,
|
||||
"FontSize": 25,
|
||||
"Pos": {
|
||||
"X": 105,
|
||||
"Y": 25
|
||||
"X": 65,
|
||||
"Y": 8
|
||||
}
|
||||
},
|
||||
"Icon": {
|
||||
"Show": true,
|
||||
"Pos": {
|
||||
"X": 14,
|
||||
"Y": 14
|
||||
"X": 11,
|
||||
"Y": 11
|
||||
},
|
||||
"Size": {
|
||||
"X": 72,
|
||||
"Y": 71
|
||||
"X": 38,
|
||||
"Y": 38
|
||||
}
|
||||
},
|
||||
"Level": {
|
||||
|
@ -47,26 +47,26 @@
|
|||
"Bar": {
|
||||
"Show": true,
|
||||
"Guild": {
|
||||
"Color": "00000095",
|
||||
"Color": "00000066",
|
||||
"PointA": {
|
||||
"X": 282,
|
||||
"Y": 248
|
||||
"X": 202,
|
||||
"Y": 66
|
||||
},
|
||||
"PointB": {
|
||||
"X": 247,
|
||||
"Y": 379
|
||||
"X": 180,
|
||||
"Y": 145
|
||||
},
|
||||
"Length": 450,
|
||||
"Length": 225,
|
||||
"Direction": 3
|
||||
}
|
||||
},
|
||||
"Guild": {
|
||||
"Color": "ffffffff",
|
||||
"Show": true,
|
||||
"FontSize": 50,
|
||||
"FontSize": 25,
|
||||
"Pos": {
|
||||
"X": 490,
|
||||
"Y": 313
|
||||
"X": 330,
|
||||
"Y": 104
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,21 +75,21 @@
|
|||
"Icon": {
|
||||
"Show": true,
|
||||
"Pos": {
|
||||
"X": 722,
|
||||
"Y": 25
|
||||
"X": 451,
|
||||
"Y": 15
|
||||
},
|
||||
"Size": {
|
||||
"X": 45,
|
||||
"Y": 45
|
||||
"X": 29,
|
||||
"Y": 29
|
||||
}
|
||||
},
|
||||
"Name": {
|
||||
"Color": "ffffffff",
|
||||
"Show": true,
|
||||
"FontSize": 35,
|
||||
"FontSize": 20,
|
||||
"Pos": {
|
||||
"X": 650,
|
||||
"Y": 55
|
||||
"X": 394,
|
||||
"Y": 40
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1064,7 +1064,6 @@
|
|||
"patron_insuff_tier": "Your Patron Tier insufficient to perform this action.",
|
||||
"xpshop_already_owned": "You already own this item.",
|
||||
"xpshop_item_not_found": "An item with that key doesn't exist.",
|
||||
"xpshop_website": "You can see the list of all Xp Shop items here: <https://beta.elliebot.net>",
|
||||
"sticker_error": "You must either send a sticker along with this command, or upload a 300x300 .png or .apng image. Up to 512KB in size.",
|
||||
"sticker_missing_name": "Please specify a name for the sticker.",
|
||||
"thread_deleted": "Thread Deleted",
|
||||
|
|
Loading…
Add table
Reference in a new issue