From a1bf03ad40cb56684d87ab53bc1961b701fad0eb Mon Sep 17 00:00:00 2001 From: Toastie <toastie@toastiet0ast.com> Date: Sun, 23 Mar 2025 14:25:41 +1300 Subject: [PATCH] added captcha option for .fish in fish.yml --- .../Modules/Games/Fish/FishCommands.cs | 129 +++++++++--------- src/EllieBot/Modules/Games/Fish/FishConfig.cs | 3 +- .../Modules/Games/Fish/FishConfigService.cs | 10 ++ src/EllieBot/data/commandlist.json | 14 -- src/EllieBot/data/fish.yml | 29 ++-- src/EllieBot/data/xp.yml | 10 +- 6 files changed, 95 insertions(+), 100 deletions(-) diff --git a/src/EllieBot/Modules/Games/Fish/FishCommands.cs b/src/EllieBot/Modules/Games/Fish/FishCommands.cs index f4bec17..bc20449 100644 --- a/src/EllieBot/Modules/Games/Fish/FishCommands.cs +++ b/src/EllieBot/Modules/Games/Fish/FishCommands.cs @@ -24,7 +24,10 @@ public partial class Games var cRes = await cache.GetAsync(FishingWhitelistKey(ctx.User.Id)); if (cRes.TryPickT1(out _, out _)) { - var password = await captchaService.GetUserCaptcha(ctx.User.Id); + string? password = null; + if (fcs.Data.RequireCaptcha) + password = await captchaService.GetUserCaptcha(ctx.User.Id); + if (password is not null) { var img = captchaService.GetPasswordImage(password); @@ -72,16 +75,16 @@ public partial class Games var spot = fs.GetSpot(ctx.Channel.Id); var msg = await Response() - .Embed(CreateEmbed() - .WithPendingColor() - .WithAuthor(ctx.User) - .WithDescription(GetText(strs.fish_waiting)) - .AddField(GetText(strs.fish_spot), GetSpotEmoji(spot) + " " + spot.ToString(), true) - .AddField(GetText(strs.fish_weather), - GetWeatherEmoji(currentWeather) + " " + currentWeather, - true) - .AddField(GetText(strs.fish_tod), GetTodEmoji(currentTod) + " " + currentTod, true)) - .SendAsync(); + .Embed(CreateEmbed() + .WithPendingColor() + .WithAuthor(ctx.User) + .WithDescription(GetText(strs.fish_waiting)) + .AddField(GetText(strs.fish_spot), GetSpotEmoji(spot) + " " + spot.ToString(), true) + .AddField(GetText(strs.fish_weather), + GetWeatherEmoji(currentWeather) + " " + currentWeather, + true) + .AddField(GetText(strs.fish_tod), GetTodEmoji(currentTod) + " " + currentTod, true)) + .SendAsync(); var res = await fishTask; if (res is null) @@ -98,14 +101,14 @@ public partial class Games } await Response() - .Embed(CreateEmbed() - .WithOkColor() - .WithAuthor(ctx.User) - .WithDescription(desc) - .AddField(GetText(strs.fish_quality), GetStarText(res.Stars, res.Fish.Stars), true) - .AddField(GetText(strs.desc), res.Fish.Fluff, true) - .WithThumbnailUrl(res.Fish.Image)) - .SendAsync(); + .Embed(CreateEmbed() + .WithOkColor() + .WithAuthor(ctx.User) + .WithDescription(desc) + .AddField(GetText(strs.fish_quality), GetStarText(res.Stars, res.Fish.Stars), true) + .AddField(GetText(strs.desc), res.Fish.Fluff, true) + .WithThumbnailUrl(res.Fish.Image)) + .SendAsync(); await msg.DeleteAsync(); } @@ -118,15 +121,15 @@ public partial class Games var time = fs.GetTime(); await Response() - .Embed(CreateEmbed() - .WithOkColor() - .WithDescription(GetText(strs.fish_weather_duration(fs.GetWeatherPeriodDuration()))) - .AddField(GetText(strs.fish_spot), GetSpotEmoji(spot) + " " + spot, true) - .AddField(GetText(strs.fish_tod), GetTodEmoji(time) + " " + time, true) - .AddField(GetText(strs.fish_weather_forecast), - ws.Select(x => GetWeatherEmoji(x)).Join(""), - true)) - .SendAsync(); + .Embed(CreateEmbed() + .WithOkColor() + .WithDescription(GetText(strs.fish_weather_duration(fs.GetWeatherPeriodDuration()))) + .AddField(GetText(strs.fish_spot), GetSpotEmoji(spot) + " " + spot, true) + .AddField(GetText(strs.fish_tod), GetTodEmoji(time) + " " + time, true) + .AddField(GetText(strs.fish_weather_forecast), + ws.Select(x => GetWeatherEmoji(x)).Join(""), + true)) + .SendAsync(); } [Cmd] @@ -143,43 +146,43 @@ public partial class Games var catchDict = catches.ToDictionary(x => x.FishId, x => x); await Response() - .Paginated() - .Items(fishes) - .PageSize(9) - .CurrentPage(page) - .Page((fs, i) => - { - var eb = CreateEmbed() - .WithDescription($"🧠**Skill:** {skill} / {maxSkill}") - .WithAuthor(ctx.User) - .WithTitle(GetText(strs.fish_list_title)) - .WithOkColor(); + .Paginated() + .Items(fishes) + .PageSize(9) + .CurrentPage(page) + .Page((fs, i) => + { + var eb = CreateEmbed() + .WithDescription($"🧠**Skill:** {skill} / {maxSkill}") + .WithAuthor(ctx.User) + .WithTitle(GetText(strs.fish_list_title)) + .WithOkColor(); - foreach (var f in fs) - { - if (catchDict.TryGetValue(f.Id, out var c)) - { - eb.AddField(f.Name, - GetFishEmoji(f, c.Count) - + " " - + GetSpotEmoji(f.Spot) - + GetTodEmoji(f.Time) - + GetWeatherEmoji(f.Weather) - + "\n" - + GetStarText(c.MaxStars, f.Stars) - + "\n" - + Format.Italics(f.Fluff), - true); - } - else - { - eb.AddField("?", GetFishEmoji(null, 0) + "\n" + GetStarText(0, f.Stars), true); - } - } + foreach (var f in fs) + { + if (catchDict.TryGetValue(f.Id, out var c)) + { + eb.AddField(f.Name, + GetFishEmoji(f, c.Count) + + " " + + GetSpotEmoji(f.Spot) + + GetTodEmoji(f.Time) + + GetWeatherEmoji(f.Weather) + + "\n" + + GetStarText(c.MaxStars, f.Stars) + + "\n" + + Format.Italics(f.Fluff), + true); + } + else + { + eb.AddField("?", GetFishEmoji(null, 0) + "\n" + GetStarText(0, f.Stars), true); + } + } - return eb; - }) - .SendAsync(); + return eb; + }) + .SendAsync(); } private string GetFishEmoji(FishData? fish, int count) diff --git a/src/EllieBot/Modules/Games/Fish/FishConfig.cs b/src/EllieBot/Modules/Games/Fish/FishConfig.cs index d2ec929..3b97d76 100644 --- a/src/EllieBot/Modules/Games/Fish/FishConfig.cs +++ b/src/EllieBot/Modules/Games/Fish/FishConfig.cs @@ -7,9 +7,10 @@ namespace EllieBot.Modules.Games; public sealed partial class FishConfig : ICloneable<FishConfig> { [Comment("DO NOT CHANGE")] - public int Version { get; set; } = 1; + public int Version { get; set; } = 2; public string WeatherSeed { get; set; } = string.Empty; + public bool RequireCaptcha { get; set; } = true; public List<string> StarEmojis { get; set; } = new(); public List<string> SpotEmojis { get; set; } = new(); public FishChance Chance { get; set; } = new FishChance(); diff --git a/src/EllieBot/Modules/Games/Fish/FishConfigService.cs b/src/EllieBot/Modules/Games/Fish/FishConfigService.cs index 43fac25..92fa150 100644 --- a/src/EllieBot/Modules/Games/Fish/FishConfigService.cs +++ b/src/EllieBot/Modules/Games/Fish/FishConfigService.cs @@ -15,5 +15,15 @@ public sealed class FishConfigService : ConfigServiceBase<FishConfig> IPubSub pubSub) : base(FILE_PATH, serializer, pubSub, _changeKey) { + Migrate(); + } + + private void Migrate() + { + ModifyConfig(c => + { + c.Version = 2; + c.RequireCaptcha = true; + }); } } \ No newline at end of file diff --git a/src/EllieBot/data/commandlist.json b/src/EllieBot/data/commandlist.json index 6eb75ae..c1d01ca 100644 --- a/src/EllieBot/data/commandlist.json +++ b/src/EllieBot/data/commandlist.json @@ -8258,20 +8258,6 @@ ], "Requirements": [] }, - { - "Aliases": [ - ".xpgleaderboard", - ".xpglb" - ], - "Description": "Shows the global xp leaderboard.", - "Usage": [ - ".xpgleaderboard" - ], - "Submodule": "Xp", - "Module": "Xp", - "Options": null, - "Requirements": [] - }, { "Aliases": [ ".xplevelset" diff --git a/src/EllieBot/data/fish.yml b/src/EllieBot/data/fish.yml index b57bcb5..9bc1c7f 100644 --- a/src/EllieBot/data/fish.yml +++ b/src/EllieBot/data/fish.yml @@ -1,10 +1,7 @@ -# DO NOT CHANGE -version: 1 -weatherSeed: "w%29';^eGE)9oWHM(aI9I;%1[.r^z2ZS7ShV,l')o(e%#\"hVzb>oxQq^`.&/7srh" -chance: - fish: 80 - trash: 15 - nothing: 5 +# DO NOT CHANGE +version: 2 +weatherSeed: w%29';^eGE)9oWHM(aI9I;%1[.r^z2ZS7ShV,l')o(e%#"hVzb>oxQq^`.&/7srh +requireCaptcha: true starEmojis: - <:emptystar:1326838565786877962> - <:onestar:1326838456739168361> @@ -17,9 +14,13 @@ spotEmojis: - <:lake:1328315260561788989> - <:swamp:1328519766083633224> - <:reef:1328519744646545421> +chance: + fish: 80 + trash: 15 + nothing: 5 fish: - - name: Bass - id: 0 + - id: 0 + name: Bass weather: spot: time: @@ -28,16 +29,16 @@ fish: fluff: Very common. condition: image: https://cdn.nadeko.bot/fish/bass.png - emoji: "<:bass:1328520376892002386>" + emoji: <:bass:1328520376892002386> trash: - - name: Plastic Bag - id: 1002 + - id: 1002 + name: Plastic Bag weather: spot: time: chance: 50 stars: 4 - fluff: "Trophy of your contribution to the environment." + fluff: Trophy of your contribution to the environment. condition: image: https://cdn.nadeko.bot/fish/plasticbag.png - emoji: "<:plasticbag:1328520895454515211>" \ No newline at end of file + emoji: <:plasticbag:1328520895454515211> \ No newline at end of file diff --git a/src/EllieBot/data/xp.yml b/src/EllieBot/data/xp.yml index 8188f2c..9277307 100644 --- a/src/EllieBot/data/xp.yml +++ b/src/EllieBot/data/xp.yml @@ -1,5 +1,5 @@ # DO NOT CHANGE -version: 10 +version: 11 # How much XP will the users receive per message textXpPerMessage: 3 # How often can the users receive XP, in seconds @@ -7,19 +7,13 @@ textXpCooldown: 300 # Amount of xp users gain from posting an image textXpFromImage: 3 # Average amount of xp earned per minute in VC -voiceXpPerMinute: 0 +voiceXpPerMinute: 3 # Xp Shop config shop: # Whether the xp shop is enabled # True -> Users can access the xp shop using .xpshop command # False -> Users can't access the xp shop isEnabled: false - # Which patron tier do users need in order to use the .xpshop bgs command - # Leave at 'None' if patron system is disabled or you don't want any restrictions - bgsTierRequirement: None - # Which patron tier do users need in order to use the .xpshop frames command - # Leave at 'None' if patron system is disabled or you don't want any restrictions - framesTierRequirement: None # Frames available for sale. Keys are unique IDs. # Do not change keys as they are not publicly visible. Only change properties (name, price, id) # Removing a key which previously existed means that all previous purchases will also be unusable.