diff options
| author | Sadie Powell <sadie@witchery.services> | 2025-04-23 01:54:57 +0100 |
|---|---|---|
| committer | Sadie Powell <sadie@witchery.services> | 2025-04-23 01:57:02 +0100 |
| commit | bbb65ddc33c6d1bf1f52a41619e135b9ea59c8b2 (patch) | |
| tree | 51603b95236c017ecbfa4cb71080e409a10bf3dc /modules/operserv | |
| parent | 508bbe11e681454efa562d30c605f18e141f1d3b (diff) | |
When deleting a single list item show the deleted item not a count.
Closes #487.
Diffstat (limited to 'modules/operserv')
| -rw-r--r-- | modules/operserv/os_akill.cpp | 20 | ||||
| -rw-r--r-- | modules/operserv/os_session.cpp | 22 | ||||
| -rw-r--r-- | modules/operserv/os_sxline.cpp | 20 |
3 files changed, 49 insertions, 13 deletions
diff --git a/modules/operserv/os_akill.cpp b/modules/operserv/os_akill.cpp index b31f5404d..b6081abba 100644 --- a/modules/operserv/os_akill.cpp +++ b/modules/operserv/os_akill.cpp @@ -18,6 +18,7 @@ class AkillDelCallback final { CommandSource &source; unsigned deleted = 0; + Anope::string lastdeleted; Command *cmd; public: AkillDelCallback(CommandSource &_source, const Anope::string &numlist, Command *c) : NumberList(numlist, true), source(_source), cmd(c) @@ -26,10 +27,20 @@ public: ~AkillDelCallback() override { - if (deleted) - source.Reply(deleted, N_("Deleted %d entry from the AKILL list.", "Deleted %d entries from the AKILL list."), deleted); - else - source.Reply(_("No matching entries on the AKILL list.")); + switch (deleted) + { + case 0: + source.Reply(_("No matching entries on the AKILL list.")); + break; + + case 1: + source.Reply(_("Deleted %s from the AKILL list."), lastdeleted.c_str()); + break; + + default: + source.Reply(deleted, N_("Deleted %d entry from the AKILL list.", "Deleted %d entries from the AKILL list."), deleted); + break; + } } void HandleNumber(unsigned number) override @@ -42,6 +53,7 @@ public: if (!x) return; + lastdeleted = x->mask; Log(LOG_ADMIN, source, cmd) << "to remove " << x->mask << " from the list"; ++deleted; diff --git a/modules/operserv/os_session.cpp b/modules/operserv/os_session.cpp index de554140b..adbe23676 100644 --- a/modules/operserv/os_session.cpp +++ b/modules/operserv/os_session.cpp @@ -174,6 +174,7 @@ class ExceptionDelCallback final protected: CommandSource &source; unsigned deleted = 0; + Anope::string lastdeleted; Command *cmd; public: ExceptionDelCallback(CommandSource &_source, const Anope::string &numlist, Command *c) : NumberList(numlist, true), source(_source), cmd(c) @@ -182,10 +183,20 @@ public: ~ExceptionDelCallback() override { - if (deleted) - source.Reply(deleted, N_("Deleted %d entry from session-limit exception list.", "Deleted %d entries from session-limit exception list."), deleted); - else - source.Reply(_("No matching entries on session-limit exception list.")); + switch (deleted) + { + case 0: + source.Reply(_("No matching entries on session-limit exception list.")); + break; + + case 1: + source.Reply(_("Deleted %s from session-limit exception list."), lastdeleted.c_str()); + break; + + default: + source.Reply(deleted, N_("Deleted %d entry from session-limit exception list.", "Deleted %d entries from session-limit exception list."), deleted); + break; + } } void HandleNumber(unsigned number) override @@ -193,7 +204,8 @@ public: if (!number || number > session_service->GetExceptions().size()) return; - Log(LOG_ADMIN, source, cmd) << "to remove the session limit exception for " << session_service->GetExceptions()[number - 1]->mask; + lastdeleted = session_service->GetExceptions()[number - 1]->mask; + Log(LOG_ADMIN, source, cmd) << "to remove the session limit exception for " << lastdeleted; ++deleted; DoDel(source, number - 1); diff --git a/modules/operserv/os_sxline.cpp b/modules/operserv/os_sxline.cpp index f19cc529c..c81bd51d4 100644 --- a/modules/operserv/os_sxline.cpp +++ b/modules/operserv/os_sxline.cpp @@ -18,6 +18,7 @@ class SXLineDelCallback final Command *command; CommandSource &source; unsigned deleted = 0; + Anope::string lastdeleted; public: SXLineDelCallback(XLineManager *x, Command *c, CommandSource &_source, const Anope::string &numlist) : NumberList(numlist, true), xlm(x), command(c), source(_source) { @@ -25,10 +26,20 @@ public: ~SXLineDelCallback() override { - if (deleted) - source.Reply(deleted, N_("Deleted %d entry from the %s list.", "Deleted %d entries from the %s list."), deleted, source.command.nobreak().c_str()); - else - source.Reply(_("No matching entries on the %s list."), source.command.nobreak().c_str()); + switch (deleted) + { + case 0: + source.Reply(deleted, N_("Deleted %d entry from the %s list.", "Deleted %d entries from the %s list."), deleted, source.command.nobreak().c_str()); + break; + + case 1: + source.Reply(_("Deleted %s from the %s list."), lastdeleted.c_str(), source.command.nobreak().c_str()); + break; + + default: + source.Reply(_("No matching entries on the %s list."), source.command.nobreak().c_str()); + break; + } } void HandleNumber(unsigned number) override @@ -41,6 +52,7 @@ public: if (!x) return; + lastdeleted = x->mask; Log(LOG_ADMIN, source, command) << "to remove " << x->mask << " from the list"; ++deleted; |
