diff --git a/language/anope.en_US.po b/language/anope.en_US.po index 46d302bd7..ce934aaee 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-13 12:39+0000\n" -"PO-Revision-Date: 2025-11-13 12:39+0000\n" +"POT-Creation-Date: 2025-11-15 16:29+0000\n" +"PO-Revision-Date: 2025-11-15 16:29+0000\n" "Last-Translator: Sadie Powell \n" "Language-Team: English\n" "Language: en_US\n" @@ -594,9 +594,6 @@ msgstr "" msgid "email" msgstr "" -msgid "language" -msgstr "" - msgid "memo-text" msgstr "" @@ -642,9 +639,6 @@ msgstr "" msgid "nickname email" msgstr "" -msgid "nickname language" -msgstr "" - msgid "nickname message" msgstr "" @@ -654,10 +648,10 @@ msgstr "" msgid "nickname new-password" msgstr "" -msgid "nickname timezone" +msgid "nickname [code]" msgstr "" -msgid "nickname [code]" +msgid "nickname [language]" msgstr "" msgid "nickname [parameter]" @@ -666,6 +660,9 @@ msgstr "" msgid "nickname [password]" msgstr "" +msgid "nickname [timezone]" +msgstr "" + msgid "nickname [+expiry] [reason]" msgstr "" @@ -720,9 +717,6 @@ msgstr "" msgid "server [reason]" msgstr "" -msgid "timezone" -msgstr "" - msgid "type parameters" msgstr "" @@ -6539,6 +6533,9 @@ msgstr "" msgid "[key|#X-Y]" msgstr "" +msgid "[language]" +msgstr "" + msgid "[message]" msgstr "" @@ -6560,6 +6557,9 @@ msgstr "" msgid "[parameter]" msgstr "" +msgid "[timezone]" +msgstr "" + msgid "[+daysd] [+limitl] pattern" msgstr "" diff --git a/modules/nickserv/ns_set_language.cpp b/modules/nickserv/ns_set_language.cpp index b1a858cf3..29d4b68f1 100644 --- a/modules/nickserv/ns_set_language.cpp +++ b/modules/nickserv/ns_set_language.cpp @@ -21,12 +21,12 @@ protected: Anope::map &languages; public: - CommandNSSetLanguage(Module *creator, Anope::map &langs, const Anope::string &sname = "nickserv/set/language", size_t min = 1) + CommandNSSetLanguage(Module *creator, Anope::map &langs, const Anope::string &sname = "nickserv/set/language", size_t min = 0) : Command(creator, sname, min, min + 1) , languages(langs) { this->SetDesc(_("Set the language services will use when messaging you")); - this->SetSyntax(_("\037language\037")); + this->SetSyntax(_("[\037language\037]")); } void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) @@ -37,7 +37,7 @@ public: return; } - const NickAlias *na = NickAlias::Find(user); + const auto *na = NickAlias::Find(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); @@ -50,40 +50,52 @@ public: if (MOD_RESULT == EVENT_STOP) return; - auto lang = languages.end(); - for (auto it = languages.begin(); it != languages.end(); ++it) - { - auto &[langcode, langname] = *it; - if (langcode.find_ci(param) != 0) - continue; // Language does not match. + Log() << "PARAM-EMPTY: " << param; - if (lang != languages.end()) + Anope::string langname; + if (param.empty()) + { + langname = Language::Translate(_("English")); + nc->language.clear(); + } + else + { + auto lang = languages.end(); + for (auto it = languages.begin(); it != languages.end(); ++it) { - source.Reply(_("Multiple languages matched \002%s\002. Please be more specific."), param.c_str()); + auto &[langcode, langname] = *it; + if (langcode.find_ci(param) != 0) + continue; // Language does not match. + + if (lang != languages.end()) + { + source.Reply(_("Multiple languages matched \002%s\002. Please be more specific."), param.c_str()); + return; + } + + lang = it; + } + + if (lang == languages.end()) + { + this->OnSyntaxError(source, ""); return; } - lang = it; + langname = lang->second; + nc->language = lang->first; } - if (lang == languages.end()) - { - this->OnSyntaxError(source, ""); - return; - } - - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the language of " << nc->display << " to " << lang->first; - - nc->language = lang->first; + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the language of " << nc->display << " to " << langname; if (source.GetAccount() == nc) - source.Reply(_("Language changed to \002%s\002."), lang->second.c_str()); + source.Reply(_("Language changed to \002%s\002."), langname.c_str()); else - source.Reply(_("Language for \002%s\002 changed to \002%s\002."), nc->display.c_str(), lang->second.c_str()); + source.Reply(_("Language for \002%s\002 changed to \002%s\002."), nc->display.c_str(), langname.c_str()); } - void Execute(CommandSource &source, const std::vector ¶m) override + void Execute(CommandSource &source, const std::vector ¶ms) override { - this->Run(source, source.nc->display, param[0]); + this->Run(source, source.nc->display, params.empty() ? "" : params[0]); } bool OnHelp(CommandSource &source, const Anope::string &) override @@ -109,15 +121,15 @@ class CommandNSSASetLanguage final { public: CommandNSSASetLanguage(Module *creator, Anope::map &langs) - : CommandNSSetLanguage(creator, langs, "nickserv/saset/language", 2) + : CommandNSSetLanguage(creator, langs, "nickserv/saset/language", 1) { this->ClearSyntax(); - this->SetSyntax(_("\037nickname\037 \037language\037")); + this->SetSyntax(_("\037nickname\037 [\037language\037]")); } void Execute(CommandSource &source, const std::vector ¶ms) override { - this->Run(source, params[0], params[1]); + this->Run(source, params[0], params.size() > 1 ? params[1] : ""); } bool OnHelp(CommandSource &source, const Anope::string &) override diff --git a/modules/nickserv/ns_set_timezone.cpp b/modules/nickserv/ns_set_timezone.cpp index 031a02e3e..e59df21f7 100644 --- a/modules/nickserv/ns_set_timezone.cpp +++ b/modules/nickserv/ns_set_timezone.cpp @@ -67,12 +67,12 @@ protected: } public: - CommandNSSetTimezone(Module *creator, SerializableExtensibleItem &tz, const Anope::string &sname = "nickserv/set/timezone", size_t min = 1) + CommandNSSetTimezone(Module *creator, SerializableExtensibleItem &tz, const Anope::string &sname = "nickserv/set/timezone", size_t min = 0) : Command(creator, sname, min, min + 1) , timezone(tz) { this->SetDesc(_("Set the timezone services will use when messaging you")); - this->SetSyntax(_("\037timezone\037")); + this->SetSyntax(_("[\037timezone\037]")); } void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) @@ -97,40 +97,48 @@ public: return; Anope::string usertz; - for (const auto &timezone : timezones) + if (param.empty()) { - if (timezone.find_ci(param) != 0) - continue; // Timezone does not match. - - if (!usertz.empty()) + usertz = "UTC"; + timezone.Unset(nc); + } + else + { + for (const auto &timezone : timezones) { - source.Reply(_("Multiple timezones matched \002%s\002. Please be more specific."), param.c_str()); + if (timezone.find_ci(param) != 0) + continue; // Timezone does not match. + + if (!usertz.empty()) + { + source.Reply(_("Multiple timezones matched \002%s\002. Please be more specific."), param.c_str()); + return; + } + + usertz = timezone; + if (usertz.equals_ci(param)) + break; // Exact match. + } + + if (usertz.empty()) + { + this->OnSyntaxError(source, ""); return; } - usertz = timezone; - if (usertz.equals_ci(param)) - break; // Exact match. - } - - if (usertz.empty()) - { - this->OnSyntaxError(source, ""); - return; + timezone.Set(nc, usertz); } Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the timezone of " << nc->display << " to " << usertz; - - timezone.Set(nc, usertz); if (source.GetAccount() == nc) source.Reply(_("Timezone changed to \002%s\002."), usertz.c_str()); else source.Reply(_("Timezone for \002%s\002 changed to \002%s\002."), nc->display.c_str(), usertz.c_str()); } - void Execute(CommandSource &source, const std::vector ¶m) override + void Execute(CommandSource &source, const std::vector ¶ms) override { - this->Run(source, source.nc->display, param[0]); + this->Run(source, source.nc->display, params.empty() ? "" : params[0]); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -163,15 +171,15 @@ class CommandNSSASetTimezone final { public: CommandNSSASetTimezone(Module *creator, SerializableExtensibleItem &tz) - : CommandNSSetTimezone(creator, tz, "nickserv/saset/timezone", 2) + : CommandNSSetTimezone(creator, tz, "nickserv/saset/timezone", 1) { this->ClearSyntax(); - this->SetSyntax(_("\037nickname\037 \037timezone\037")); + this->SetSyntax(_("\037nickname\037 [\037timezone\037]")); } void Execute(CommandSource &source, const std::vector ¶ms) override { - this->Run(source, params[0], params[1]); + this->Run(source, params[0], params.size() > 1 ? params[1] : ""); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override