diff --git a/language/anope.en_US.po b/language/anope.en_US.po index 70bcc0340..39a92d4b5 100644 --- a/language/anope.en_US.po +++ b/language/anope.en_US.po @@ -16,8 +16,8 @@ msgid "" msgstr "" "Project-Id-Version: Anope\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-11-17 23:13+0000\n" -"PO-Revision-Date: 2025-11-17 23:13+0000\n" +"POT-Creation-Date: 2025-11-18 01:12+0000\n" +"PO-Revision-Date: 2025-11-18 01:12+0000\n" "Last-Translator: Sadie Powell \n" "Language-Team: English\n" "Language: en_US\n" @@ -1288,7 +1288,7 @@ msgstr "" msgid "ADD [+expiry] mask:reason" msgstr "" -msgid "ADD [+expiry] vhost reason" +msgid "ADD [+expiry] vhost [reason]" msgstr "" msgid "ADD {NICK|CHAN|EMAIL|REGISTER} [+expiry] entry reason" diff --git a/modules/hostserv/hs_offer.cpp b/modules/hostserv/hs_offer.cpp index 06dc1cda9..5b2010e2c 100644 --- a/modules/hostserv/hs_offer.cpp +++ b/modules/hostserv/hs_offer.cpp @@ -19,6 +19,7 @@ namespace { + Anope::string network_name; time_t take_delay = 0; Anope::string GetVHostMask(const Anope::string &ident, const Anope::string &host) @@ -47,12 +48,14 @@ namespace return Anope::string(buf); }; + // NOTE: when updating this also update dummy_template. return Anope::Template(ih, { - { "account", na ? na->nc->display : "" }, - { "nick", na ? na->nick : "" }, - { "network", Config->GetBlock("networkinfo").Get("networkname") }, - { "regdate", na ? Anope::ToString(na->registered) : "" }, - { "regepoch", na ? regdate(na) : "" }, + { "account", na ? na->nc->display : "" }, + { "nick", na ? na->nick : "" }, + { "network", network_name }, + { "regdate", na ? regdate(na) : "" }, + { "regepoch", na ? Anope::ToString(na->registered) : "" }, + }); } } @@ -334,7 +337,7 @@ private: const size_t vhost_idx = expiry_idx ? 2 : 1; const size_t reason_idx = expiry_idx ? 3 : 2; - if (params.size() <= reason_idx) + if (params.size() <= vhost_idx) { this->OnSyntaxError(source, "ADD"); return; @@ -371,6 +374,17 @@ private: return; } + auto dummy_template = [](const Anope::string &v) + { + return Anope::Template(v, { + { "account", "a" }, + { "nick", "a" }, + { "network", network_name }, + { "regdate", "1111-11-11" }, + { "regepoch", "1111111111" }, + }); + }; + if (!ident.empty()) { if (!IRCD->CanSetVIdent) @@ -379,7 +393,7 @@ private: return; } - const auto sub_ident = Template(ident, ""); + const auto sub_ident = dummy_template(ident); if (sub_ident.length() > IRCD->MaxUser) { source.Reply(HOST_SET_VIDENT_TOO_LONG, IRCD->MaxUser); @@ -392,7 +406,7 @@ private: } } - const auto sub_host = Template(host, ""); + const auto sub_host = dummy_template(host); if (sub_host.length() > IRCD->MaxHost) { source.Reply(HOST_SET_VHOST_TOO_LONG, IRCD->MaxHost); @@ -412,9 +426,8 @@ private: } Anope::string reason; - for (auto idx = reason_idx; idx <= params.size(); ++idx) - reason += " " + params[idx]; - reason.erase(reason.begin()); + for (auto idx = reason_idx; idx < params.size(); ++idx) + reason.append(reason.empty() ? "" : " ").append(params[idx]); auto *ho = new HostOffer(ident, host, source.GetNick(), reason, Anope::CurTime, expiry); HostOffersList.Add(ho); @@ -556,7 +569,7 @@ public: : Command(creator, "hostserv/offer", 1, 4) { this->SetDesc(_("Manipulate the host offer list")); - this->SetSyntax(_("ADD [+\037expiry\037] \037vhost\037 \037reason\037")); + this->SetSyntax(_("ADD [+\037expiry\037] \037vhost\037 [\037reason\037]")); this->SetSyntax(_("CLEAR")); this->SetSyntax(_("DEL {\037vhost\037 | \037entry-num\037 | \037list\037}")); this->SetSyntax(_("LIST [\037vhost-mask\037 | \037entry-num\037 | \037list\037]")); @@ -913,8 +926,8 @@ public: void OnReload(Configuration::Conf &conf) override { - auto &modconf = conf.GetModule(this); - take_delay = modconf.Get("takedelay"); + network_name = Config->GetBlock("networkinfo").Get("networkname"); + take_delay = conf.GetModule(this).Get("takedelay"); } };