added captcha option for .fish in fish.yml

This commit is contained in:
Toastie 2025-03-23 14:25:41 +13:00
parent 2d3c7de8e7
commit a1bf03ad40
Signed by: toastie_t0ast
GPG key ID: 0861BE54AD481DC7
6 changed files with 95 additions and 100 deletions

View file

@ -24,7 +24,10 @@ public partial class Games
var cRes = await cache.GetAsync(FishingWhitelistKey(ctx.User.Id)); var cRes = await cache.GetAsync(FishingWhitelistKey(ctx.User.Id));
if (cRes.TryPickT1(out _, out _)) 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) if (password is not null)
{ {
var img = captchaService.GetPasswordImage(password); var img = captchaService.GetPasswordImage(password);
@ -72,16 +75,16 @@ public partial class Games
var spot = fs.GetSpot(ctx.Channel.Id); var spot = fs.GetSpot(ctx.Channel.Id);
var msg = await Response() var msg = await Response()
.Embed(CreateEmbed() .Embed(CreateEmbed()
.WithPendingColor() .WithPendingColor()
.WithAuthor(ctx.User) .WithAuthor(ctx.User)
.WithDescription(GetText(strs.fish_waiting)) .WithDescription(GetText(strs.fish_waiting))
.AddField(GetText(strs.fish_spot), GetSpotEmoji(spot) + " " + spot.ToString(), true) .AddField(GetText(strs.fish_spot), GetSpotEmoji(spot) + " " + spot.ToString(), true)
.AddField(GetText(strs.fish_weather), .AddField(GetText(strs.fish_weather),
GetWeatherEmoji(currentWeather) + " " + currentWeather, GetWeatherEmoji(currentWeather) + " " + currentWeather,
true) true)
.AddField(GetText(strs.fish_tod), GetTodEmoji(currentTod) + " " + currentTod, true)) .AddField(GetText(strs.fish_tod), GetTodEmoji(currentTod) + " " + currentTod, true))
.SendAsync(); .SendAsync();
var res = await fishTask; var res = await fishTask;
if (res is null) if (res is null)
@ -98,14 +101,14 @@ public partial class Games
} }
await Response() await Response()
.Embed(CreateEmbed() .Embed(CreateEmbed()
.WithOkColor() .WithOkColor()
.WithAuthor(ctx.User) .WithAuthor(ctx.User)
.WithDescription(desc) .WithDescription(desc)
.AddField(GetText(strs.fish_quality), GetStarText(res.Stars, res.Fish.Stars), true) .AddField(GetText(strs.fish_quality), GetStarText(res.Stars, res.Fish.Stars), true)
.AddField(GetText(strs.desc), res.Fish.Fluff, true) .AddField(GetText(strs.desc), res.Fish.Fluff, true)
.WithThumbnailUrl(res.Fish.Image)) .WithThumbnailUrl(res.Fish.Image))
.SendAsync(); .SendAsync();
await msg.DeleteAsync(); await msg.DeleteAsync();
} }
@ -118,15 +121,15 @@ public partial class Games
var time = fs.GetTime(); var time = fs.GetTime();
await Response() await Response()
.Embed(CreateEmbed() .Embed(CreateEmbed()
.WithOkColor() .WithOkColor()
.WithDescription(GetText(strs.fish_weather_duration(fs.GetWeatherPeriodDuration()))) .WithDescription(GetText(strs.fish_weather_duration(fs.GetWeatherPeriodDuration())))
.AddField(GetText(strs.fish_spot), GetSpotEmoji(spot) + " " + spot, true) .AddField(GetText(strs.fish_spot), GetSpotEmoji(spot) + " " + spot, true)
.AddField(GetText(strs.fish_tod), GetTodEmoji(time) + " " + time, true) .AddField(GetText(strs.fish_tod), GetTodEmoji(time) + " " + time, true)
.AddField(GetText(strs.fish_weather_forecast), .AddField(GetText(strs.fish_weather_forecast),
ws.Select(x => GetWeatherEmoji(x)).Join(""), ws.Select(x => GetWeatherEmoji(x)).Join(""),
true)) true))
.SendAsync(); .SendAsync();
} }
[Cmd] [Cmd]
@ -143,43 +146,43 @@ public partial class Games
var catchDict = catches.ToDictionary(x => x.FishId, x => x); var catchDict = catches.ToDictionary(x => x.FishId, x => x);
await Response() await Response()
.Paginated() .Paginated()
.Items(fishes) .Items(fishes)
.PageSize(9) .PageSize(9)
.CurrentPage(page) .CurrentPage(page)
.Page((fs, i) => .Page((fs, i) =>
{ {
var eb = CreateEmbed() var eb = CreateEmbed()
.WithDescription($"🧠 **Skill:** {skill} / {maxSkill}") .WithDescription($"🧠 **Skill:** {skill} / {maxSkill}")
.WithAuthor(ctx.User) .WithAuthor(ctx.User)
.WithTitle(GetText(strs.fish_list_title)) .WithTitle(GetText(strs.fish_list_title))
.WithOkColor(); .WithOkColor();
foreach (var f in fs) foreach (var f in fs)
{ {
if (catchDict.TryGetValue(f.Id, out var c)) if (catchDict.TryGetValue(f.Id, out var c))
{ {
eb.AddField(f.Name, eb.AddField(f.Name,
GetFishEmoji(f, c.Count) GetFishEmoji(f, c.Count)
+ " " + " "
+ GetSpotEmoji(f.Spot) + GetSpotEmoji(f.Spot)
+ GetTodEmoji(f.Time) + GetTodEmoji(f.Time)
+ GetWeatherEmoji(f.Weather) + GetWeatherEmoji(f.Weather)
+ "\n" + "\n"
+ GetStarText(c.MaxStars, f.Stars) + GetStarText(c.MaxStars, f.Stars)
+ "\n" + "\n"
+ Format.Italics(f.Fluff), + Format.Italics(f.Fluff),
true); true);
} }
else else
{ {
eb.AddField("?", GetFishEmoji(null, 0) + "\n" + GetStarText(0, f.Stars), true); eb.AddField("?", GetFishEmoji(null, 0) + "\n" + GetStarText(0, f.Stars), true);
} }
} }
return eb; return eb;
}) })
.SendAsync(); .SendAsync();
} }
private string GetFishEmoji(FishData? fish, int count) private string GetFishEmoji(FishData? fish, int count)

