From 4fb4a2d0c31dc729004a6f35c70c5d170a2dd031 Mon Sep 17 00:00:00 2001 From: Toastie Date: Fri, 31 Jan 2025 13:49:31 +1300 Subject: [PATCH] increased todo and archive limits slightly --- .../Modules/Utility/Todo/TodoCommands.cs | 27 ++++++++++++++++--- .../Modules/Utility/Todo/TodoService.cs | 8 +++--- src/EllieBot/data/aliases.yml | 5 ++++ .../data/strings/commands/commands.en-US.yml | 7 +++++ 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/EllieBot/Modules/Utility/Todo/TodoCommands.cs b/src/EllieBot/Modules/Utility/Todo/TodoCommands.cs index ed941d6..e39a280 100644 --- a/src/EllieBot/Modules/Utility/Todo/TodoCommands.cs +++ b/src/EllieBot/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/EllieBot/Modules/Utility/Todo/TodoService.cs b/src/EllieBot/Modules/Utility/Todo/TodoService.cs index ab7f3bf..f349e38 100644 --- a/src/EllieBot/Modules/Utility/Todo/TodoService.cs +++ b/src/EllieBot/Modules/Utility/Todo/TodoService.cs @@ -6,8 +6,8 @@ namespace EllieBot.Modules.Utility; public sealed class TodoService : IEService { - 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 : IEService .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 : IEService 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(); diff --git a/src/EllieBot/data/aliases.yml b/src/EllieBot/data/aliases.yml index 2f31667..969bfe0 100644 --- a/src/EllieBot/data/aliases.yml +++ b/src/EllieBot/data/aliases.yml @@ -1441,6 +1441,11 @@ todoarchivedelete: - del - remove - rm +todoarchivedone: + - done + - compelete + - finish + - completed todoedit: - edit - change diff --git a/src/EllieBot/data/strings/commands/commands.en-US.yml b/src/EllieBot/data/strings/commands/commands.en-US.yml index f3b3253..720ea39 100644 --- a/src/EllieBot/data/strings/commands/commands.en-US.yml +++ b/src/EllieBot/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: