00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "module.h"
00013
00014 class CommandNSSet : public Command
00015 {
00016 public:
00017 CommandNSSet(Module *creator) : Command(creator, "nickserv/set", 1, 3)
00018 {
00019 this->SetDesc(_("Set options, including kill protection"));
00020 this->SetSyntax(_("\037option\037 \037parameters\037"));
00021 }
00022
00023 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00024 {
00025 this->OnSyntaxError(source, "");
00026 return;
00027 }
00028
00029 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
00030 {
00031 this->SendSyntax(source);
00032 source.Reply(" ");
00033 source.Reply(_("Sets various nickname options. \037option\037 can be one of:"));
00034
00035 Anope::string this_name = source.command;
00036 for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it)
00037 {
00038 const Anope::string &c_name = it->first;
00039 const CommandInfo &info = it->second;
00040
00041 if (c_name.find_ci(this_name + " ") == 0)
00042 {
00043 ServiceReference<Command> command("Command", info.name);
00044 if (command)
00045 {
00046 source.command = c_name;
00047 command->OnServHelp(source);
00048 }
00049 }
00050 }
00051
00052 source.Reply(_("Type \002%s%s HELP %s \037option\037\002 for more information\n"
00053 "on a specific option."), Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str(), source.command.c_str());
00054
00055 return true;
00056 }
00057 };
00058
00059 class CommandNSSASet : public Command
00060 {
00061 public:
00062 CommandNSSASet(Module *creator) : Command(creator, "nickserv/saset", 2, 4)
00063 {
00064 this->SetDesc(_("Set SET-options on another nickname"));
00065 this->SetSyntax(_("\037option\037 \037nickname\037 \037parameters\037"));
00066 }
00067
00068 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00069 {
00070 this->OnSyntaxError(source, "");
00071 return;
00072 }
00073
00074 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
00075 {
00076 this->SendSyntax(source);
00077 source.Reply(_("Sets various nickname options. \037option\037 can be one of:"));
00078 Anope::string this_name = source.command;
00079 for (CommandInfo::map::const_iterator it = source.service->commands.begin(), it_end = source.service->commands.end(); it != it_end; ++it)
00080 {
00081 const Anope::string &c_name = it->first;
00082 const CommandInfo &info = it->second;
00083
00084 if (c_name.find_ci(this_name + " ") == 0)
00085 {
00086 ServiceReference<Command> command("Command", info.name);
00087 if (command)
00088 {
00089 source.command = c_name;
00090 command->OnServHelp(source);
00091 }
00092 }
00093 }
00094 source.Reply(_("Type \002%s%s HELP SASET \037option\037\002 for more information\n"
00095 "on a specific option. The options will be set on the given\n"
00096 "\037nickname\037."), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str());
00097 return true;
00098 }
00099 };
00100
00101 class CommandNSSetPassword : public Command
00102 {
00103 public:
00104 CommandNSSetPassword(Module *creator) : Command(creator, "nickserv/set/password", 1)
00105 {
00106 this->SetDesc(_("Set your nickname password"));
00107 this->SetSyntax(_("\037new-password\037"));
00108 }
00109
00110 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00111 {
00112 const Anope::string ¶m = params[1];
00113 unsigned len = param.length();
00114
00115 if (source.GetNick().equals_ci(param) || (Config->StrictPasswords && len < 5))
00116 {
00117 source.Reply(MORE_OBSCURE_PASSWORD);
00118 return;
00119 }
00120 else if (len > Config->PassLen)
00121 {
00122 source.Reply(PASSWORD_TOO_LONG);
00123 return;
00124 }
00125
00126 Anope::Encrypt(param, source.nc->pass);
00127 Anope::string tmp_pass;
00128 if (Anope::Decrypt(source.nc->pass, tmp_pass) == 1)
00129 source.Reply(_("Password for \002%s\002 changed to \002%s\002."), source.nc->display.c_str(), tmp_pass.c_str());
00130 else
00131 source.Reply(_("Password for \002%s\002 changed."), source.nc->display.c_str());
00132 }
00133
00134 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00135 {
00136 this->SendSyntax(source);
00137 source.Reply(" ");
00138 source.Reply(_("Changes the password used to identify you as the nick's\n"
00139 "owner."));
00140 return true;
00141 }
00142 };
00143
00144 class CommandNSSASetPassword : public Command
00145 {
00146 public:
00147 CommandNSSASetPassword(Module *creator) : Command(creator, "nickserv/saset/password", 2, 2)
00148 {
00149 this->SetDesc(_("Set the nickname password"));
00150 this->SetSyntax(_("\037nickname\037 \037new-password\037"));
00151 }
00152
00153 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00154 {
00155 const NickAlias *setter_na = NickAlias::Find(params[0]);
00156 if (setter_na == NULL)
00157 {
00158 source.Reply(NICK_X_NOT_REGISTERED, params[0].c_str());
00159 return;
00160 }
00161 NickCore *nc = setter_na->nc;
00162
00163 size_t len = params[1].length();
00164
00165 if (Config->NSSecureAdmins && source.nc != nc && nc->IsServicesOper())
00166 {
00167 source.Reply(_("You may not change the password of other Services Operators."));
00168 return;
00169 }
00170 else if (nc->display.equals_ci(params[1]) || (Config->StrictPasswords && len < 5))
00171 {
00172 source.Reply(MORE_OBSCURE_PASSWORD);
00173 return;
00174 }
00175 else if (len > Config->PassLen)
00176 {
00177 source.Reply(PASSWORD_TOO_LONG);
00178 return;
00179 }
00180
00181 Anope::Encrypt(params[1], nc->pass);
00182 Anope::string tmp_pass;
00183 if (Anope::Decrypt(nc->pass, tmp_pass) == 1)
00184 source.Reply(_("Password for \002%s\002 changed to \002%s\002."), nc->display.c_str(), tmp_pass.c_str());
00185 else
00186 source.Reply(_("Password for \002%s\002 changed."), nc->display.c_str());
00187
00188 return;
00189 }
00190
00191 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00192 {
00193 this->SendSyntax(source);
00194 source.Reply(" ");
00195 source.Reply(_("Changes the password used to identify as the nick's owner."));
00196 return true;
00197 }
00198 };
00199
00200 class CommandNSSetAutoOp : public Command
00201 {
00202 public:
00203 CommandNSSetAutoOp(Module *creator, const Anope::string &sname = "nickserv/set/autoop", size_t min = 1) : Command(creator, sname, min, min + 1)
00204 {
00205 this->SetDesc(_("Sets whether services should set channel status modes on you automatically."));
00206 this->SetSyntax(_("{ON | OFF}"));
00207 }
00208
00209 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
00210 {
00211 const NickAlias *na = NickAlias::Find(user);
00212 if (na == NULL)
00213 {
00214 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
00215 return;
00216 }
00217 NickCore *nc = na->nc;
00218
00219 EventReturn MOD_RESULT;
00220 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
00221 if (MOD_RESULT == EVENT_STOP)
00222 return;
00223
00224 if (param.equals_ci("ON"))
00225 {
00226 nc->ExtendMetadata("AUTOOP");
00227 source.Reply(_("Services will from now on set status modes on %s in channels."), nc->display.c_str());
00228 }
00229 else if (param.equals_ci("OFF"))
00230 {
00231 nc->Shrink("AUTOOP");
00232 source.Reply(_("Services will no longer set status modes on %s in channels."), nc->display.c_str());
00233 }
00234 else
00235 this->OnSyntaxError(source, "AUTOOP");
00236
00237 return;
00238 }
00239
00240 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00241 {
00242 this->Run(source, source.nc->display, params[0]);
00243 }
00244
00245 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00246 {
00247 this->SendSyntax(source);
00248 source.Reply(" ");
00249 source.Reply(_("Sets whether you will be given your channel status modes automatically.\n"
00250 "Set to \002ON\002 to allow ChanServ to set status modes on you automatically\n"
00251 "when entering channels. Note that depending on channel settings some modes\n"
00252 "may not get set automatically."));
00253 return true;
00254 }
00255 };
00256
00257 class CommandNSSASetAutoOp : public CommandNSSetAutoOp
00258 {
00259 public:
00260 CommandNSSASetAutoOp(Module *creator) : CommandNSSetAutoOp(creator, "nickserv/saset/autoop", 2)
00261 {
00262 this->ClearSyntax();
00263 this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
00264 }
00265
00266 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00267 {
00268 this->Run(source, params[0], params[1]);
00269 }
00270
00271 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00272 {
00273 this->SendSyntax(source);
00274 source.Reply(" ");
00275 source.Reply(_("Sets whether the given nickname will be given its status modes\n"
00276 "in channels automatically. Set to \002ON\002 to allow ChanServ\n"
00277 "to set status modes on the given nickname automatically when it\n"
00278 "is entering channels. Note that depending on channel settings\n"
00279 "some modes may not get set automatically."));
00280 return true;
00281 }
00282 };
00283
00284 class CommandNSSetChanstats : public Command
00285 {
00286 public:
00287 CommandNSSetChanstats(Module *creator, const Anope::string &sname = "nickserv/set/chanstats", size_t min = 1 ) : Command(creator, sname, min, min + 1)
00288 {
00289 this->SetDesc(_("Turn chanstat statistic on or off"));
00290 this->SetSyntax(_("{ON | OFF}"));
00291 }
00292 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
00293 {
00294 NickAlias *na = NickAlias::Find(user);
00295 if (!na)
00296 {
00297 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
00298 return;
00299 }
00300
00301 EventReturn MOD_RESULT;
00302 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, na->nc, param));
00303 if (MOD_RESULT == EVENT_STOP)
00304 return;
00305
00306 if (param.equals_ci("ON"))
00307 {
00308 na->nc->ExtendMetadata("STATS");
00309 source.Reply(_("Chanstat statistics are now enabled for your nick."));
00310 }
00311 else if (param.equals_ci("OFF"))
00312 {
00313 na->nc->Shrink("STATS");
00314 source.Reply(_("Chanstat statistics are now disabled for your nick."));
00315 }
00316 else
00317 this->OnSyntaxError(source, "CHANSTATS");
00318
00319 return;
00320 }
00321
00322 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00323 {
00324 this->Run(source, source.nc->display, params[0]);
00325 }
00326
00327 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00328 {
00329 this->SendSyntax(source);
00330 source.Reply(" ");
00331 source.Reply(_("Turns Chanstats statistics ON or OFF."));
00332 return true;
00333 }
00334 };
00335
00336 class CommandNSSASetChanstats : public CommandNSSetChanstats
00337 {
00338 public:
00339 CommandNSSASetChanstats(Module *creator) : CommandNSSetChanstats(creator, "nickserv/saset/chanstats", 2)
00340 {
00341 this->ClearSyntax();
00342 this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
00343 }
00344
00345 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00346 {
00347 this->Run(source, params[0], params[1]);
00348 }
00349
00350 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00351 {
00352 this->SendSyntax(source);
00353 source.Reply(" ");
00354 source.Reply(_("Turns chanstats channel statistics ON or OFF for this user."));
00355 return true;
00356 }
00357 };
00358
00359 class CommandNSSetDisplay : public Command
00360 {
00361 public:
00362 CommandNSSetDisplay(Module *creator, const Anope::string &sname = "nickserv/set/display", size_t min = 1) : Command(creator, sname, min, min + 1)
00363 {
00364 this->SetDesc(_("Set the display of your group in Services"));
00365 this->SetSyntax(_("\037new-display\037"));
00366 }
00367
00368 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
00369 {
00370 const NickAlias *user_na = NickAlias::Find(user), *na = NickAlias::Find(param);
00371
00372 if (!Config->NoNicknameOwnership)
00373 {
00374 source.Reply(_("This command may not be used on this network because nickname ownership is disabled."));
00375 return;
00376 }
00377 if (user_na == NULL)
00378 {
00379 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
00380 return;
00381 }
00382 else if (!na || *na->nc != *user_na->nc)
00383 {
00384 source.Reply(_("The new display MUST be a nickname of the nickname group %s."), user_na->nc->display.c_str());
00385 return;
00386 }
00387
00388 EventReturn MOD_RESULT;
00389 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, user_na->nc, param));
00390 if (MOD_RESULT == EVENT_STOP)
00391 return;
00392
00393 user_na->nc->SetDisplay(na);
00394 source.Reply(NICK_SET_DISPLAY_CHANGED, user_na->nc->display.c_str());
00395 }
00396
00397 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00398 {
00399 this->Run(source, source.nc->display, params[0]);
00400 }
00401
00402 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00403 {
00404 this->SendSyntax(source);
00405 source.Reply(" ");
00406 source.Reply(_("Changes the display used to refer to your nickname group in\n"
00407 "Services. The new display MUST be a nick of your group."));
00408 return true;
00409 }
00410 };
00411
00412 class CommandNSSASetDisplay : public CommandNSSetDisplay
00413 {
00414 public:
00415 CommandNSSASetDisplay(Module *creator) : CommandNSSetDisplay(creator, "nickserv/saset/display", 2)
00416 {
00417 this->ClearSyntax();
00418 this->SetSyntax(_("\037nickname\037 \037new-display\037"));
00419 }
00420
00421 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00422 {
00423 this->Run(source, params[0], params[1]);
00424 }
00425
00426 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00427 {
00428 this->SendSyntax(source);
00429 source.Reply(" ");
00430 source.Reply(_("Changes the display used to refer to the nickname group in\n"
00431 "Services. The new display MUST be a nick of the group."));
00432 return true;
00433 }
00434 };
00435
00436 class CommandNSSetEmail : public Command
00437 {
00438 static bool SendConfirmMail(User *u, const BotInfo *bi)
00439 {
00440 int chars[] = {
00441 ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
00442 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
00443 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
00444 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
00445 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
00446 };
00447 int idx, min = 1, max = 62;
00448 Anope::string code;
00449 for (idx = 0; idx < 9; ++idx)
00450 code += chars[1 + static_cast<int>((static_cast<float>(max - min)) * static_cast<uint16_t>(rand()) / 65536.0) + min];
00451
00452 u->Account()->Extend("ns_set_email_passcode", new ExtensibleItemClass<Anope::string>(code));
00453
00454 Anope::string subject = Config->MailEmailchangeSubject;
00455 Anope::string message = Config->MailEmailchangeMessage;
00456
00457 subject = subject.replace_all_cs("%e", u->Account()->email);
00458 subject = subject.replace_all_cs("%N", Config->NetworkName);
00459 subject = subject.replace_all_cs("%c", code);
00460
00461 message = message.replace_all_cs("%e", u->Account()->email);
00462 message = message.replace_all_cs("%N", Config->NetworkName);
00463 message = message.replace_all_cs("%c", code);
00464
00465 return Mail::Send(u, u->Account(), bi, subject, message);
00466 }
00467
00468 public:
00469 CommandNSSetEmail(Module *creator, const Anope::string &cname = "nickserv/set/email", size_t min = 0) : Command(creator, cname, min, min + 1)
00470 {
00471 this->SetDesc(_("Associate an E-mail address with your nickname"));
00472 this->SetSyntax(_("\037address\037"));
00473 }
00474
00475 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
00476 {
00477 const NickAlias *na = NickAlias::Find(user);
00478 if (!na)
00479 {
00480 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
00481 return;
00482 }
00483 NickCore *nc = na->nc;
00484
00485 if (param.empty() && Config->NSForceEmail)
00486 {
00487 source.Reply(_("You cannot unset the e-mail on this network."));
00488 return;
00489 }
00490 else if (Config->NSSecureAdmins && source.nc != nc && nc->IsServicesOper())
00491 {
00492 source.Reply(_("You may not change the e-mail of other Services Operators."));
00493 return;
00494 }
00495 else if (!param.empty() && !Mail::Validate(param))
00496 {
00497 source.Reply(MAIL_X_INVALID, param.c_str());
00498 return;
00499 }
00500
00501 EventReturn MOD_RESULT;
00502 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
00503 if (MOD_RESULT == EVENT_STOP)
00504 return;
00505
00506 if (!param.empty() && Config->NSConfirmEmailChanges && !source.IsServicesOper())
00507 {
00508 source.nc->Extend("ns_set_email", new ExtensibleItemClass<Anope::string>(param));
00509 Anope::string old = source.nc->email;
00510 source.nc->email = param;
00511 if (SendConfirmMail(source.GetUser(), source.service))
00512 source.Reply(_("A confirmation e-mail has been sent to \002%s\002. Follow the instructions in it to change your e-mail address."), param.c_str());
00513 source.nc->email = old;
00514 }
00515 else
00516 {
00517 if (!param.empty())
00518 {
00519 nc->email = param;
00520 source.Reply(_("E-mail address for \002%s\002 changed to \002%s\002."), nc->display.c_str(), param.c_str());
00521 }
00522 else
00523 {
00524 nc->email.clear();
00525 source.Reply(_("E-mail address for \002%s\002 unset."), nc->display.c_str());
00526 }
00527 }
00528
00529 return;
00530 }
00531
00532 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00533 {
00534 this->Run(source, source.nc->display, params.size() ? params[0] : "");
00535 }
00536
00537 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00538 {
00539 this->SendSyntax(source);
00540 source.Reply(" ");
00541 source.Reply(_("Associates the given E-mail address with your nickname.\n"
00542 "This address will be displayed whenever someone requests\n"
00543 "information on the nickname with the \002INFO\002 command."));
00544 return true;
00545 }
00546 };
00547
00548 class CommandNSSASetEmail : public CommandNSSetEmail
00549 {
00550 public:
00551 CommandNSSASetEmail(Module *creator) : CommandNSSetEmail(creator, "nickserv/saset/email", 2)
00552 {
00553 this->ClearSyntax();
00554 this->SetSyntax(_("\037nickname\037 \037address\037"));
00555 }
00556
00557 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00558 {
00559 this->Run(source, params[0], params.size() > 1 ? params[1] : "");
00560 }
00561
00562 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00563 {
00564 this->SendSyntax(source);
00565 source.Reply(" ");
00566 source.Reply(_("Associates the given E-mail address with the nickname."));
00567 return true;
00568 }
00569 };
00570
00571 class CommandNSSetGreet : public Command
00572 {
00573 public:
00574 CommandNSSetGreet(Module *creator, const Anope::string &sname = "nickserv/set/greet", size_t min = 0) : Command(creator, sname, min, min + 1)
00575 {
00576 this->SetDesc(_("Associate a greet message with your nickname"));
00577 this->SetSyntax(_("\037message\037"));
00578 }
00579
00580 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
00581 {
00582 const NickAlias *na = NickAlias::Find(user);
00583 if (!na)
00584 {
00585 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
00586 return;
00587 }
00588 NickCore *nc = na->nc;
00589
00590 EventReturn MOD_RESULT;
00591 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
00592 if (MOD_RESULT == EVENT_STOP)
00593 return;
00594
00595 if (!param.empty())
00596 {
00597 nc->greet = param;
00598 source.Reply(_("Greet message for \002%s\002 changed to \002%s\002."), nc->display.c_str(), nc->greet.c_str());
00599 }
00600 else
00601 {
00602 nc->greet.clear();
00603 source.Reply(_("Greet message for \002%s\002 unset."), nc->display.c_str());
00604 }
00605
00606 return;
00607 }
00608
00609 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00610 {
00611 this->Run(source, source.nc->display, params.size() > 0 ? params[0] : "");
00612 }
00613
00614 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00615 {
00616 this->SendSyntax(source);
00617 source.Reply(" ");
00618 source.Reply(_("Makes the given message the greet of your nickname, that\n"
00619 "will be displayed when joining a channel that has GREET\n"
00620 "option enabled, provided that you have the necessary\n"
00621 "access on it."));
00622 return true;
00623 }
00624 };
00625
00626 class CommandNSSASetGreet : public CommandNSSetGreet
00627 {
00628 public:
00629 CommandNSSASetGreet(Module *creator) : CommandNSSetGreet(creator, "nickserv/saset/greet", 1)
00630 {
00631 this->ClearSyntax();
00632 this->SetSyntax(_("\037nickname\037 \037message\037"));
00633 }
00634
00635 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00636 {
00637 this->Run(source, params[0], params.size() > 1 ? params[1] : "");
00638 }
00639
00640 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00641 {
00642 this->SendSyntax(source);
00643 source.Reply(" ");
00644 source.Reply(_("Makes the given message the greet of the nickname, that\n"
00645 "will be displayed when joining a channel that has GREET\n"
00646 "option enabled, provided that the user has the necessary\n"
00647 "access on it."));
00648 return true;
00649 }
00650 };
00651
00652 class CommandNSSetHide : public Command
00653 {
00654 public:
00655 CommandNSSetHide(Module *creator, const Anope::string &sname = "nickserv/set/hide", size_t min = 2) : Command(creator, sname, min, min + 1)
00656 {
00657 this->SetDesc(_("Hide certain pieces of nickname information"));
00658 this->SetSyntax(_("{EMAIL | STATUS | USERMASK | QUIT} {ON | OFF}"));
00659 }
00660
00661 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m, const Anope::string &arg)
00662 {
00663 const NickAlias *na = NickAlias::Find(user);
00664 if (!na)
00665 {
00666 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
00667 return;
00668 }
00669 NickCore *nc = na->nc;
00670
00671 EventReturn MOD_RESULT;
00672 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
00673 if (MOD_RESULT == EVENT_STOP)
00674 return;
00675
00676 Anope::string onmsg, offmsg, flag;
00677
00678 if (param.equals_ci("EMAIL"))
00679 {
00680 flag = "HIDE_EMAIL";
00681 onmsg = _("The E-mail address of \002%s\002 will now be hidden from %s INFO displays.");
00682 offmsg = _("The E-mail address of \002%s\002 will now be shown in %s INFO displays.");
00683 }
00684 else if (param.equals_ci("USERMASK"))
00685 {
00686 flag = "HIDE_MASK";
00687 onmsg = _("The last seen user@host mask of \002%s\002 will now be hidden from %s INFO displays.");
00688 offmsg = _("The last seen user@host mask of \002%s\002 will now be shown in %s INFO displays.");
00689 }
00690 else if (param.equals_ci("STATUS"))
00691 {
00692 flag = "HIDE_STATUS";
00693 onmsg = _("The services access status of \002%s\002 will now be hidden from %s INFO displays.");
00694 offmsg = _("The services access status of \002%s\002 will now be shown in %s INFO displays.");
00695 }
00696 else if (param.equals_ci("QUIT"))
00697 {
00698 flag = "HIDE_QUIT";
00699 onmsg = _("The last quit message of \002%s\002 will now be hidden from %s INFO displays.");
00700 offmsg = _("The last quit message of \002%s\002 will now be shown in %s INFO displays.");
00701 }
00702 else
00703 {
00704 this->OnSyntaxError(source, "HIDE");
00705 return;
00706 }
00707
00708 if (arg.equals_ci("ON"))
00709 {
00710 nc->ExtendMetadata(flag);
00711 source.Reply(onmsg.c_str(), nc->display.c_str(), Config->NickServ.c_str());
00712 }
00713 else if (arg.equals_ci("OFF"))
00714 {
00715 nc->Shrink(flag);
00716 source.Reply(offmsg.c_str(), nc->display.c_str(), Config->NickServ.c_str());
00717 }
00718 else
00719 this->OnSyntaxError(source, "HIDE");
00720
00721 return;
00722 }
00723
00724 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00725 {
00726 this->Run(source, source.nc->display, params[0], params[1]);
00727 }
00728
00729 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00730 {
00731 this->SendSyntax(source);
00732 source.Reply(" ");
00733 source.Reply(_("Allows you to prevent certain pieces of information from\n"
00734 "being displayed when someone does a %s \002INFO\002 on your\n"
00735 "nick. You can hide your E-mail address (\002EMAIL\002), last seen\n"
00736 "user@host mask (\002USERMASK\002), your services access status\n"
00737 "(\002STATUS\002) and last quit message (\002QUIT\002).\n"
00738 "The second parameter specifies whether the information should\n"
00739 "be displayed (\002OFF\002) or hidden (\002ON\002)."), Config->NickServ.c_str());
00740 return true;
00741 }
00742 };
00743
00744 class CommandNSSASetHide : public CommandNSSetHide
00745 {
00746 public:
00747 CommandNSSASetHide(Module *creator) : CommandNSSetHide(creator, "nickserv/saset/hide", 3)
00748 {
00749 this->SetSyntax("\037nickname\037 {EMAIL | STATUS | USERMASK | QUIT} {ON | OFF}");
00750 }
00751
00752 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00753 {
00754 this->ClearSyntax();
00755 this->Run(source, params[0], params[1], params[2]);
00756 }
00757
00758 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00759 {
00760 this->SendSyntax(source);
00761 source.Reply(" ");
00762 source.Reply(_("Allows you to prevent certain pieces of information from\n"
00763 "being displayed when someone does a %s \002INFO\002 on the\n"
00764 "nick. You can hide the E-mail address (\002EMAIL\002), last seen\n"
00765 "user@host mask (\002USERMASK\002), the services access status\n"
00766 "(\002STATUS\002) and last quit message (\002QUIT\002).\n"
00767 "The second parameter specifies whether the information should\n"
00768 "be displayed (\002OFF\002) or hidden (\002ON\002)."), Config->NickServ.c_str());
00769 return true;
00770 }
00771 };
00772
00773 class CommandNSSetKill : public Command
00774 {
00775 public:
00776 CommandNSSetKill(Module *creator, const Anope::string &sname = "nickserv/set/kill", size_t min = 1) : Command(creator, sname, min, min + 1)
00777 {
00778 this->SetDesc(_("Turn protection on or off"));
00779 this->SetSyntax(_("{ON | QUICK | IMMED | OFF}"));
00780 }
00781
00782 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
00783 {
00784 if (Config->NoNicknameOwnership)
00785 {
00786 source.Reply(_("This command may not be used on this network because nickname ownership is disabled."));
00787 return;
00788 }
00789
00790 const NickAlias *na = NickAlias::Find(user);
00791 if (!na)
00792 {
00793 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
00794 return;
00795 }
00796 NickCore *nc = na->nc;
00797
00798 EventReturn MOD_RESULT;
00799 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
00800 if (MOD_RESULT == EVENT_STOP)
00801 return;
00802
00803 if (param.equals_ci("ON"))
00804 {
00805 nc->ExtendMetadata("KILLPROTECT");
00806 nc->Shrink("KILL_QUICK");
00807 nc->Shrink("KILL_IMMED");
00808 source.Reply(_("Protection is now \002on\002 for \002%s\002."), nc->display.c_str());
00809 }
00810 else if (param.equals_ci("QUICK"))
00811 {
00812 nc->ExtendMetadata("KILLPROTECT");
00813 nc->ExtendMetadata("KILL_QUICK");
00814 nc->Shrink("KILL_IMMED");
00815 source.Reply(_("Protection is now \002on\002 for \002%s\002, with a reduced delay."), nc->display.c_str());
00816 }
00817 else if (param.equals_ci("IMMED"))
00818 {
00819 if (Config->NSAllowKillImmed)
00820 {
00821 nc->ExtendMetadata("KILLPROTECT");
00822 nc->ExtendMetadata("KILL_IMMED");
00823 nc->Shrink("KILL_QUICK");
00824 source.Reply(_("Protection is now \002on\002 for \002%s\002, with no delay."), nc->display.c_str());
00825 }
00826 else
00827 source.Reply(_("The \002IMMED\002 option is not available on this network."));
00828 }
00829 else if (param.equals_ci("OFF"))
00830 {
00831 nc->Shrink("KILLPROTECT");
00832 nc->Shrink("KILL_QUICK");
00833 nc->Shrink("KILL_IMMED");
00834 source.Reply(_("Protection is now \002off\002 for \002%s\002."), nc->display.c_str());
00835 }
00836 else
00837 this->OnSyntaxError(source, "KILL");
00838
00839 return;
00840 }
00841
00842 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00843 {
00844 this->Run(source, source.nc->display, params[0]);
00845 }
00846
00847 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00848 {
00849 this->SendSyntax(source);
00850 source.Reply(" ");
00851 source.Reply(_("Turns the automatic protection option for your nick\n"
00852 "on or off. With protection on, if another user\n"
00853 "tries to take your nick, they will be given one minute to\n"
00854 "change to another nick, after which %s will forcibly change\n"
00855 "their nick.\n"
00856 " \n"
00857 "If you select \002QUICK\002, the user will be given only 20 seconds\n"
00858 "to change nicks instead of the usual 60. If you select\n"
00859 "\002IMMED\002, user's nick will be changed immediately \037without\037 being\n"
00860 "warned first or given a chance to change their nick; please\n"
00861 "do not use this option unless necessary. Also, your\n"
00862 "network's administrators may have disabled this option."), Config->NickServ.c_str());
00863 return true;
00864 }
00865 };
00866
00867 class CommandNSSASetKill : public CommandNSSetKill
00868 {
00869 public:
00870 CommandNSSASetKill(Module *creator) : CommandNSSetKill(creator, "nickserv/saset/kill", 2)
00871 {
00872 this->SetSyntax(_("\037nickname\037 {ON | QUICK | IMMED | OFF}"));
00873 }
00874
00875 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00876 {
00877 this->ClearSyntax();
00878 this->Run(source, params[0], params[1]);
00879 }
00880
00881 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00882 {
00883 this->SendSyntax(source);
00884 source.Reply(" ");
00885 source.Reply(_("Turns the automatic protection option for the nick\n"
00886 "on or off. With protection on, if another user\n"
00887 "tries to take the nick, they will be given one minute to\n"
00888 "change to another nick, after which %s will forcibly change\n"
00889 "their nick.\n"
00890 " \n"
00891 "If you select \002QUICK\002, the user will be given only 20 seconds\n"
00892 "to change nicks instead of the usual 60. If you select\n"
00893 "\002IMMED\002, the user's nick will be changed immediately \037without\037 being\n"
00894 "warned first or given a chance to change their nick; please\n"
00895 "do not use this option unless necessary. Also, your\n"
00896 "network's administrators may have disabled this option."), Config->NickServ.c_str());
00897 return true;
00898 }
00899 };
00900
00901 class CommandNSSetLanguage : public Command
00902 {
00903 public:
00904 CommandNSSetLanguage(Module *creator, const Anope::string &sname = "nickserv/set/language", size_t min = 1) : Command(creator, sname, min, min + 1)
00905 {
00906 this->SetDesc(_("Set the language Services will use when messaging you"));
00907 this->SetSyntax(_("\037language\037"));
00908 }
00909
00910 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
00911 {
00912 const NickAlias *na = NickAlias::Find(user);
00913 if (!na)
00914 {
00915 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
00916 return;
00917 }
00918 NickCore *nc = na->nc;
00919
00920 EventReturn MOD_RESULT;
00921 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
00922 if (MOD_RESULT == EVENT_STOP)
00923 return;
00924
00925 for (unsigned j = 0; j < Language::Languages.size(); ++j)
00926 {
00927 if (param == "en" || Language::Languages[j] == param)
00928 break;
00929 else if (j + 1 == Language::Languages.size())
00930 {
00931 this->OnSyntaxError(source, "");
00932 return;
00933 }
00934 }
00935
00936 nc->language = param != "en" ? param : "";
00937 source.Reply(_("Language changed to \002English\002."));
00938
00939 return;
00940 }
00941
00942 void Execute(CommandSource &source, const std::vector<Anope::string> ¶m) anope_override
00943 {
00944 this->Run(source, source.nc->display, param[0]);
00945 }
00946
00947 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00948 {
00949 this->SendSyntax(source);
00950 source.Reply(" ");
00951 source.Reply(_("Changes the language Services uses when sending messages to\n"
00952 "you (for example, when responding to a command you send).\n"
00953 "\037language\037 should be chosen from the following list of\n"
00954 "supported languages:"));
00955
00956 source.Reply(" en (English)");
00957 for (unsigned j = 0; j < Language::Languages.size(); ++j)
00958 {
00959 const Anope::string &langname = Language::Translate(Language::Languages[j].c_str(), _("English"));
00960 if (langname == "English")
00961 continue;
00962 source.Reply(" %s (%s)", Language::Languages[j].c_str(), langname.c_str());
00963 }
00964
00965 return true;
00966 }
00967 };
00968
00969 class CommandNSSASetLanguage : public CommandNSSetLanguage
00970 {
00971 public:
00972 CommandNSSASetLanguage(Module *creator) : CommandNSSetLanguage(creator, "nickserv/saset/language", 2)
00973 {
00974 this->ClearSyntax();
00975 this->SetSyntax(_("\037nickname\037 \037language\037"));
00976 }
00977
00978 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00979 {
00980 this->Run(source, params[0], params[1]);
00981 }
00982
00983 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00984 {
00985 this->SendSyntax(source);
00986 source.Reply(" ");
00987 source.Reply(_("Changes the language Services uses when sending messages to\n"
00988 "the given user (for example, when responding to a command they send).\n"
00989 "\037language\037 should be chosen from the following list of\n"
00990 "supported languages:"));
00991 source.Reply(" en (English)");
00992 for (unsigned j = 0; j < Language::Languages.size(); ++j)
00993 {
00994 const Anope::string &langname = Language::Translate(Language::Languages[j].c_str(), _("English"));
00995 if (langname == "English")
00996 continue;
00997 source.Reply(" %s (%s)", Language::Languages[j].c_str(), langname.c_str());
00998 }
00999 return true;
01000 }
01001 };
01002
01003 class CommandNSSetMessage : public Command
01004 {
01005 public:
01006 CommandNSSetMessage(Module *creator, const Anope::string &sname = "nickserv/set/message", size_t min = 1) : Command(creator, sname, min, min + 1)
01007 {
01008 this->SetDesc(_("Change the communication method of Services"));
01009 this->SetSyntax(_("{ON | OFF}"));
01010 }
01011
01012 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
01013 {
01014 const NickAlias *na = NickAlias::Find(user);
01015 if (!na)
01016 {
01017 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
01018 return;
01019 }
01020 NickCore *nc = na->nc;
01021
01022 if (!Config->UsePrivmsg)
01023 {
01024 source.Reply(_("You cannot %s on this network."), source.command.c_str());
01025 return;
01026 }
01027
01028 EventReturn MOD_RESULT;
01029 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
01030 if (MOD_RESULT == EVENT_STOP)
01031 return;
01032
01033 if (param.equals_ci("ON"))
01034 {
01035 nc->ExtendMetadata("MSG");
01036 source.Reply(_("Services will now reply to \002%s\002 with \002messages\002."), nc->display.c_str());
01037 }
01038 else if (param.equals_ci("OFF"))
01039 {
01040 nc->Shrink("MSG");
01041 source.Reply(_("Services will now reply to \002%s\002 with \002notices\002."), nc->display.c_str());
01042 }
01043 else
01044 this->OnSyntaxError(source, "MSG");
01045
01046 return;
01047 }
01048
01049 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
01050 {
01051 this->Run(source, source.nc->display, params[0]);
01052 }
01053
01054 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
01055 {
01056 this->SendSyntax(source);
01057 source.Reply(" ");
01058 source.Reply(_("Allows you to choose the way Services are communicating with\n"
01059 "you. With \002MSG\002 set, Services will use messages, else they'll\n"
01060 "use notices."));
01061 return true;
01062 }
01063
01064 void OnServHelp(CommandSource &source) anope_override
01065 {
01066 if (Config->UsePrivmsg)
01067 Command::OnServHelp(source);
01068 }
01069 };
01070
01071 class CommandNSSASetMessage : public CommandNSSetMessage
01072 {
01073 public:
01074 CommandNSSASetMessage(Module *creator) : CommandNSSetMessage(creator, "nickserv/saset/message", 2)
01075 {
01076 this->ClearSyntax();
01077 this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
01078 }
01079
01080 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
01081 {
01082 this->SendSyntax(source);
01083 source.Reply(" ");
01084 source.Reply(_("Allows you to choose the way Services are communicating with\n"
01085 "the given user. With \002MSG\002 set, Services will use messages,\n"
01086 "else they'll use notices."));
01087 return true;
01088 }
01089
01090 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
01091 {
01092 this->Run(source, params[0], params[1]);
01093 }
01094 };
01095
01096 class CommandNSSetPrivate : public Command
01097 {
01098 public:
01099 CommandNSSetPrivate(Module *creator, const Anope::string &sname = "nickserv/set/private", size_t min = 1) : Command(creator, sname, min, min + 1)
01100 {
01101 this->SetDesc(Anope::printf(_("Prevent the nickname from appearing in a \002%s%s LIST\002"), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str()));
01102 this->SetSyntax(_("{ON | OFF}"));
01103 }
01104
01105 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
01106 {
01107 const NickAlias *na = NickAlias::Find(user);
01108 if (!na)
01109 {
01110 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
01111 return;
01112 }
01113 NickCore *nc = na->nc;
01114
01115 EventReturn MOD_RESULT;
01116 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
01117 if (MOD_RESULT == EVENT_STOP)
01118 return;
01119
01120 if (param.equals_ci("ON"))
01121 {
01122 nc->ExtendMetadata("PRIVATE");
01123 source.Reply(_("Private option is now \002on\002 for \002%s\002."), nc->display.c_str());
01124 }
01125 else if (param.equals_ci("OFF"))
01126 {
01127 nc->Shrink("PRIVATE");
01128 source.Reply(_("Private option is now \002off\002 for \002%s\002."), nc->display.c_str());
01129 }
01130 else
01131 this->OnSyntaxError(source, "PRIVATE");
01132
01133 return;
01134 }
01135
01136 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
01137 {
01138 this->Run(source, source.nc->display, params[0]);
01139 }
01140
01141 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
01142 {
01143 this->SendSyntax(source);
01144 source.Reply(" ");
01145 source.Reply(_("Turns %s's privacy option on or off for your nick.\n"
01146 "With \002PRIVATE\002 set, your nickname will not appear in\n"
01147 "nickname lists generated with %s's \002LIST\002 command.\n"
01148 "(However, anyone who knows your nickname can still get\n"
01149 "information on it using the \002INFO\002 command.)"),
01150 Config->NickServ.c_str(), Config->NickServ.c_str());
01151 return true;
01152 }
01153 };
01154
01155 class CommandNSSASetPrivate : public CommandNSSetPrivate
01156 {
01157 public:
01158 CommandNSSASetPrivate(Module *creator) : CommandNSSetPrivate(creator, "nickserv/saset/private", 2)
01159 {
01160 this->ClearSyntax();
01161 this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
01162 }
01163
01164 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
01165 {
01166 this->Run(source, params[0], params[1]);
01167 }
01168
01169 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
01170 {
01171 this->SendSyntax(source);
01172 source.Reply(" ");
01173 source.Reply(_("Turns %s's privacy option on or off for the nick.\n"
01174 "With \002PRIVATE\002 set, the nickname will not appear in\n"
01175 "nickname lists generated with %s's \002LIST\002 command.\n"
01176 "(However, anyone who knows the nickname can still get\n"
01177 "information on it using the \002INFO\002 command.)"),
01178 Config->NickServ.c_str(), Config->NickServ.c_str());
01179 return true;
01180 }
01181 };
01182
01183 class CommandNSSetSecure : public Command
01184 {
01185 public:
01186 CommandNSSetSecure(Module *creator, const Anope::string &sname = "nickserv/set/secure", size_t min = 1) : Command(creator, sname, min, min + 1)
01187 {
01188 this->SetDesc(_("Turn nickname security on or off"));
01189 this->SetSyntax(_("{ON | OFF}"));
01190 }
01191
01192 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
01193 {
01194 const NickAlias *na = NickAlias::Find(user);
01195 if (!na)
01196 {
01197 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
01198 return;
01199 }
01200 NickCore *nc = na->nc;
01201
01202 EventReturn MOD_RESULT;
01203 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
01204 if (MOD_RESULT == EVENT_STOP)
01205 return;
01206
01207 if (param.equals_ci("ON"))
01208 {
01209 nc->ExtendMetadata("SECURE");
01210 source.Reply(_("Secure option is now \002on\002 for \002%s\002."), nc->display.c_str());
01211 }
01212 else if (param.equals_ci("OFF"))
01213 {
01214 nc->Shrink("SECURE");
01215 source.Reply(_("Secure option is now \002off\002 for \002%s\002."), nc->display.c_str());
01216 }
01217 else
01218 this->OnSyntaxError(source, "SECURE");
01219 }
01220
01221 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
01222 {
01223 this->Run(source, source.nc->display, params[0]);
01224 }
01225
01226 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
01227 {
01228 this->SendSyntax(source);
01229 source.Reply(" ");
01230 source.Reply(_("Turns %s's security features on or off for your\n"
01231 "nick. With \002SECURE\002 set, you must enter your password\n"
01232 "before you will be recognized as the owner of the nick,\n"
01233 "regardless of whether your address is on the access\n"
01234 "list. However, if you are on the access list, %s\n"
01235 "will not auto-kill you regardless of the setting of the\n"
01236 "\002KILL\002 option."), Config->NickServ.c_str(), Config->NickServ.c_str());
01237 return true;
01238 }
01239 };
01240
01241 class CommandNSSASetSecure : public CommandNSSetSecure
01242 {
01243 public:
01244 CommandNSSASetSecure(Module *creator) : CommandNSSetSecure(creator, "nickserv/saset/secure", 2)
01245 {
01246 this->ClearSyntax();
01247 this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
01248 }
01249
01250 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
01251 {
01252 this->Run(source, params[0], params[1]);
01253 }
01254
01255 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
01256 {
01257 this->SendSyntax(source);
01258 source.Reply(" ");
01259 source.Reply(_("Turns %s's security features on or off for your\n"
01260 "nick. With \002SECURE\002 set, you must enter your password\n"
01261 "before you will be recognized as the owner of the nick,\n"
01262 "regardless of whether your address is on the access\n"
01263 "list. However, if you are on the access list, %s\n"
01264 "will not auto-kill you regardless of the setting of the\n"
01265 "\002KILL\002 option."), Config->NickServ.c_str(), Config->NickServ.c_str());
01266 return true;
01267 }
01268 };
01269
01270 class CommandNSSASetNoexpire : public Command
01271 {
01272 public:
01273 CommandNSSASetNoexpire(Module *creator) : Command(creator, "nickserv/saset/noexpire", 1, 2)
01274 {
01275 this->SetDesc(_("Prevent the nickname from expiring"));
01276 this->SetSyntax(_("\037nickname\037 {ON | OFF}"));
01277 }
01278
01279 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
01280 {
01281 NickAlias *na = NickAlias::Find(params[0]);
01282 if (na == NULL)
01283 {
01284 source.Reply(NICK_X_NOT_REGISTERED, params[0].c_str());
01285 return;
01286 }
01287
01288 Anope::string param = params.size() > 1 ? params[1] : "";
01289
01290 if (param.equals_ci("ON"))
01291 {
01292 na->ExtendMetadata("NO_EXPIRE");
01293 source.Reply(_("Nick %s \002will not\002 expire."), na->nick.c_str());
01294 }
01295 else if (param.equals_ci("OFF"))
01296 {
01297 na->Shrink("NO_EXPIRE");
01298 source.Reply(_("Nick %s \002will\002 expire."), na->nick.c_str());
01299 }
01300 else
01301 this->OnSyntaxError(source, "NOEXPIRE");
01302
01303 return;
01304 }
01305
01306 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
01307 {
01308 this->SendSyntax(source);
01309 source.Reply(" ");
01310 source.Reply(_("Sets whether the given nickname will expire. Setting this\n"
01311 "to \002ON\002 prevents the nickname from expiring."));
01312 return true;
01313 }
01314 };
01315
01316 class NSSet : public Module
01317 {
01318 CommandNSSet commandnsset;
01319 CommandNSSASet commandnssaset;
01320
01321 CommandNSSetAutoOp commandnssetautoop;
01322 CommandNSSASetAutoOp commandnssasetautoop;
01323
01324 CommandNSSetChanstats commandnssetchanstats;
01325 CommandNSSASetChanstats commandnssasetchanstats;
01326 bool NSDefChanstats;
01327
01328 CommandNSSetDisplay commandnssetdisplay;
01329 CommandNSSASetDisplay commandnssasetdisplay;
01330
01331 CommandNSSetEmail commandnssetemail;
01332 CommandNSSASetEmail commandnssasetemail;
01333
01334 CommandNSSetGreet commandnssetgreet;
01335 CommandNSSASetGreet commandnssasetgreet;
01336
01337 CommandNSSetHide commandnssethide;
01338 CommandNSSASetHide commandnssasethide;
01339
01340 CommandNSSetKill commandnssetkill;
01341 CommandNSSASetKill commandnssasetkill;
01342
01343 CommandNSSetLanguage commandnssetlanguage;
01344 CommandNSSASetLanguage commandnssasetlanguage;
01345
01346 CommandNSSetMessage commandnssetmessage;
01347 CommandNSSASetMessage commandnssasetmessage;
01348
01349 CommandNSSetPassword commandnssetpassword;
01350 CommandNSSASetPassword commandnssasetpassword;
01351
01352 CommandNSSetPrivate commandnssetprivate;
01353 CommandNSSASetPrivate commandnssasetprivate;
01354
01355 CommandNSSetSecure commandnssetsecure;
01356 CommandNSSASetSecure commandnssasetsecure;
01357
01358 CommandNSSASetNoexpire commandnssasetnoexpire;
01359
01360 public:
01361 NSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
01362 commandnsset(this), commandnssaset(this),
01363 commandnssetautoop(this), commandnssasetautoop(this),
01364 commandnssetchanstats(this), commandnssasetchanstats(this), NSDefChanstats(false),
01365 commandnssetdisplay(this), commandnssasetdisplay(this),
01366 commandnssetemail(this), commandnssasetemail(this),
01367 commandnssetgreet(this), commandnssasetgreet(this),
01368 commandnssethide(this), commandnssasethide(this),
01369 commandnssetkill(this), commandnssasetkill(this),
01370 commandnssetlanguage(this), commandnssasetlanguage(this),
01371 commandnssetmessage(this), commandnssasetmessage(this),
01372 commandnssetpassword(this), commandnssasetpassword(this),
01373 commandnssetprivate(this), commandnssasetprivate(this),
01374 commandnssetsecure(this), commandnssasetsecure(this),
01375 commandnssasetnoexpire(this)
01376 {
01377 this->SetAuthor("Anope");
01378
01379 Implementation i[] = { I_OnReload, I_OnNickRegister, I_OnPreCommand };
01380 ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
01381
01382 this->OnReload();
01383 }
01384
01385 void OnReload() anope_override
01386 {
01387 ConfigReader config;
01388 NSDefChanstats = config.ReadFlag("chanstats", "NSDefChanstats", "0", 0);
01389 }
01390
01391 void OnNickRegister(NickAlias *na) anope_override
01392 {
01393 if (NSDefChanstats)
01394 na->nc->ExtendMetadata("STATS");
01395 }
01396
01397 EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) anope_override
01398 {
01399 NickCore *uac = source.nc;
01400
01401 if (command->name == "nickserv/confirm" && !params.empty() && uac)
01402 {
01403 Anope::string *new_email = uac->GetExt<ExtensibleItemClass<Anope::string> *>("ns_set_email"), *passcode = uac->GetExt<ExtensibleItemClass<Anope::string> *>("ns_set_email_passcode");
01404 if (new_email && passcode)
01405 {
01406 if (params[0] == *passcode)
01407 {
01408 uac->email = *new_email;
01409 Log(LOG_COMMAND, source, command) << "to confirm their email address change to " << uac->email;
01410 source.Reply(_("Your email address has been changed to \002%s\002."), uac->email.c_str());
01411 uac->Shrink("ns_set_email");
01412 uac->Shrink("ns_set_email_passcode");
01413 return EVENT_STOP;
01414 }
01415 }
01416 }
01417
01418 return EVENT_CONTINUE;
01419 }
01420 };
01421
01422 MODULE_INIT(NSSet)