View file

@ -7,9 +7,10 @@ namespace EllieBot.Modules.Games;
public sealed partial class FishConfig : ICloneable<FishConfig> public sealed partial class FishConfig : ICloneable<FishConfig>
{ {
[Comment("DO NOT CHANGE")] [Comment("DO NOT CHANGE")]
public int Version { get; set; } = 1; public int Version { get; set; } = 2;
public string WeatherSeed { get; set; } = string.Empty; public string WeatherSeed { get; set; } = string.Empty;
public bool RequireCaptcha { get; set; } = true;
public List<string> StarEmojis { get; set; } = new(); public List<string> StarEmojis { get; set; } = new();
public List<string> SpotEmojis { get; set; } = new(); public List<string> SpotEmojis { get; set; } = new();
public FishChance Chance { get; set; } = new FishChance(); public FishChance Chance { get; set; } = new FishChance();

View file

@ -15,5 +15,15 @@ public sealed class FishConfigService : ConfigServiceBase<FishConfig>
IPubSub pubSub) IPubSub pubSub)
: base(FILE_PATH, serializer, pubSub, _changeKey) : base(FILE_PATH, serializer, pubSub, _changeKey)
{ {
Migrate();
}
private void Migrate()
{
ModifyConfig(c =>
{
c.Version = 2;
c.RequireCaptcha = true;
});
} }
} }

View file

@ -8258,20 +8258,6 @@
], ],
"Requirements": [] "Requirements": []
}, },
{
"Aliases": [
".xpgleaderboard",
".xpglb"
],
"Description": "Shows the global xp leaderboard.",
"Usage": [
".xpgleaderboard"
],
"Submodule": "Xp",
"Module": "Xp",
"Options": null,
"Requirements": []
},
{ {
"Aliases": [ "Aliases": [
".xplevelset" ".xplevelset"

View file

@ -1,10 +1,7 @@
# DO NOT CHANGE # DO NOT CHANGE
version: 1 version: 2
weatherSeed: "w%29';^eGE)9oWHM(aI9I;%1[.r^z2ZS7ShV,l')o(e%#\"hVzb>oxQq^`.&/7srh" weatherSeed: w%29';^eGE)9oWHM(aI9I;%1[.r^z2ZS7ShV,l')o(e%#"hVzb>oxQq^`.&/7srh
chance: requireCaptcha: true
fish: 80
trash: 15
nothing: 5
starEmojis: starEmojis:
- <:emptystar:1326838565786877962> - <:emptystar:1326838565786877962>
- <:onestar:1326838456739168361> - <:onestar:1326838456739168361>
@ -17,9 +14,13 @@ spotEmojis:
- <:lake:1328315260561788989> - <:lake:1328315260561788989>
- <:swamp:1328519766083633224> - <:swamp:1328519766083633224>
- <:reef:1328519744646545421> - <:reef:1328519744646545421>
chance:
fish: 80
trash: 15
nothing: 5
fish: fish:
- name: Bass - id: 0
id: 0 name: Bass
weather: weather:
spot: spot:
time: time:
@ -28,16 +29,16 @@ fish:
fluff: Very common. fluff: Very common.
condition: condition:
image: https://cdn.nadeko.bot/fish/bass.png image: https://cdn.nadeko.bot/fish/bass.png
emoji: "<:bass:1328520376892002386>" emoji: <:bass:1328520376892002386>
trash: trash:
- name: Plastic Bag - id: 1002
id: 1002 name: Plastic Bag
weather: weather:
spot: spot:
time: time:
chance: 50 chance: 50
stars: 4 stars: 4
fluff: "Trophy of your contribution to the environment." fluff: Trophy of your contribution to the environment.
condition: condition:
image: https://cdn.nadeko.bot/fish/plasticbag.png image: https://cdn.nadeko.bot/fish/plasticbag.png
emoji: "<:plasticbag:1328520895454515211>" emoji: <:plasticbag:1328520895454515211>

View file

@ -1,5 +1,5 @@
# DO NOT CHANGE # DO NOT CHANGE
version: 10 version: 11
# How much XP will the users receive per message # How much XP will the users receive per message
textXpPerMessage: 3 textXpPerMessage: 3
# How often can the users receive XP, in seconds # How often can the users receive XP, in seconds
@ -7,19 +7,13 @@ textXpCooldown: 300
# Amount of xp users gain from posting an image # Amount of xp users gain from posting an image
textXpFromImage: 3 textXpFromImage: 3
# Average amount of xp earned per minute in VC # Average amount of xp earned per minute in VC
voiceXpPerMinute: 0 voiceXpPerMinute: 3
# Xp Shop config # Xp Shop config
shop: shop:
# Whether the xp shop is enabled # Whether the xp shop is enabled
# True -> Users can access the xp shop using .xpshop command # True -> Users can access the xp shop using .xpshop command
# False -> Users can't access the xp shop # False -> Users can't access the xp shop
isEnabled: false 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. # Frames available for sale. Keys are unique IDs.
# Do not change keys as they are not publicly visible. Only change properties (name, price, id) # 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. # Removing a key which previously existed means that all previous purchases will also be unusable.