summaryrefslogtreecommitdiff
path: root/src/core/ns_saset.cpp
diff options
context:
space:
mode:
authorAdam <Adam@drink-coca-cola.info>2010-06-03 23:09:22 -0400
committerAdam <Adam@anope.org>2010-06-18 21:04:09 -0400
commite6447fa2c40270d2e2435229127dd970194b47d9 (patch)
tree65778fc16c1789517595b2b4cbfcb2c9330b022e /src/core/ns_saset.cpp
parent6cd88494662c5c4af2da891926dcc82367596cb9 (diff)
Added in a subcommand system and switched ns_set and ns_saset to use it
Diffstat (limited to 'src/core/ns_saset.cpp')
-rw-r--r--src/core/ns_saset.cpp579
1 files changed, 123 insertions, 456 deletions
diff --git a/src/core/ns_saset.cpp b/src/core/ns_saset.cpp
index c2e5831bd..ccc6be928 100644
--- a/src/core/ns_saset.cpp
+++ b/src/core/ns_saset.cpp
@@ -16,559 +16,223 @@
class CommandNSSASet : public Command
{
-private:
- CommandReturn DoSetDisplay(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ std::map<ci::string, Command *> subcommands;
+ public:
+ CommandNSSASet(const ci::string &cname) : Command(cname, 2, 4)
{
- ci::string param = params.size() > 2 ? params[2] : "";
-
- if (param.empty())
- {
- this->OnSyntaxError(u, "DISPLAY");
- return MOD_CONT;
- }
-
- /* First check whether param is a valid nick of the group */
- NickAlias *na = findnick(param);
-
- if (!na || na->nc != nc)
- {
- notice_lang(Config.s_NickServ, u, NICK_SASET_DISPLAY_INVALID, nc->display);
- return MOD_CONT;
- }
-
- change_core_display(nc, param.c_str());
- notice_lang(Config.s_NickServ, u, NICK_SASET_DISPLAY_CHANGED, nc->display);
- return MOD_CONT;
}
- CommandReturn DoSetPassword(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ ~CommandNSSASet()
{
- ci::string param = params.size() > 2 ? params[2] : "";
- std::string buf, tmp_pass;
-
- if (param.empty())
+ for (std::map<ci::string, Command *>::const_iterator it = this->subcommands.begin(); it != this->subcommands.end(); ++it)
{
- this->OnSyntaxError(u, "PASSWORD");
- return MOD_CONT;
+ delete it->second;
}
-
- int len = param.size();
-
- if (Config.NSSecureAdmins && u->Account() != nc && nc->IsServicesOper())
- {
- notice_lang(Config.s_NickServ, u, ACCESS_DENIED);
- return MOD_CONT;
- }
- else if (nc->display == param || (Config.StrictPasswords && len < 5))
- {
- notice_lang(Config.s_NickServ, u, MORE_OBSCURE_PASSWORD);
- return MOD_CONT;
- }
- else if (len > Config.PassLen)
- {
- notice_lang(Config.s_NickServ, u, PASSWORD_TOO_LONG);
- return MOD_CONT;
- }
- buf = param.c_str(); /* conversion from ci::string to std::string */
- if (enc_encrypt(buf, nc->pass))
- {
- Alog() << Config.s_NickServ << ": Failed to encrypt password for " << nc->display << " (set)";
- notice_lang(Config.s_NickServ, u, NICK_SASET_PASSWORD_FAILED, nc->display);
- return MOD_CONT;
- }
-
- if (enc_decrypt(nc->pass, tmp_pass) == 1)
- notice_lang(Config.s_NickServ, u, NICK_SASET_PASSWORD_CHANGED_TO, nc->display, tmp_pass.c_str());
- else
- notice_lang(Config.s_NickServ, u, NICK_SASET_PASSWORD_CHANGED, nc->display);
-
- Alog() << Config.s_NickServ << ": " << u->GetMask() << " used SASET PASSWORD on " << nc->display << " (e-mail: "<< (nc->email ? nc->email : "none") << ")";
- if (Config.WallSetpass)
- ircdproto->SendGlobops(NickServ, "\2%s\2 used SASET PASSWORD on \2%s\2", u->nick.c_str(), nc->display);
- return MOD_CONT;
- }
-
- CommandReturn DoSetUrl(User *u, const std::vector<ci::string> &params, NickCore *nc)
- {
- const char *param = params.size() > 2 ? params[2].c_str() : NULL;
-
- if (nc->url)
- delete [] nc->url;
-
- if (param)
- {
- nc->url = sstrdup(param);
- notice_lang(Config.s_NickServ, u, NICK_SASET_URL_CHANGED, nc->display, param);
- }
- else
- {
- nc->url = NULL;
- notice_lang(Config.s_NickServ, u, NICK_SASET_URL_UNSET, nc->display);
- }
- return MOD_CONT;
+ this->subcommands.clear();
}
- CommandReturn DoSetEmail(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
- const char *param = params.size() > 2 ? params[2].c_str() : NULL;
+ const char *nick = params[0].c_str();
+ ci::string cmd = params[1];
- if (!param && Config.NSForceEmail)
- {
- notice_lang(Config.s_NickServ, u, NICK_SASET_EMAIL_UNSET_IMPOSSIBLE);
- return MOD_CONT;
- }
- else if (Config.NSSecureAdmins && u->Account() != nc && nc->IsServicesOper())
- {
- notice_lang(Config.s_NickServ, u, ACCESS_DENIED);
- return MOD_CONT;
- }
- else if (param && !MailValidate(param))
+ if (readonly)
{
- notice_lang(Config.s_NickServ, u, MAIL_X_INVALID, param);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_DISABLED);
return MOD_CONT;
}
- Alog() << Config.s_NickServ << ": " << u->GetMask() << " used SASET EMAIL on " << nc->display << " (e-mail: " << (nc->email ? nc->email : "none") << ")";
-
- if (nc->email)
- delete [] nc->email;
-
- if (param)
- {
- nc->email = sstrdup(param);
- notice_lang(Config.s_NickServ, u, NICK_SASET_EMAIL_CHANGED, nc->display, param);
- }
+ NickAlias *na = findnick(nick);
+ if (!na)
+ notice_lang(Config.s_NickServ, u, NICK_SASET_BAD_NICK, nick);
+ else if (na->HasFlag(NS_FORBIDDEN))
+ notice_lang(Config.s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
+ else if (na->nc->HasFlag(NI_SUSPENDED))
+ notice_lang(Config.s_NickServ, u, NICK_X_SUSPENDED, na->nick);
else
{
- nc->email = NULL;
- notice_lang(Config.s_NickServ, u, NICK_SASET_EMAIL_UNSET, nc->display);
- }
- return MOD_CONT;
- }
+ Command *c = this->FindCommand(params[1]);
- CommandReturn DoSetICQ(User *u, const std::vector<ci::string> &params, NickCore *nc)
- {
- const char *param = params.size() > 2 ? params[2].c_str() : NULL;
-
- if (param)
- {
- int32 tmp = atol(param);
- if (!tmp)
- notice_lang(Config.s_NickServ, u, NICK_SASET_ICQ_INVALID, param);
+ if (c)
+ {
+ ci::string cmdparams = na->nc->display;
+ for (std::vector<ci::string>::const_iterator it = params.begin() + 1; it != params.end(); ++it)
+ cmdparams += " " + *it;
+ mod_run_cmd(NickServ, u, c, params[1], cmdparams);
+ }
else
{
- nc->icq = tmp;
- notice_lang(Config.s_NickServ, u, NICK_SASET_ICQ_CHANGED, nc->display, param);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_UNKNOWN_OPTION, cmd.c_str());
}
}
- else
- {
- nc->icq = 0;
- notice_lang(Config.s_NickServ, u, NICK_SASET_ICQ_UNSET, nc->display);
- }
+
return MOD_CONT;
}
- CommandReturn DoSetGreet(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ bool OnHelp(User *u, const ci::string &subcommand)
{
- const char *param = params.size() > 2 ? params[2].c_str() : NULL;
-
- if (nc->greet)
- delete [] nc->greet;
-
- if (param)
+ if (subcommand.empty())
{
- char buf[BUFSIZE];
- const char *rest = params.size() > 3 ? params[3].c_str() : NULL;
-
- snprintf(buf, sizeof(buf), "%s%s%s", param, rest ? " " : "", rest ? rest : "");
-
- nc->greet = sstrdup(buf);
- notice_lang(Config.s_NickServ, u, NICK_SASET_GREET_CHANGED, nc->display, buf);
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_HEAD);
+ for (std::map<ci::string, Command *>::iterator it = this->subcommands.begin(); it != this->subcommands.end(); ++it)
+ it->second->OnServHelp(u);
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_TAIL);
+ return true;
}
else
{
- nc->greet = NULL;
- notice_lang(Config.s_NickServ, u, NICK_SASET_GREET_UNSET, nc->display);
- }
- return MOD_CONT;
- }
-
- CommandReturn DoSetKill(User *u, const std::vector<ci::string> &params, NickCore *nc)
- {
- ci::string param = params.size() > 2 ? params[2] : "";
-
- if (param.empty())
- {
- this->OnSyntaxError(u, "KILL");
- return MOD_CONT;
- }
+ Command *c = this->FindCommand(subcommand);
- if (param == "ON")
- {
- nc->SetFlag(NI_KILLPROTECT);
- nc->UnsetFlag(NI_KILL_QUICK);
- nc->UnsetFlag(NI_KILL_IMMED);
- notice_lang(Config.s_NickServ, u, NICK_SASET_KILL_ON, nc->display);
- }
- else if (param == "QUICK")
- {
- nc->SetFlag(NI_KILLPROTECT);
- nc->SetFlag(NI_KILL_QUICK);
- nc->UnsetFlag(NI_KILL_IMMED);
- notice_lang(Config.s_NickServ, u, NICK_SASET_KILL_QUICK, nc->display);
- }
- else if (param == "IMMED")
- {
- if (Config.NSAllowKillImmed)
+ if (c)
{
- nc->SetFlag(NI_KILLPROTECT);
- nc->SetFlag(NI_KILL_IMMED);
- nc->UnsetFlag(NI_KILL_QUICK);
- notice_lang(Config.s_NickServ, u, NICK_SASET_KILL_IMMED, nc->display);
+ return c->OnHelp(u, subcommand);
}
- else
- notice_lang(Config.s_NickServ, u, NICK_SASET_KILL_IMMED_DISABLED);
- }
- else if (param == "OFF")
- {
- nc->UnsetFlag(NI_KILLPROTECT);
- nc->UnsetFlag(NI_KILL_QUICK);
- nc->UnsetFlag(NI_KILL_IMMED);
- notice_lang(Config.s_NickServ, u, NICK_SASET_KILL_OFF, nc->display);
}
- else
- syntax_error(Config.s_NickServ, u, "SASET KILL", Config.NSAllowKillImmed ? NICK_SASET_KILL_IMMED_SYNTAX : NICK_SASET_KILL_SYNTAX);
- return MOD_CONT;
+
+ return false;
}
- CommandReturn DoSetSecure(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ void OnSyntaxError(User *u, const ci::string &subcommand)
{
- ci::string param = params.size() > 2 ? params[2] : "";
-
- if (param.empty())
- {
- this->OnSyntaxError(u, "SECURE");
- return MOD_CONT;
- }
-
- if (param == "ON")
- {
- nc->SetFlag(NI_SECURE);
- notice_lang(Config.s_NickServ, u, NICK_SASET_SECURE_ON, nc->display);
- }
- else if (param == "OFF")
- {
- nc->UnsetFlag(NI_SECURE);
- notice_lang(Config.s_NickServ, u, NICK_SASET_SECURE_OFF, nc->display);
- }
- else
- syntax_error(Config.s_NickServ, u, "SASET SECURE", NICK_SASET_SECURE_SYNTAX);
- return MOD_CONT;
+ syntax_error(Config.s_NickServ, u, "SASET", NICK_SASET_SYNTAX);
}
- CommandReturn DoSetPrivate(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ void OnServHelp(User *u)
{
- ci::string param = params.size() > 2 ? params[2] : "";
-
- if (param.empty())
- {
- this->OnSyntaxError(u, "PRIVATE");
- return MOD_CONT;
- }
-
- if (param == "ON")
- {
- nc->SetFlag(NI_PRIVATE);
- notice_lang(Config.s_NickServ, u, NICK_SASET_PRIVATE_ON, nc->display);
- }
- else if (param == "OFF")
- {
- nc->UnsetFlag(NI_PRIVATE);
- notice_lang(Config.s_NickServ, u, NICK_SASET_PRIVATE_OFF, nc->display);
- }
- else
- syntax_error(Config.s_NickServ, u, "SASET PRIVATE", NICK_SASET_PRIVATE_SYNTAX);
- return MOD_CONT;
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET);
}
- CommandReturn DoSetMsg(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ bool AddSubcommand(Command *c)
{
- ci::string param = params.size() > 2 ? params[2] : "";
-
- if (param.empty())
- {
- this->OnSyntaxError(u, "MSG");
- return MOD_CONT;
- }
-
- if (!Config.UsePrivmsg)
- {
- notice_lang(Config.s_NickServ, u, NICK_SASET_OPTION_DISABLED, "MSG");
- return MOD_CONT;
- }
+ return this->subcommands.insert(std::make_pair(c->name, c)).second;
+ }
- if (param == "ON")
- {
- nc->SetFlag(NI_MSG);
- notice_lang(Config.s_NickServ, u, NICK_SASET_MSG_ON, nc->display);
- }
- else if (param == "OFF")
- {
- nc->UnsetFlag(NI_MSG);
- notice_lang(Config.s_NickServ, u, NICK_SASET_MSG_OFF, nc->display);
- }
- else
- syntax_error(Config.s_NickServ, u, "SASET MSG", NICK_SASET_MSG_SYNTAX);
- return MOD_CONT;
+ bool DelSubcommand(const ci::string &command)
+ {
+ return this->subcommands.erase(command);
}
- CommandReturn DoSetHide(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ Command *FindCommand(const ci::string &subcommand)
{
- ci::string param = params.size() > 2 ? params[2] : "";
+ std::map<ci::string, Command *>::const_iterator it = this->subcommands.find(subcommand);
- if (param.empty())
+ if (it != this->subcommands.end())
{
- this->OnSyntaxError(u, "HIDE");
- return MOD_CONT;
+ return it->second;
}
- int onmsg, offmsg;
- NickCoreFlag flag;
-
- if (param == "EMAIL")
- {
- flag = NI_HIDE_EMAIL;
- onmsg = NICK_SASET_HIDE_EMAIL_ON;
- offmsg = NICK_SASET_HIDE_EMAIL_OFF;
- }
- else if (param == "USERMASK")
- {
- flag = NI_HIDE_MASK;
- onmsg = NICK_SASET_HIDE_MASK_ON;
- offmsg = NICK_SASET_HIDE_MASK_OFF;
- }
- else if (param == "STATUS")
- {
- flag = NI_HIDE_STATUS;
- onmsg = NICK_SASET_HIDE_STATUS_ON;
- offmsg = NICK_SASET_HIDE_STATUS_OFF;
- }
- else if (param == "QUIT")
- {
- flag = NI_HIDE_QUIT;
- onmsg = NICK_SASET_HIDE_QUIT_ON;
- offmsg = NICK_SASET_HIDE_QUIT_OFF;
- }
- else
- {
- syntax_error(Config.s_NickServ, u, "SASET HIDE", NICK_SASET_HIDE_SYNTAX);
- return MOD_CONT;
- }
+ return NULL;
+ }
+};
- param = params.size() > 3 ? params[3] : "";
- if (param.empty())
- syntax_error(Config.s_NickServ, u, "SASET HIDE", NICK_SASET_HIDE_SYNTAX);
- else if (param == "ON")
- {
- nc->SetFlag(flag);
- notice_lang(Config.s_NickServ, u, onmsg, nc->display, Config.s_NickServ);
- }
- else if (param == "OFF")
- {
- nc->UnsetFlag(flag);
- notice_lang(Config.s_NickServ, u, offmsg, nc->display, Config.s_NickServ);
- }
- else
- syntax_error(Config.s_NickServ, u, "SASET HIDE", NICK_SASET_HIDE_SYNTAX);
- return MOD_CONT;
+class CommandNSSASetDisplay : public Command
+{
+ public:
+ CommandNSSASetDisplay(const ci::string &cname) : Command(cname, 2, 2, "nickserv/saset/display")
+ {
}
- CommandReturn DoSetNoExpire(User *u, const std::vector<ci::string> &params, NickAlias *na)
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
- ci::string param = params.size() > 2 ? params[2] : "";
+ NickCore *nc = findcore(params[0]);
+ assert(nc);
- if (param.empty())
+ NickAlias *na = findnick(params[1]);
+ if (!na || na->nc != nc)
{
- syntax_error(Config.s_NickServ, u, "SASET NOEXPIRE", NICK_SASET_NOEXPIRE_SYNTAX);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_DISPLAY_INVALID, nc->display);
return MOD_CONT;
}
- if (param == "ON")
- {
- na->SetFlag(NS_NO_EXPIRE);
- notice_lang(Config.s_NickServ, u, NICK_SASET_NOEXPIRE_ON, na->nick);
- }
- else if (param == "OFF")
- {
- na->UnsetFlag(NS_NO_EXPIRE);
- notice_lang(Config.s_NickServ, u, NICK_SASET_NOEXPIRE_OFF, na->nick);
- }
- else
- syntax_error(Config.s_NickServ, u, "SASET NOEXPIRE", NICK_SASET_NOEXPIRE_SYNTAX);
+ change_core_display(nc, params[1].c_str());
+ notice_lang(Config.s_NickServ, u, NICK_SASET_DISPLAY_CHANGED, nc->display);
return MOD_CONT;
}
- CommandReturn DoSetAutoOP(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ bool OnHelp(User *u, const ci::string &)
{
- ci::string param = params.size() > 2 ? params[2] : "";
-
- if (param.empty())
- {
- this->OnSyntaxError(u, "AUTOOP");
- return MOD_CONT;
- }
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_DISPLAY);
+ return true;
+ }
- if (param == "ON")
- {
- nc->SetFlag(NI_AUTOOP);
- notice_lang(Config.s_NickServ, u, NICK_SASET_AUTOOP_ON, nc->display);
- }
- else if (param == "OFF")
- {
- nc->UnsetFlag(NI_AUTOOP);
- notice_lang(Config.s_NickServ, u, NICK_SASET_AUTOOP_OFF, nc->display);
- }
- else
- syntax_error(Config.s_NickServ, u, "SET AUTOOP", NICK_SASET_AUTOOP_SYNTAX);
+ void OnSyntaxError(User *u)
+ {
+ // XXX
+ syntax_error(Config.s_NickServ, u, "SASET", NICK_SASET_SYNTAX);
+ }
- return MOD_CONT;
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET_DISPLAY);
}
+};
- CommandReturn DoSetLanguage(User *u, const std::vector<ci::string> &params, NickCore *nc)
+class CommandNSSASetPassword : public Command
+{
+ public:
+ CommandNSSASetPassword(const ci::string &cname) : Command(cname, 2, 2, "nickserv/saset/password")
{
- const char *param = params.size() > 2 ? params[2].c_str() : NULL;
+ }
- if (!param)
- {
- this->OnSyntaxError(u, "LANGUAGE");
- return MOD_CONT;
- }
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ NickCore *nc = findcore(params[0]);
+ assert(nc);
- int langnum;
+ size_t len = params[1].size();
- if (param[strspn(param, "0123456789")]) /* i.e. not a number */
+ if (Config.NSSecureAdmins && u->Account() != nc && nc->IsServicesOper())
{
- syntax_error(Config.s_NickServ, u, "SASET LANGUAGE", NICK_SASET_LANGUAGE_SYNTAX);
+ notice_lang(Config.s_NickServ, u, ACCESS_DENIED);
return MOD_CONT;
}
- langnum = atoi(param) - 1;
- if (langnum < 0 || langnum >= NUM_LANGS || langlist[langnum] < 0)
+ else if (nc->display == params[1] || (Config.StrictPasswords && len < 5))
{
- notice_lang(Config.s_NickServ, u, NICK_SASET_LANGUAGE_UNKNOWN, langnum + 1, Config.s_NickServ);
+ notice_lang(Config.s_NickServ, u, MORE_OBSCURE_PASSWORD);
return MOD_CONT;
}
- nc->language = langlist[langnum];
- notice_lang(Config.s_NickServ, u, NICK_SASET_LANGUAGE_CHANGED);
-
- return MOD_CONT;
- }
-public:
- CommandNSSASet() : Command("SASET", 2, 4, "nickserv/saset")
- {
- }
-
- CommandReturn Execute(User *u, const std::vector<ci::string> &params)
- {
- const char *nick = params[0].c_str();
- ci::string cmd = params[1];
-
- NickAlias *na;
-
- if (readonly)
+ else if (len > Config.PassLen)
{
- notice_lang(Config.s_NickServ, u, NICK_SASET_DISABLED);
+ notice_lang(Config.s_NickServ, u, PASSWORD_TOO_LONG);
return MOD_CONT;
}
- if (!(na = findnick(nick)))
+
+ std::string buf = params[1].c_str();
+ if (enc_encrypt(buf, nc->pass))
{
- notice_lang(Config.s_NickServ, u, NICK_SASET_BAD_NICK, nick);
+ Alog() << Config.s_NickServ << ": Failed to encrypt password for " << nc->display << " (saset)";
+ notice_lang(Config.s_NickServ, u, NICK_SASET_PASSWORD_FAILED, nc->display);
return MOD_CONT;
}
- if (na->HasFlag(NS_FORBIDDEN))
- notice_lang(Config.s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
- else if (na->nc->HasFlag(NI_SUSPENDED))
- notice_lang(Config.s_NickServ, u, NICK_X_SUSPENDED, na->nick);
- else if (cmd == "DISPLAY")
- return this->DoSetDisplay(u, params, na->nc);
- else if (cmd == "PASSWORD")
- return this->DoSetPassword(u, params, na->nc);
- else if (cmd == "URL")
- return this->DoSetUrl(u, params, na->nc);
- else if (cmd == "EMAIL")
- return this->DoSetEmail(u, params, na->nc);
- else if (cmd == "ICQ")
- return this->DoSetICQ(u, params, na->nc);
- else if (cmd == "GREET")
- return this->DoSetGreet(u, params, na->nc);
- else if (cmd == "KILL")
- return this->DoSetKill(u, params, na->nc);
- else if (cmd == "SECURE")
- return this->DoSetSecure(u, params, na->nc);
- else if (cmd == "PRIVATE")
- return this->DoSetPrivate(u, params, na->nc);
- else if (cmd == "MSG")
- return this->DoSetMsg(u, params, na->nc);
- else if (cmd == "HIDE")
- return this->DoSetHide(u, params, na->nc);
- else if (cmd == "NOEXPIRE")
- return this->DoSetNoExpire(u, params, na);
- else if (cmd == "AUTOOP")
- return this->DoSetAutoOP(u, params, na->nc);
- else if (cmd == "LANGUAGE")
- return this->DoSetLanguage(u, params, na->nc);
+ std::string tmp_pass;
+ if (enc_decrypt(nc->pass, tmp_pass) == 1)
+ notice_lang(Config.s_NickServ, u, NICK_SASET_PASSWORD_CHANGED_TO, nc->display, tmp_pass.c_str());
else
- notice_lang(Config.s_NickServ, u, NICK_SASET_UNKNOWN_OPTION, cmd.c_str());
+ notice_lang(Config.s_NickServ, u, NICK_SASET_PASSWORD_CHANGED, nc->display);
+
+ Alog() << Config.s_NickServ << ": " << u->GetMask() << " used SASET PASSWORD on " << nc->display << " (e-mail: "<< (nc->email ? nc->email : "none") << ")";
+
+ if (Config.WallSetpass)
+ ircdproto->SendGlobops(NickServ, "\2%s\2 used SASET PASSWORD on \2%s\2", u->nick.c_str(), nc->display);
+
return MOD_CONT;
}
- bool OnHelp(User *u, const ci::string &subcommand)
+ bool OnHelp(User *u, const ci::string &)
{
- if (subcommand.empty())
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET);
- else if (subcommand == "DISPLAY")
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET_DISPLAY);
- else if (subcommand == "PASSWORD")
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET_PASSWORD);
- else if (subcommand == "URL")
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET_URL);
- else if (subcommand == "EMAIL")
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET_EMAIL);
- else if (subcommand == "ICQ")
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET_ICQ);
- else if (subcommand == "GREET")
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET_GREET);
- else if (subcommand == "KILL")
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET_KILL);
- else if (subcommand == "SECURE")
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET_SECURE);
- else if (subcommand == "PRIVATE")
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET_PRIVATE);
- else if (subcommand == "MSG")
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET_MSG);
- else if (subcommand == "HIDE")
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET_HIDE);
- else if (subcommand == "NOEXPIRE")
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET_NOEXPIRE);
- else if (subcommand == "AUTOOP")
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET_AUTOOP);
- else if (subcommand == "LANGUAGE")
- notice_help(Config.s_NickServ, u, NICK_HELP_SASET_LANGUAGE);
- else
- return false;
-
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_PASSWORD);
return true;
}
- void OnSyntaxError(User *u, const ci::string &subcommand)
+ void OnSyntaxError(User *u, const ci::string &)
{
syntax_error(Config.s_NickServ, u, "SASET", NICK_SASET_SYNTAX);
}
void OnServHelp(User *u)
{
- notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET);
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET_PASSWORD);
}
};
@@ -581,7 +245,10 @@ public:
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NickServ, new CommandNSSASet());
+ Command *c = new CommandNSSASet("SASET");
+ this->AddCommand(NickServ, c);
+ c->AddSubcommand(new CommandNSSASetDisplay("DISPLAY"));
+ c->AddSubcommand(new CommandNSSASetPassword("PASSWORD"));
}
};