From 988d8c025073b3edd5aaafe6571cfb77afda47aa Mon Sep 17 00:00:00 2001
From: Toastie <toastie@toastiet0ast.com>
Date: Fri, 14 Mar 2025 21:03:23 +1300
Subject: [PATCH] .savechat no longer owneronly started implementation of
 bigwin announcement, but there are problems

---
 src/EllieBot/Db/EllieContext.cs               |  3 --
 src/EllieBot/Db/Models/DiscordUser.cs         |  3 --
 src/EllieBot/Db/Models/Notify.cs              |  1 +
 .../Notify/Models/BigWinNotifyModel.cs        | 46 +++++++++++++++++++
 .../Administration/Notify/NotifyService.cs    |  1 +
 src/EllieBot/Modules/Gambling/Gambling.cs     |  7 ---
 src/EllieBot/Modules/Utility/Utility.cs       |  6 ++-
 .../Services/Currency/GamblingTxTracker.cs    | 14 +++++-
 8 files changed, 66 insertions(+), 15 deletions(-)
 create mode 100644 src/EllieBot/Modules/Administration/Notify/Models/BigWinNotifyModel.cs

diff --git a/src/EllieBot/Db/EllieContext.cs b/src/EllieBot/Db/EllieContext.cs
index 1134692..4289e50 100644
--- a/src/EllieBot/Db/EllieContext.cs
+++ b/src/EllieBot/Db/EllieContext.cs
@@ -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);
 
diff --git a/src/EllieBot/Db/Models/DiscordUser.cs b/src/EllieBot/Db/Models/DiscordUser.cs
index b07da85..cc447f0 100644
--- a/src/EllieBot/Db/Models/DiscordUser.cs
+++ b/src/EllieBot/Db/Models/DiscordUser.cs
@@ -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; }
 
diff --git a/src/EllieBot/Db/Models/Notify.cs b/src/EllieBot/Db/Models/Notify.cs
index f8b29c0..87985b9 100644
--- a/src/EllieBot/Db/Models/Notify.cs
+++ b/src/EllieBot/Db/Models/Notify.cs
@@ -21,4 +21,5 @@ public enum NotifyType
     Protection = 1, Prot = 1,
     AddRoleReward = 2,
     RemoveRoleReward = 3,
+    // BigWin = 4,
 }
\ No newline at end of file
diff --git a/src/EllieBot/Modules/Administration/Notify/Models/BigWinNotifyModel.cs b/src/EllieBot/Modules/Administration/Notify/Models/BigWinNotifyModel.cs
new file mode 100644
index 0000000..16e82a4
--- /dev/null
+++ b/src/EllieBot/Modules/Administration/Notify/Models/BigWinNotifyModel.cs
@@ -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;
+//     }
+// }
\ No newline at end of file
diff --git a/src/EllieBot/Modules/Administration/Notify/NotifyService.cs b/src/EllieBot/Modules/Administration/Notify/NotifyService.cs
index d23d71d..9a1b8de 100644
--- a/src/EllieBot/Modules/Administration/Notify/NotifyService.cs
+++ b/src/EllieBot/Modules/Administration/Notify/NotifyService.cs
@@ -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;
diff --git a/src/EllieBot/Modules/Gambling/Gambling.cs b/src/EllieBot/Modules/Gambling/Gambling.cs
index 11f3d19..6e31283 100644
--- a/src/EllieBot/Modules/Gambling/Gambling.cs
+++ b/src/EllieBot/Modules/Gambling/Gambling.cs
@@ -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;
 
diff --git a/src/EllieBot/Modules/Utility/Utility.cs b/src/EllieBot/Modules/Utility/Utility.cs
index 315c8d8..777caae 100644
--- a/src/EllieBot/Modules/Utility/Utility.cs
+++ b/src/EllieBot/Modules/Utility/Utility.cs
@@ -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));
 
diff --git a/src/EllieBot/_common/Services/Currency/GamblingTxTracker.cs b/src/EllieBot/_common/Services/Currency/GamblingTxTracker.cs
index 5a40474..92a0fda 100644
--- a/src/EllieBot/_common/Services/Currency/GamblingTxTracker.cs
+++ b/src/EllieBot/_common/Services/Currency/GamblingTxTracker.cs
@@ -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")