diff options
Diffstat (limited to 'modules/commands/ns_set.cpp')
-rw-r--r-- | modules/commands/ns_set.cpp | 119 |
1 files changed, 64 insertions, 55 deletions
diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index 252a83262..93024b437 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -11,6 +11,8 @@ #include "module.h" +static ServiceReference<NickServService> nickserv("NickServService", "NickServ"); + class CommandNSSet : public Command { public: @@ -50,7 +52,7 @@ class CommandNSSet : public Command } source.Reply(_("Type \002%s%s HELP %s \037option\037\002 for more information\n" - "on a specific option."), Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str(), this_name.c_str()); + "on a specific option."), Config->StrictPrivmsg.c_str(), source.service->nick.c_str(), this_name.c_str()); return true; } @@ -96,7 +98,7 @@ class CommandNSSASet : public Command source.Reply(_("Type \002%s%s HELP %s \037option\037\002 for more information\n" "on a specific option. The options will be set on the given\n" - "\037nickname\037."), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str(), this_name.c_str()); + "\037nickname\037."), Config->StrictPrivmsg.c_str(), NickServ->nick.c_str(), this_name.c_str()); return true; } }; @@ -115,17 +117,19 @@ class CommandNSSetPassword : public Command const Anope::string ¶m = params[1]; unsigned len = param.length(); - if (source.GetNick().equals_ci(param) || (Config->StrictPasswords && len < 5)) + if (source.GetNick().equals_ci(param) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && len < 5)) { source.Reply(MORE_OBSCURE_PASSWORD); return; } - else if (len > Config->PassLen) + else if (len > Config->GetBlock("options")->Get<unsigned>("passlen")) { source.Reply(PASSWORD_TOO_LONG); return; } + Log(LOG_COMMAND, source, this) << "to change their password"; + Anope::Encrypt(param, source.nc->pass); Anope::string tmp_pass; if (Anope::Decrypt(source.nc->pass, tmp_pass) == 1) @@ -165,22 +169,24 @@ class CommandNSSASetPassword : public Command size_t len = params[1].length(); - if (Config->NSSecureAdmins && source.nc != nc && nc->IsServicesOper()) + if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && source.nc != nc && nc->IsServicesOper()) { source.Reply(_("You may not change the password of other Services Operators.")); return; } - else if (nc->display.equals_ci(params[1]) || (Config->StrictPasswords && len < 5)) + else if (nc->display.equals_ci(params[1]) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && len < 5)) { source.Reply(MORE_OBSCURE_PASSWORD); return; } - else if (len > Config->PassLen) + else if (len > Config->GetBlock("options")->Get<unsigned>("passlen")) { source.Reply(PASSWORD_TOO_LONG); return; } + Log(LOG_ADMIN, source, this) << "to change the password of " << nc->display; + Anope::Encrypt(params[1], nc->pass); Anope::string tmp_pass; if (Anope::Decrypt(nc->pass, tmp_pass) == 1) @@ -226,18 +232,18 @@ class CommandNSSetAutoOp : public Command if (param.equals_ci("ON")) { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable autoop for " << na->nc->display; nc->ExtendMetadata("AUTOOP"); source.Reply(_("Services will from now on set status modes on %s in channels."), nc->display.c_str()); } else if (param.equals_ci("OFF")) { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable autoop for " << na->nc->display; nc->Shrink("AUTOOP"); source.Reply(_("Services will no longer set status modes on %s in channels."), nc->display.c_str()); } else this->OnSyntaxError(source, "AUTOOP"); - - return; } void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override @@ -308,11 +314,13 @@ class CommandNSSetChanstats : public Command if (param.equals_ci("ON")) { + Log(na->nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable chanstats for " << na->nc->display; na->nc->ExtendMetadata("STATS"); source.Reply(_("Chanstat statistics are now enabled for your nick.")); } else if (param.equals_ci("OFF")) { + Log(na->nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable chanstats for " << na->nc->display; na->nc->Shrink("STATS"); source.Reply(_("Chanstat statistics are now disabled for your nick.")); } @@ -372,7 +380,7 @@ class CommandNSSetDisplay : public Command { const NickAlias *user_na = NickAlias::Find(user), *na = NickAlias::Find(param); - if (!Config->NoNicknameOwnership) + if (Config->GetBlock("options")->Get<bool>("nonicknameownership")) { source.Reply(_("This command may not be used on this network because nickname ownership is disabled.")); return; @@ -393,6 +401,8 @@ class CommandNSSetDisplay : public Command if (MOD_RESULT == EVENT_STOP) return; + Log(user_na->nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the display of " << user_na->nc->display << " to " << na->nick; + user_na->nc->SetDisplay(na); source.Reply(NICK_SET_DISPLAY_CHANGED, user_na->nc->display.c_str()); } @@ -454,15 +464,15 @@ class CommandNSSetEmail : public Command u->Account()->Extend("ns_set_email_passcode", new ExtensibleItemClass<Anope::string>(code)); - Anope::string subject = Config->MailEmailchangeSubject; - Anope::string message = Config->MailEmailchangeMessage; + Anope::string subject = Config->GetBlock("mail")->Get<const Anope::string>("emailchange_subject"), + message = Config->GetBlock("mail")->Get<const Anope::string>("emailchange_message"); subject = subject.replace_all_cs("%e", u->Account()->email); - subject = subject.replace_all_cs("%N", Config->NetworkName); + subject = subject.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get<const Anope::string>("networkname")); subject = subject.replace_all_cs("%c", code); message = message.replace_all_cs("%e", u->Account()->email); - message = message.replace_all_cs("%N", Config->NetworkName); + message = message.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get<const Anope::string>("networkname")); message = message.replace_all_cs("%c", code); return Mail::Send(u, u->Account(), bi, subject, message); @@ -485,12 +495,12 @@ class CommandNSSetEmail : public Command } NickCore *nc = na->nc; - if (param.empty() && Config->NSForceEmail) + if (param.empty() && Config->GetModule("nickserv")->Get<bool>("forceemail", "yes")) { source.Reply(_("You cannot unset the e-mail on this network.")); return; } - else if (Config->NSSecureAdmins && source.nc != nc && nc->IsServicesOper()) + else if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && source.nc != nc && nc->IsServicesOper()) { source.Reply(_("You may not change the e-mail of other Services Operators.")); return; @@ -506,7 +516,7 @@ class CommandNSSetEmail : public Command if (MOD_RESULT == EVENT_STOP) return; - if (!param.empty() && Config->NSConfirmEmailChanges && !source.IsServicesOper()) + if (!param.empty() && Config->GetModule("nickserv")->Get<bool>("forceemail", "yes") && !source.IsServicesOper()) { source.nc->Extend("ns_set_email", new ExtensibleItemClass<Anope::string>(param)); Anope::string old = source.nc->email; @@ -519,17 +529,17 @@ class CommandNSSetEmail : public Command { if (!param.empty()) { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the email of " << nc->display << " to " << param; nc->email = param; source.Reply(_("E-mail address for \002%s\002 changed to \002%s\002."), nc->display.c_str(), param.c_str()); } else { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to unset the email of " << nc->display; nc->email.clear(); source.Reply(_("E-mail address for \002%s\002 unset."), nc->display.c_str()); } } - - return; } void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override @@ -597,11 +607,13 @@ class CommandNSSetGreet : public Command if (!param.empty()) { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the greet of " << nc->display; nc->greet = param; source.Reply(_("Greet message for \002%s\002 changed to \002%s\002."), nc->display.c_str(), nc->greet.c_str()); } else { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to unset the greet of " << nc->display; nc->greet.clear(); source.Reply(_("Greet message for \002%s\002 unset."), nc->display.c_str()); } @@ -710,13 +722,15 @@ class CommandNSSetHide : public Command if (arg.equals_ci("ON")) { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change hide " << param << " to " << arg << " for " << nc->display; nc->ExtendMetadata(flag); - source.Reply(onmsg.c_str(), nc->display.c_str(), Config->NickServ.c_str()); + source.Reply(onmsg.c_str(), nc->display.c_str(), NickServ->nick.c_str()); } else if (arg.equals_ci("OFF")) { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change hide " << param << " to " << arg << " for " << nc->display; nc->Shrink(flag); - source.Reply(offmsg.c_str(), nc->display.c_str(), Config->NickServ.c_str()); + source.Reply(offmsg.c_str(), nc->display.c_str(), NickServ->nick.c_str()); } else this->OnSyntaxError(source, "HIDE"); @@ -739,7 +753,7 @@ class CommandNSSetHide : public Command "user@host mask (\002USERMASK\002), your services access status\n" "(\002STATUS\002) and last quit message (\002QUIT\002).\n" "The second parameter specifies whether the information should\n" - "be displayed (\002OFF\002) or hidden (\002ON\002)."), Config->NickServ.c_str()); + "be displayed (\002OFF\002) or hidden (\002ON\002)."), NickServ->nick.c_str()); return true; } }; @@ -768,7 +782,7 @@ class CommandNSSASetHide : public CommandNSSetHide "user@host mask (\002USERMASK\002), the services access status\n" "(\002STATUS\002) and last quit message (\002QUIT\002).\n" "The second parameter specifies whether the information should\n" - "be displayed (\002OFF\002) or hidden (\002ON\002)."), Config->NickServ.c_str()); + "be displayed (\002OFF\002) or hidden (\002ON\002)."), NickServ->nick.c_str()); return true; } }; @@ -784,7 +798,7 @@ class CommandNSSetKill : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { - if (Config->NoNicknameOwnership) + if (Config->GetBlock("options")->Get<bool>("nonicknameownership")) { source.Reply(_("This command may not be used on this network because nickname ownership is disabled.")); return; @@ -808,6 +822,7 @@ class CommandNSSetKill : public Command nc->ExtendMetadata("KILLPROTECT"); nc->Shrink("KILL_QUICK"); nc->Shrink("KILL_IMMED"); + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to set kill on for " << nc->display; source.Reply(_("Protection is now \002on\002 for \002%s\002."), nc->display.c_str()); } else if (param.equals_ci("QUICK")) @@ -815,15 +830,17 @@ class CommandNSSetKill : public Command nc->ExtendMetadata("KILLPROTECT"); nc->ExtendMetadata("KILL_QUICK"); nc->Shrink("KILL_IMMED"); + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to set kill quick for " << nc->display; source.Reply(_("Protection is now \002on\002 for \002%s\002, with a reduced delay."), nc->display.c_str()); } else if (param.equals_ci("IMMED")) { - if (Config->NSAllowKillImmed) + if (Config->GetModule(this->owner)->Get<bool>("allowkillimmed")) { nc->ExtendMetadata("KILLPROTECT"); nc->ExtendMetadata("KILL_IMMED"); nc->Shrink("KILL_QUICK"); + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to set kill immed for " << nc->display; source.Reply(_("Protection is now \002on\002 for \002%s\002, with no delay."), nc->display.c_str()); } else @@ -834,6 +851,7 @@ class CommandNSSetKill : public Command nc->Shrink("KILLPROTECT"); nc->Shrink("KILL_QUICK"); nc->Shrink("KILL_IMMED"); + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable kill for " << nc->display; source.Reply(_("Protection is now \002off\002 for \002%s\002."), nc->display.c_str()); } else @@ -862,7 +880,7 @@ class CommandNSSetKill : public Command "\002IMMED\002, user's nick will be changed immediately \037without\037 being\n" "warned first or given a chance to change their nick; please\n" "do not use this option unless necessary. Also, your\n" - "network's administrators may have disabled this option."), Config->NickServ.c_str()); + "network's administrators may have disabled this option."), NickServ->nick.c_str()); return true; } }; @@ -896,7 +914,7 @@ class CommandNSSASetKill : public CommandNSSetKill "\002IMMED\002, the user's nick will be changed immediately \037without\037 being\n" "warned first or given a chance to change their nick; please\n" "do not use this option unless necessary. Also, your\n" - "network's administrators may have disabled this option."), Config->NickServ.c_str()); + "network's administrators may have disabled this option."), NickServ->nick.c_str()); return true; } }; @@ -936,10 +954,10 @@ class CommandNSSetLanguage : public Command } } + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the langauge of " << nc->display << " to " << param; + nc->language = param != "en" ? param : ""; source.Reply(_("Language changed to \002English\002.")); - - return; } void Execute(CommandSource &source, const std::vector<Anope::string> ¶m) anope_override @@ -1022,7 +1040,7 @@ class CommandNSSetMessage : public Command } NickCore *nc = na->nc; - if (!Config->UsePrivmsg) + if (!Config->GetBlock("options")->Get<bool>("useprivmsg")) { source.Reply(_("You cannot %s on this network."), source.command.c_str()); return; @@ -1035,11 +1053,13 @@ class CommandNSSetMessage : public Command if (param.equals_ci("ON")) { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable " << source.command << " for " << nc->display; nc->ExtendMetadata("MSG"); source.Reply(_("Services will now reply to \002%s\002 with \002messages\002."), nc->display.c_str()); } else if (param.equals_ci("OFF")) { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable " << source.command << " for " << nc->display; nc->Shrink("MSG"); source.Reply(_("Services will now reply to \002%s\002 with \002notices\002."), nc->display.c_str()); } @@ -1066,7 +1086,7 @@ class CommandNSSetMessage : public Command void OnServHelp(CommandSource &source) anope_override { - if (Config->UsePrivmsg) + if (!Config->GetBlock("options")->Get<bool>("useprivmsg")) Command::OnServHelp(source); } }; @@ -1101,7 +1121,7 @@ class CommandNSSetPrivate : public Command public: CommandNSSetPrivate(Module *creator, const Anope::string &sname = "nickserv/set/private", size_t min = 1) : Command(creator, sname, min, min + 1) { - this->SetDesc(Anope::printf(_("Prevent the nickname from appearing in a \002%s%s LIST\002"), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str())); + this->SetDesc(_("Prevent the nickname from appearing in the LIST command")); this->SetSyntax(_("{ON | OFF}")); } @@ -1122,11 +1142,13 @@ class CommandNSSetPrivate : public Command if (param.equals_ci("ON")) { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable private for " << nc->display; nc->ExtendMetadata("PRIVATE"); source.Reply(_("Private option is now \002on\002 for \002%s\002."), nc->display.c_str()); } else if (param.equals_ci("OFF")) { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable private for " << nc->display; nc->Shrink("PRIVATE"); source.Reply(_("Private option is now \002off\002 for \002%s\002."), nc->display.c_str()); } @@ -1150,7 +1172,7 @@ class CommandNSSetPrivate : public Command "nickname lists generated with %s's \002LIST\002 command.\n" "(However, anyone who knows your nickname can still get\n" "information on it using the \002INFO\002 command.)"), - Config->NickServ.c_str(), Config->NickServ.c_str()); + NickServ->nick.c_str(), NickServ->nick.c_str()); return true; } }; @@ -1178,7 +1200,7 @@ class CommandNSSASetPrivate : public CommandNSSetPrivate "nickname lists generated with %s's \002LIST\002 command.\n" "(However, anyone who knows the nickname can still get\n" "information on it using the \002INFO\002 command.)"), - Config->NickServ.c_str(), Config->NickServ.c_str()); + NickServ->nick.c_str(), NickServ->nick.c_str()); return true; } }; @@ -1209,11 +1231,13 @@ class CommandNSSetSecure : public Command if (param.equals_ci("ON")) { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable secure for " << nc->display; nc->ExtendMetadata("SECURE"); source.Reply(_("Secure option is now \002on\002 for \002%s\002."), nc->display.c_str()); } else if (param.equals_ci("OFF")) { + Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable secure for " << nc->display; nc->Shrink("SECURE"); source.Reply(_("Secure option is now \002off\002 for \002%s\002."), nc->display.c_str()); } @@ -1236,7 +1260,7 @@ class CommandNSSetSecure : public Command "regardless of whether your address is on the access\n" "list. However, if you are on the access list, %s\n" "will not auto-kill you regardless of the setting of the\n" - "\002KILL\002 option."), Config->NickServ.c_str(), Config->NickServ.c_str()); + "\002KILL\002 option."), NickServ->nick.c_str(), NickServ->nick.c_str()); return true; } }; @@ -1265,7 +1289,7 @@ class CommandNSSASetSecure : public CommandNSSetSecure "regardless of whether your address is on the access\n" "list. However, if you are on the access list, %s\n" "will not auto-kill you regardless of the setting of the\n" - "\002KILL\002 option."), Config->NickServ.c_str(), Config->NickServ.c_str()); + "\002KILL\002 option."), NickServ->nick.c_str(), NickServ->nick.c_str()); return true; } }; @@ -1292,18 +1316,18 @@ class CommandNSSASetNoexpire : public Command if (param.equals_ci("ON")) { + Log(LOG_ADMIN, source, this) << "to enable noexpire " << na->nc->display; na->ExtendMetadata("NO_EXPIRE"); source.Reply(_("Nick %s \002will not\002 expire."), na->nick.c_str()); } else if (param.equals_ci("OFF")) { + Log(LOG_ADMIN, source, this) << "to disable noexpire " << na->nc->display; na->Shrink("NO_EXPIRE"); source.Reply(_("Nick %s \002will\002 expire."), na->nick.c_str()); } else this->OnSyntaxError(source, "NOEXPIRE"); - - return; } bool OnHelp(CommandSource &source, const Anope::string &) anope_override @@ -1361,7 +1385,7 @@ class NSSet : public Module CommandNSSASetNoexpire commandnssasetnoexpire; public: - NSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), + NSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandnsset(this), commandnssaset(this), commandnssetautoop(this), commandnssasetautoop(this), commandnssetchanstats(this), commandnssasetchanstats(this), NSDefChanstats(false), @@ -1377,24 +1401,9 @@ class NSSet : public Module commandnssetsecure(this), commandnssasetsecure(this), commandnssasetnoexpire(this) { - this->SetAuthor("Anope"); - Implementation i[] = { I_OnReload, I_OnNickRegister, I_OnPreCommand }; + Implementation i[] = { I_OnPreCommand }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); - - this->OnReload(); - } - - void OnReload() anope_override - { - ConfigReader config; - NSDefChanstats = config.ReadFlag("chanstats", "NSDefChanstats", "0", 0); - } - - void OnNickRegister(NickAlias *na) anope_override - { - if (NSDefChanstats) - na->nc->ExtendMetadata("STATS"); } EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) anope_override |