From 5e7c75a498f0b307a36320d6a9270601c9e49325 Mon Sep 17 00:00:00 2001 From: Toastie Date: Sat, 29 Jun 2024 17:49:10 +1200 Subject: [PATCH 1/4] Disabled honeypot system This system is being a little buggy and will be fixed in the future --- .../Modules/Administration/Honeypot/HoneyPotService.cs | 8 +++++--- .../Modules/Administration/Honeypot/HoneypotCommands.cs | 7 ++++--- .../Modules/Administration/Honeypot/IHoneyPotService.cs | 7 ++++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/EllieBot/Modules/Administration/Honeypot/HoneyPotService.cs b/src/EllieBot/Modules/Administration/Honeypot/HoneyPotService.cs index ab0d0f0..8108aad 100644 --- a/src/EllieBot/Modules/Administration/Honeypot/HoneyPotService.cs +++ b/src/EllieBot/Modules/Administration/Honeypot/HoneyPotService.cs @@ -5,7 +5,7 @@ using EllieBot.Db.Models; using System.Threading.Channels; namespace EllieBot.Modules.Administration.Honeypot; - +/* public sealed class HoneyPotService : IHoneyPotService, IReadyExecutor, IExecNoCommand, IEService { private readonly DbService _db; @@ -71,7 +71,8 @@ public sealed class HoneyPotService : IHoneyPotService, IReadyExecutor, IExecNoC try { Log.Information("Honeypot caught user {User} [{UserId}]", user, user.Id); - await user.BanAsync(); + await user.BanAsync(pruneDays: 1); + await user.Guild.RemoveBanAsync(user.Id); } catch (Exception e) { @@ -91,4 +92,5 @@ public sealed class HoneyPotService : IHoneyPotService, IReadyExecutor, IExecNoC await _punishments.Writer.WriteAsync(sgu); } } -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/src/EllieBot/Modules/Administration/Honeypot/HoneypotCommands.cs b/src/EllieBot/Modules/Administration/Honeypot/HoneypotCommands.cs index 479e975..9a1f5b3 100644 --- a/src/EllieBot/Modules/Administration/Honeypot/HoneypotCommands.cs +++ b/src/EllieBot/Modules/Administration/Honeypot/HoneypotCommands.cs @@ -1,7 +1,7 @@ -using EllieBot.Modules.Administration.Honeypot; +using EllieBot.Modules.Administration.Honeypot; namespace EllieBot.Modules.Administration; - +/* public partial class Administration { [Group] @@ -26,4 +26,5 @@ public partial class Administration await Response().Confirm(strs.honeypot_off).SendAsync(); } } -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/src/EllieBot/Modules/Administration/Honeypot/IHoneyPotService.cs b/src/EllieBot/Modules/Administration/Honeypot/IHoneyPotService.cs index e6d6c20..c64e7b9 100644 --- a/src/EllieBot/Modules/Administration/Honeypot/IHoneyPotService.cs +++ b/src/EllieBot/Modules/Administration/Honeypot/IHoneyPotService.cs @@ -1,6 +1,7 @@ -namespace EllieBot.Modules.Administration.Honeypot; - +namespace EllieBot.Modules.Administration.Honeypot; +/* public interface IHoneyPotService { public Task ToggleHoneypotChannel(ulong guildId, ulong channelId); -} \ No newline at end of file +} +*/ \ No newline at end of file From c5cd772126afd480dea82d80508f3c496d140345 Mon Sep 17 00:00:00 2001 From: Toastie Date: Sat, 29 Jun 2024 17:50:16 +1200 Subject: [PATCH 2/4] Updated Db models --- src/EllieBot/Db/EllieContext.cs | 52 +++++++++---------- src/EllieBot/Db/EllieDbService.cs | 10 ++-- src/EllieBot/Db/LevelStats.cs | 1 + src/EllieBot/Db/Models/DiscordUser.cs | 1 + src/EllieBot/Db/Models/HoneypotChannel.cs | 4 +- .../Db/Models/anti/AntiRaidSetting.cs | 1 + src/EllieBot/Db/Models/support/PatronQuota.cs | 6 +-- 7 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/EllieBot/Db/EllieContext.cs b/src/EllieBot/Db/EllieContext.cs index 8f5c2d8..860e834 100644 --- a/src/EllieBot/Db/EllieContext.cs +++ b/src/EllieBot/Db/EllieContext.cs @@ -1,4 +1,4 @@ -#nullable disable +#nullable disable using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using EllieBot.Db.Models; @@ -149,7 +149,7 @@ public abstract class EllieContext : DbContext .OnDelete(DeleteBehavior.Cascade); // start antispam - + modelBuilder.Entity() .HasOne(x => x.AntiSpamSetting) .WithOne() @@ -282,10 +282,10 @@ public abstract class EllieContext : DbContext var selfassignableRolesEntity = modelBuilder.Entity(); selfassignableRolesEntity.HasIndex(s => new - { - s.GuildId, - s.RoleId - }) + { + s.GuildId, + s.RoleId + }) .IsUnique(); selfassignableRolesEntity.Property(x => x.Group).HasDefaultValue(0); @@ -358,10 +358,10 @@ public abstract class EllieContext : DbContext var xps = modelBuilder.Entity(); xps.HasIndex(x => new - { - x.UserId, - x.GuildId - }) + { + x.UserId, + x.GuildId + }) .IsUnique(); xps.HasIndex(x => x.UserId); @@ -407,9 +407,9 @@ public abstract class EllieContext : DbContext .OnDelete(DeleteBehavior.SetNull); ci.HasIndex(x => new - { - x.Name - }) + { + x.Name + }) .IsUnique(); #endregion @@ -528,10 +528,10 @@ public abstract class EllieContext : DbContext .IsUnique(false); rr2.HasIndex(x => new - { - x.MessageId, - x.Emote - }) + { + x.MessageId, + x.Emote + }) .IsUnique(); }); @@ -606,11 +606,11 @@ public abstract class EllieContext : DbContext { // user can own only one of each item x.HasIndex(model => new - { - model.UserId, - model.ItemType, - model.ItemKey - }) + { + model.UserId, + model.ItemType, + model.ItemKey + }) .IsUnique(); }); @@ -635,10 +635,10 @@ public abstract class EllieContext : DbContext #region Sticky Roles modelBuilder.Entity(sr => sr.HasIndex(x => new - { - x.GuildId, - x.UserId - }) + { + x.GuildId, + x.UserId + }) .IsUnique()); #endregion diff --git a/src/EllieBot/Db/EllieDbService.cs b/src/EllieBot/Db/EllieDbService.cs index 2a3382e..52e0bf9 100644 --- a/src/EllieBot/Db/EllieDbService.cs +++ b/src/EllieBot/Db/EllieDbService.cs @@ -4,14 +4,14 @@ using Microsoft.EntityFrameworkCore; namespace EllieBot.Db; -public sealed class EllieDbService : DbService +public sealed class EllieDbService : DbService { private readonly IBotCredsProvider _creds; // these are props because creds can change at runtime private string DbType => _creds.GetCreds().Db.Type.ToLowerInvariant().Trim(); private string ConnString => _creds.GetCreds().Db.ConnectionString; - + public EllieDbService(IBotCredsProvider creds) { LinqToDBForEFTools.Initialize(); @@ -26,13 +26,13 @@ public sealed class EllieDbService : DbService var connString = ConnString; await using var context = CreateRawDbContext(dbType, connString); - + // make sure sqlite db is in wal journal mode if (context is SqliteContext) { await context.Database.ExecuteSqlRawAsync("PRAGMA journal_mode=WAL"); } - + await context.Database.MigrateAsync(); } @@ -52,7 +52,7 @@ public sealed class EllieDbService : DbService throw new NotSupportedException($"The database provide type of '{dbType}' is not supported."); } } - + private EllieContext GetDbContextInternal() { var dbType = DbType; diff --git a/src/EllieBot/Db/LevelStats.cs b/src/EllieBot/Db/LevelStats.cs index 0f3e02c..25a3936 100644 --- a/src/EllieBot/Db/LevelStats.cs +++ b/src/EllieBot/Db/LevelStats.cs @@ -1,4 +1,5 @@ #nullable disable + namespace EllieBot.Db; public readonly struct LevelStats diff --git a/src/EllieBot/Db/Models/DiscordUser.cs b/src/EllieBot/Db/Models/DiscordUser.cs index cae2bb3..69eecb6 100644 --- a/src/EllieBot/Db/Models/DiscordUser.cs +++ b/src/EllieBot/Db/Models/DiscordUser.cs @@ -1,6 +1,7 @@ #nullable disable namespace EllieBot.Db.Models; + // FUTURE remove LastLevelUp from here and UserXpStats public class DiscordUser : DbEntity { diff --git a/src/EllieBot/Db/Models/HoneypotChannel.cs b/src/EllieBot/Db/Models/HoneypotChannel.cs index 418543a..bd074c9 100644 --- a/src/EllieBot/Db/Models/HoneypotChannel.cs +++ b/src/EllieBot/Db/Models/HoneypotChannel.cs @@ -6,6 +6,6 @@ public class HoneypotChannel { [Key] public ulong GuildId { get; set; } - + public ulong ChannelId { get; set; } -} +} \ No newline at end of file diff --git a/src/EllieBot/Db/Models/anti/AntiRaidSetting.cs b/src/EllieBot/Db/Models/anti/AntiRaidSetting.cs index 351d194..b5e5f67 100644 --- a/src/EllieBot/Db/Models/anti/AntiRaidSetting.cs +++ b/src/EllieBot/Db/Models/anti/AntiRaidSetting.cs @@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema; namespace EllieBot.Db.Models; + public class AntiRaidSetting : DbEntity { public int GuildConfigId { get; set; } diff --git a/src/EllieBot/Db/Models/support/PatronQuota.cs b/src/EllieBot/Db/Models/support/PatronQuota.cs index 688d005..d493807 100644 --- a/src/EllieBot/Db/Models/support/PatronQuota.cs +++ b/src/EllieBot/Db/Models/support/PatronQuota.cs @@ -6,12 +6,12 @@ public class PatronUser public string UniquePlatformUserId { get; set; } public ulong UserId { get; set; } public int AmountCents { get; set; } - + public DateTime LastCharge { get; set; } - + // Date Only component public DateTime ValidThru { get; set; } - + public PatronUser Clone() => new PatronUser() { From d31cf1bfaeff6b7c3d7a0465300822771b222d8e Mon Sep 17 00:00:00 2001 From: Toastie Date: Sat, 29 Jun 2024 17:50:59 +1200 Subject: [PATCH 3/4] Updated Administration module --- .../ServerLog/DummyLogCommandService.cs | 2 +- .../ServerLog/ServerLogCommandService.cs | 4 ++-- .../Administration/Ticket/TicketCommands.cs | 14 ++++++++++++++ .../Administration/UserPunish/UserPunishService.cs | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 src/EllieBot/Modules/Administration/Ticket/TicketCommands.cs diff --git a/src/EllieBot/Modules/Administration/ServerLog/DummyLogCommandService.cs b/src/EllieBot/Modules/Administration/ServerLog/DummyLogCommandService.cs index 00576b7..aade00c 100644 --- a/src/EllieBot/Modules/Administration/ServerLog/DummyLogCommandService.cs +++ b/src/EllieBot/Modules/Administration/ServerLog/DummyLogCommandService.cs @@ -3,7 +3,7 @@ namespace EllieBot.Modules.Administration; public sealed class DummyLogCommandService : ILogCommandService -#if GLOBAL_ELLIE +#if GLOBAL_NADEKO , IEService #endif { diff --git a/src/EllieBot/Modules/Administration/ServerLog/ServerLogCommandService.cs b/src/EllieBot/Modules/Administration/ServerLog/ServerLogCommandService.cs index 6ea5345..232f90d 100644 --- a/src/EllieBot/Modules/Administration/ServerLog/ServerLogCommandService.cs +++ b/src/EllieBot/Modules/Administration/ServerLog/ServerLogCommandService.cs @@ -8,8 +8,8 @@ using EllieBot.Db.Models; namespace EllieBot.Modules.Administration; public sealed class LogCommandService : ILogCommandService, IReadyExecutor -#if !GLOBAL_ELLIE - , IEService // don't load this service on global ellie +#if !GLOBAL_NADEKO + , IEService // don't load this service on global nadeko #endif { public ConcurrentDictionary GuildLogSettings { get; } diff --git a/src/EllieBot/Modules/Administration/Ticket/TicketCommands.cs b/src/EllieBot/Modules/Administration/Ticket/TicketCommands.cs new file mode 100644 index 0000000..67f5ca6 --- /dev/null +++ b/src/EllieBot/Modules/Administration/Ticket/TicketCommands.cs @@ -0,0 +1,14 @@ +// namespace EllieBot.Modules.Administration; +// +// public partial class Administration +// { +// [Group] +// public partial class TicketCommands : EllieModule +// { +// [Cmd] +// public async Task Ticket() +// { +// +// } +// } +// } \ No newline at end of file diff --git a/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs b/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs index cdc9900..5847bea 100644 --- a/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs +++ b/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs @@ -228,7 +228,7 @@ public class UserPunishService : IEService, IReadyExecutor case PunishmentAction.RemoveRoles: return botUser.GuildPermissions.ManageRoles; case PunishmentAction.ChatMute: - return botUser.GuildPermissions.ManageRoles; // adds ellie-mute role + return botUser.GuildPermissions.ManageRoles; // adds nadeko-mute role case PunishmentAction.VoiceMute: return botUser.GuildPermissions.MuteMembers; case PunishmentAction.AddRole: From 62319ebb1a21be5d746cb48cbfbc162a946e8d4f Mon Sep 17 00:00:00 2001 From: Toastie Date: Sat, 29 Jun 2024 17:54:54 +1200 Subject: [PATCH 4/4] Updated changelog and upped version to 5.1.2 --- CHANGELOG.md | 10 ++++++++-- src/EllieBot/EllieBot.csproj | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ef2508..d7faabc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,18 +2,24 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o +## [5.1.2] - 29.06.2024 + +### Fixed + +- Compile issues by disabling honeypot submodule for the time being + ## [5.1.1] - 29.06.2024 ### Added -- Added `.honeypot` command, which automatically softbans (ban and immediate unban) any user who posts in that channel. +- Added `'honeypot` command, which automatically softbans (ban and immediate unban) any user who posts in that channel. - Useful to auto softban bots who spam every channel upon joining - Users who run commands or expressions won't be softbanned. - Users who have ban member permissions are also excluded. ### Fixed -- Fixed `.betdraw` not respecting maxbet +- Fixed `'betdraw` not respecting maxbet - Fixed `'xpshop` pagination for real this time? ## [5.1.0] - 28.06.2024 diff --git a/src/EllieBot/EllieBot.csproj b/src/EllieBot/EllieBot.csproj index cef48b0..174d25d 100644 --- a/src/EllieBot/EllieBot.csproj +++ b/src/EllieBot/EllieBot.csproj @@ -4,7 +4,7 @@ enable true en - 5.1.1 + 5.1.2 $(MSBuildProjectDirectory)