From 42fc0c263d5906ff85ed763f64149fa128acfe8d Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 30 Jan 2025 10:52:38 +0000 Subject: [PATCH] fix: global nadeko captcha patron add will show 12.5% of the time now, down from 20%, and be smaller change: increased todo and archive limits slightly --- src/NadekoBot/Modules/Gambling/Gambling.cs | 4 +-- .../Modules/Games/Fish/FishCommands.cs | 4 +-- .../Modules/Utility/Todo/TodoCommands.cs | 27 ++++++++++++++++--- .../Modules/Utility/Todo/TodoService.cs | 9 ++++--- src/NadekoBot/data/aliases.yml | 5 ++++ .../data/strings/commands/commands.en-US.yml | 7 +++++ 6 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index 6b1f9953e..865879851 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -168,9 +168,9 @@ public partial class Gambling : GamblingModule .File(stream, "timely.png"); #if GLOBAL_NADEKO - if (_rng.Next(0, 5) == 0) + if (_rng.Next(0, 8) == 0) toSend = toSend - .Confirm("[Sub on Patreon](https://patreon.com/nadekobot) to remove captcha."); + .Text("*[Sub on Patreon](https://patreon.com/nadekobot) to remove captcha.*"); #endif var captchaMessage = await toSend.SendAsync(); diff --git a/src/NadekoBot/Modules/Games/Fish/FishCommands.cs b/src/NadekoBot/Modules/Games/Fish/FishCommands.cs index 026d0353f..56e52b76c 100644 --- a/src/NadekoBot/Modules/Games/Fish/FishCommands.cs +++ b/src/NadekoBot/Modules/Games/Fish/FishCommands.cs @@ -33,9 +33,9 @@ public partial class Games .File(stream, "timely.png"); #if GLOBAL_NADEKO - if (_rng.Next(0, 5) == 0) + if (_rng.Next(0, 8) == 0) toSend = toSend - .Confirm("[Sub on Patreon](https://patreon.com/nadekobot) to remove captcha."); + .Text("*[Sub on Patreon](https://patreon.com/nadekobot) to remove captcha.*"); #endif var captcha = await toSend.SendAsync(); diff --git a/src/NadekoBot/Modules/Utility/Todo/TodoCommands.cs b/src/NadekoBot/Modules/Utility/Todo/TodoCommands.cs index f4380df10..9b7a56291 100644 --- a/src/NadekoBot/Modules/Utility/Todo/TodoCommands.cs +++ b/src/NadekoBot/Modules/Utility/Todo/TodoCommands.cs @@ -150,7 +150,26 @@ public partial class Utility [Cmd] public async Task TodoArchiveAdd([Leftover] string name) { - var result = await _service.ArchiveTodosAsync(ctx.User.Id, name); + var result = await _service.ArchiveTodosAsync(ctx.User.Id, name, false); + if (result == ArchiveTodoResult.NoTodos) + { + await Response().Error(strs.todo_no_todos).SendAsync(); + return; + } + + if (result == ArchiveTodoResult.MaxLimitReached) + { + await Response().Error(strs.todo_archive_max_limit).SendAsync(); + return; + } + + await ctx.OkAsync(); + } + + [Cmd] + public async Task TodoArchiveDone([Leftover] string name) + { + var result = await _service.ArchiveTodosAsync(ctx.User.Id, name, true); if (result == ArchiveTodoResult.NoTodos) { await Response().Error(strs.todo_no_todos).SendAsync(); @@ -193,7 +212,7 @@ public partial class Utility foreach (var archivedList in items) { - eb.AddField($"id: {archivedList.Id.ToString()}", archivedList.Name, true); + eb.AddField($"id: {new kwum(archivedList.Id)}", archivedList.Name, true); } return eb; @@ -202,7 +221,7 @@ public partial class Utility } [Cmd] - public async Task TodoArchiveShow(int id) + public async Task TodoArchiveShow(kwum id) { var list = await _service.GetArchivedTodoListAsync(ctx.User.Id, id); if (list == null || list.Items.Count == 0) @@ -234,7 +253,7 @@ public partial class Utility } [Cmd] - public async Task TodoArchiveDelete(int id) + public async Task TodoArchiveDelete(kwum id) { if (!await _service.ArchiveDeleteAsync(ctx.User.Id, id)) { diff --git a/src/NadekoBot/Modules/Utility/Todo/TodoService.cs b/src/NadekoBot/Modules/Utility/Todo/TodoService.cs index 6cbd5af33..981303b9b 100644 --- a/src/NadekoBot/Modules/Utility/Todo/TodoService.cs +++ b/src/NadekoBot/Modules/Utility/Todo/TodoService.cs @@ -6,8 +6,8 @@ namespace NadekoBot.Modules.Utility; public sealed class TodoService : INService { - private const int ARCHIVE_MAX_COUNT = 9; - private const int TODO_MAX_COUNT = 27; + private const int ARCHIVE_MAX_COUNT = 18; + private const int TODO_MAX_COUNT = 36; private readonly DbService _db; @@ -111,7 +111,7 @@ public sealed class TodoService : INService .DeleteAsync(); } - public async Task ArchiveTodosAsync(ulong userId, string name) + public async Task ArchiveTodosAsync(ulong userId, string name, bool onlyDone) { // create a new archive @@ -140,7 +140,7 @@ public sealed class TodoService : INService var updated = await ctx .GetTable() - .Where(x => x.UserId == userId && x.ArchiveId == null) + .Where(x => x.UserId == userId && (!onlyDone || x.IsDone) && x.ArchiveId == null) .Set(x => x.ArchiveId, inserted.Id) .UpdateAsync(); @@ -204,4 +204,5 @@ public sealed class TodoService : INService .Where(x => x.UserId == userId && x.Id == todoId) .FirstOrDefaultAsyncLinqToDB(); } + } \ No newline at end of file diff --git a/src/NadekoBot/data/aliases.yml b/src/NadekoBot/data/aliases.yml index 6dc27cd45..178bcb6ce 100644 --- a/src/NadekoBot/data/aliases.yml +++ b/src/NadekoBot/data/aliases.yml @@ -1441,6 +1441,11 @@ todoarchivedelete: - del - remove - rm +todoarchivedone: + - done + - compelete + - finish + - completed todoedit: - edit - change diff --git a/src/NadekoBot/data/strings/commands/commands.en-US.yml b/src/NadekoBot/data/strings/commands/commands.en-US.yml index 50884e680..9ab9a26d6 100644 --- a/src/NadekoBot/data/strings/commands/commands.en-US.yml +++ b/src/NadekoBot/data/strings/commands/commands.en-US.yml @@ -4524,6 +4524,13 @@ todoarchiveadd: params: - name: desc: "The name of the archive to be created." +todoarchivedone: + desc: Creates a new archive with the specified name using only completed current todos. + ex: + - Success! + params: + - name: + desc: "The name of the archive to be created." todoarchivelist: desc: Lists all archived todo lists. ex: