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/botserv | |
| parent | 508bbe11e681454efa562d30c605f18e141f1d3b (diff) | |
When deleting a single list item show the deleted item not a count.
Closes #487.
Diffstat (limited to 'modules/botserv')
| -rw-r--r-- | modules/botserv/bs_badwords.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/modules/botserv/bs_badwords.cpp b/modules/botserv/bs_badwords.cpp index 48d101c56..a8980066a 100644 --- a/modules/botserv/bs_badwords.cpp +++ b/modules/botserv/bs_badwords.cpp @@ -165,6 +165,7 @@ class BadwordsDelCallback final BadWords *bw; Command *c; unsigned deleted = 0; + Anope::string lastdeleted; bool override = false; public: BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c) @@ -176,10 +177,20 @@ public: ~BadwordsDelCallback() override { - if (deleted) - source.Reply(deleted, N_("Deleted %d entry from %s bad words list.", "Deleted %d entries from %s bad words list."), deleted, ci->name.c_str()); - else - source.Reply(_("No matching entries on %s bad words list."), ci->name.c_str()); + switch (deleted) + { + case 0: + source.Reply(_("No matching entries on %s bad words list."), ci->name.c_str()); + break; + + case 1: + source.Reply(_("Deleted %s from %s bad words list."), lastdeleted.c_str(), ci->name.c_str()); + break; + + default: + source.Reply(deleted, N_("Deleted %d entry from %s bad words list.", "Deleted %d entries from %s bad words list."), deleted, ci->name.c_str()); + break; + } } void HandleNumber(unsigned Number) override @@ -187,7 +198,8 @@ public: if (!bw || !Number || Number > bw->GetBadWordCount()) return; - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "DEL " << bw->GetBadWord(Number - 1)->word; + lastdeleted = bw->GetBadWord(Number - 1)->word; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "DEL " << lastdeleted; ++deleted; bw->EraseBadWord(Number - 1); } |
