.savechat no longer owneronly

started implementation of bigwin announcement, but there are problems
This commit is contained in:
Toastie 2025-03-14 21:03:23 +13:00
parent 082cf79736
commit 988d8c0250
Signed by: toastie_t0ast
GPG key ID: 0861BE54AD481DC7
8 changed files with 66 additions and 15 deletions
src/EllieBot
Db
Modules
Administration/Notify
Gambling
Utility
_common/Services/Currency

View file

@ -272,9 +272,6 @@ public abstract class EllieContext : DbContext
du.Property(x => x.IsClubAdmin) du.Property(x => x.IsClubAdmin)
.HasDefaultValue(false); .HasDefaultValue(false);
du.Property(x => x.NotifyOnLevelUp)
.HasDefaultValue(XpNotificationLocation.None);
du.Property(x => x.TotalXp) du.Property(x => x.TotalXp)
.HasDefaultValue(0); .HasDefaultValue(0);

View file

@ -1,7 +1,5 @@
namespace EllieBot.Db.Models; namespace EllieBot.Db.Models;
// FUTURE remove LastLevelUp from here and UserXpStats
public class DiscordUser : DbEntity public class DiscordUser : DbEntity
{ {
public const string DEFAULT_USERNAME = "??Unknown"; public const string DEFAULT_USERNAME = "??Unknown";
@ -15,7 +13,6 @@ public class DiscordUser : DbEntity
public bool IsClubAdmin { get; set; } public bool IsClubAdmin { get; set; }
public long TotalXp { get; set; } public long TotalXp { get; set; }
public XpNotificationLocation NotifyOnLevelUp { get; set; }
public long CurrencyAmount { get; set; } public long CurrencyAmount { get; set; }

View file

@ -21,4 +21,5 @@ public enum NotifyType
Protection = 1, Prot = 1, Protection = 1, Prot = 1,
AddRoleReward = 2, AddRoleReward = 2,
RemoveRoleReward = 3, RemoveRoleReward = 3,
// BigWin = 4,
} }

View file

@ -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;
// }
// }

View file

@ -4,6 +4,7 @@ using EllieBot.Common.ModuleBehaviors;
using EllieBot.Db.Models; using EllieBot.Db.Models;
using EllieBot.Generators; using EllieBot.Generators;
using EllieBot.Modules.Administration.Services; using EllieBot.Modules.Administration.Services;
using EllieBot.Modules.Gambling;
using EllieBot.Modules.Xp.Services; using EllieBot.Modules.Xp.Services;
namespace EllieBot.Modules.Administration; namespace EllieBot.Modules.Administration;

View file

@ -15,13 +15,6 @@ using EllieBot.Modules.Gambling.Rps;
using EllieBot.Common.TypeReaders; using EllieBot.Common.TypeReaders;
using EllieBot.Modules.Games; using EllieBot.Modules.Games;
using EllieBot.Modules.Patronage; 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; namespace EllieBot.Modules.Gambling;

View file

@ -642,9 +642,13 @@ public partial class Utility : EllieModule
[Cmd] [Cmd]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [UserPerm(GuildPerm.Administrator)]
[Ratelimit(3600)]
public async Task SaveChat(int cnt) public async Task SaveChat(int cnt)
{ {
if (cnt > 1000)
return;
var msgs = new List<IMessage>(cnt); var msgs = new List<IMessage>(cnt);
await ctx.Channel.GetMessagesAsync(cnt).ForEachAsync(dled => msgs.AddRange(dled)); await ctx.Channel.GetMessagesAsync(cnt).ForEachAsync(dled => msgs.AddRange(dled));

View file

@ -6,6 +6,8 @@ using EllieBot.Services.Currency;
using EllieBot.Db.Models; using EllieBot.Db.Models;
using EllieBot.Modules.Gambling; using EllieBot.Modules.Gambling;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using EllieBot.Modules.Administration;
using EllieBot.Modules.Gambling.Services;
namespace EllieBot.Services; namespace EllieBot.Services;
@ -20,10 +22,14 @@ public sealed class GamblingTxTracker : ITxTracker, IEService, IReadyExecutor
private ConcurrentBag<UserBetStats> userStats = new(); private ConcurrentBag<UserBetStats> userStats = new();
private readonly DbService _db; 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; _db = db;
_gcs = gcs;
_notify = notify;
} }
public async Task OnReadyAsync() public async Task OnReadyAsync()
@ -184,6 +190,12 @@ public sealed class GamblingTxTracker : ITxTracker, IEService, IReadyExecutor
if (mType is not { } type) if (mType is not { } type)
return Task.CompletedTask; return Task.CompletedTask;
// var bigWin = _gcs.Data.BigWin;
// if (bigWin > 0 && amount >= bigWin)
// {
// _notify.NotifyAsync<BigWinNotifyModel>(new())
// }
if (txData.Type == "lula") if (txData.Type == "lula")
{ {
if (txData.Extra == "lose") if (txData.Extra == "lose")