From 5702fb914589c7bd2be3bb326584dcaf73522a5a Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 10 Jun 2025 10:59:49 +0100 Subject: [PATCH] Add a PREPEND subcommand to chanserv/topic. --- language/anope.en_US.po | 7 +++++-- modules/chanserv/cs_topic.cpp | 13 ++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/language/anope.en_US.po b/language/anope.en_US.po index 07d9cfe2e..ca2a982c9 100644 --- a/language/anope.en_US.po +++ b/language/anope.en_US.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: Anope\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-05-29 16:46+0100\n" -"PO-Revision-Date: 2025-05-29 16:46+0100\n" +"POT-Creation-Date: 2025-06-10 12:05+0100\n" +"PO-Revision-Date: 2025-06-10 12:05+0100\n" "Last-Translator: Sadie Powell \n" "Language-Team: English\n" "Language: en_US\n" @@ -448,6 +448,9 @@ msgstr "" msgid "channel LOCK {ADD|DEL|SET|LIST} [what]" msgstr "" +msgid "channel PREPEND topic" +msgstr "" + msgid "channel RESET" msgstr "" diff --git a/modules/chanserv/cs_topic.cpp b/modules/chanserv/cs_topic.cpp index fd5d61b2d..c732af4d4 100644 --- a/modules/chanserv/cs_topic.cpp +++ b/modules/chanserv/cs_topic.cpp @@ -132,14 +132,18 @@ class CommandCSTopic final Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << (!topic.empty() ? "to change the topic to: " : "to unset the topic") << (!topic.empty() ? topic : ""); } - void Append(CommandSource &source, ChannelInfo *ci, const std::vector ¶ms) + void Combine(CommandSource &source, ChannelInfo *ci, const std::vector ¶ms, bool append) { const Anope::string &topic = params[2]; Anope::string new_topic; if (!ci->c->topic.empty()) { - new_topic = ci->c->topic + " " + topic; + if (append) + new_topic = ci->c->topic + " " + topic; + else + new_topic = topic + " " + ci->c->topic; + ci->last_topic.clear(); } else @@ -155,6 +159,7 @@ public: this->SetDesc(_("Manipulate the topic of the specified channel")); this->SetSyntax(_("\037channel\037 [SET] [\037topic\037]")); this->SetSyntax(_("\037channel\037 APPEND \037topic\037")); + this->SetSyntax(_("\037channel\037 PREPEND \037topic\037")); this->SetSyntax(_("\037channel\037 [UNLOCK|LOCK]")); } @@ -174,7 +179,9 @@ public: else if (!ci->c) source.Reply(CHAN_X_NOT_IN_USE, ci->name.c_str()); else if (subcmd.equals_ci("APPEND") && params.size() > 2) - this->Append(source, ci, params); + this->Combine(source, ci, params, true); + else if (subcmd.equals_ci("PREPEND") && params.size() > 2) + this->Combine(source, ci, params, false); else { Anope::string topic;