00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "module.h"
00015
00016 class CommandNSSetKill : public Command
00017 {
00018 public:
00019 CommandNSSetKill(Module *creator, const Anope::string &sname = "nickserv/set/kill", size_t min = 1) : Command(creator, sname, min, min + 1)
00020 {
00021 this->SetDesc(_("Turn protection on or off"));
00022 this->SetSyntax(_("{ON | QUICK | IMMED | OFF}"));
00023 }
00024
00025 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
00026 {
00027 const NickAlias *na = NickAlias::Find(user);
00028 if (!na)
00029 {
00030 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
00031 return;
00032 }
00033 NickCore *nc = na->nc;
00034
00035 EventReturn MOD_RESULT;
00036 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
00037 if (MOD_RESULT == EVENT_STOP)
00038 return;
00039
00040 if (param.equals_ci("ON"))
00041 {
00042 nc->SetFlag(NI_KILLPROTECT);
00043 nc->UnsetFlag(NI_KILL_QUICK);
00044 nc->UnsetFlag(NI_KILL_IMMED);
00045 source.Reply(_("Protection is now \002on\002 for \002%s\002."), nc->display.c_str());
00046 }
00047 else if (param.equals_ci("QUICK"))
00048 {
00049 nc->SetFlag(NI_KILLPROTECT);
00050 nc->SetFlag(NI_KILL_QUICK);
00051 nc->UnsetFlag(NI_KILL_IMMED);
00052 source.Reply(_("Protection is now \002on\002 for \002%s\002, with a reduced delay."), nc->display.c_str());
00053 }
00054 else if (param.equals_ci("IMMED"))
00055 {
00056 if (Config->NSAllowKillImmed)
00057 {
00058 nc->SetFlag(NI_KILLPROTECT);
00059 nc->SetFlag(NI_KILL_IMMED);
00060 nc->UnsetFlag(NI_KILL_QUICK);
00061 source.Reply(_("Protection is now \002on\002 for \002%s\002, with no delay."), nc->display.c_str());
00062 }
00063 else
00064 source.Reply(_("The \002IMMED\002 option is not available on this network."));
00065 }
00066 else if (param.equals_ci("OFF"))
00067 {
00068 nc->UnsetFlag(NI_KILLPROTECT);
00069 nc->UnsetFlag(NI_KILL_QUICK);
00070 nc->UnsetFlag(NI_KILL_IMMED);
00071 source.Reply(_("Protection is now \002off\002 for \002%s\002."), nc->display.c_str());
00072 }
00073 else
00074 this->OnSyntaxError(source, "KILL");
00075
00076 return;
00077 }
00078
00079 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00080 {
00081 this->Run(source, source.nc->display, params[0]);
00082 }
00083
00084 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00085 {
00086 this->SendSyntax(source);
00087 source.Reply(" ");
00088 source.Reply(_("Turns the automatic protection option for your nick\n"
00089 "on or off. With protection on, if another user\n"
00090 "tries to take your nick, they will be given one minute to\n"
00091 "change to another nick, after which %s will forcibly change\n"
00092 "their nick.\n"
00093 " \n"
00094 "If you select \002QUICK\002, the user will be given only 20 seconds\n"
00095 "to change nicks instead of the usual 60. If you select\n"
00096 "\002IMMED\002, user's nick will be changed immediately \037without\037 being\n"
00097 "warned first or given a chance to change their nick; please\n"
00098 "do not use this option unless necessary. Also, your\n"
00099 "network's administrators may have disabled this option."), Config->NickServ.c_str());
00100 return true;
00101 }
00102 };
00103
00104 class CommandNSSASetKill : public CommandNSSetKill
00105 {
00106 public:
00107 CommandNSSASetKill(Module *creator) : CommandNSSetKill(creator, "nickserv/saset/kill", 2)
00108 {
00109 this->SetSyntax(_("\037nickname\037 {ON | QUICK | IMMED | OFF}"));
00110 }
00111
00112 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00113 {
00114 this->ClearSyntax();
00115 this->Run(source, params[0], params[1]);
00116 }
00117
00118 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00119 {
00120 this->SendSyntax(source);
00121 source.Reply(" ");
00122 source.Reply(_("Turns the automatic protection option for the nick\n"
00123 "on or off. With protection on, if another user\n"
00124 "tries to take the nick, they will be given one minute to\n"
00125 "change to another nick, after which %s will forcibly change\n"
00126 "their nick.\n"
00127 " \n"
00128 "If you select \002QUICK\002, the user will be given only 20 seconds\n"
00129 "to change nicks instead of the usual 60. If you select\n"
00130 "\002IMMED\002, the user's nick will be changed immediately \037without\037 being\n"
00131 "warned first or given a chance to change their nick; please\n"
00132 "do not use this option unless necessary. Also, your\n"
00133 "network's administrators may have disabled this option."), Config->NickServ.c_str());
00134 return true;
00135 }
00136 };
00137
00138 class NSSetKill : public Module
00139 {
00140 CommandNSSetKill commandnssetkill;
00141 CommandNSSASetKill commandnssasetkill;
00142
00143 public:
00144 NSSetKill(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00145 commandnssetkill(this), commandnssasetkill(this)
00146 {
00147 this->SetAuthor("Anope");
00148
00149 if (Config->NoNicknameOwnership)
00150 throw ModuleException(modname + " can not be used with options:nonicknameownership enabled");
00151 }
00152 };
00153
00154 MODULE_INIT(NSSetKill)