summaryrefslogtreecommitdiff
path: root/src/core
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
parent6cd88494662c5c4af2da891926dcc82367596cb9 (diff)
Added in a subcommand system and switched ns_set and ns_saset to use it
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ns_saset.cpp579
-rw-r--r--src/core/ns_saset_noexpire.cpp87
-rw-r--r--src/core/ns_set.cpp523
-rw-r--r--src/core/ns_set_autoop.cpp131
-rw-r--r--src/core/ns_set_email.cpp160
-rw-r--r--src/core/ns_set_greet.cpp129
-rw-r--r--src/core/ns_set_hide.cpp200
-rw-r--r--src/core/ns_set_icq.cpp136
-rw-r--r--src/core/ns_set_kill.cpp183
-rw-r--r--src/core/ns_set_language.cpp143
-rw-r--r--src/core/ns_set_message.cpp149
-rw-r--r--src/core/ns_set_private.cpp137
-rw-r--r--src/core/ns_set_secure.cpp137
-rw-r--r--src/core/ns_set_url.cpp128
14 files changed, 1952 insertions, 870 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"));
}
};
diff --git a/src/core/ns_saset_noexpire.cpp b/src/core/ns_saset_noexpire.cpp
new file mode 100644
index 000000000..a5df0bb19
--- /dev/null
+++ b/src/core/ns_saset_noexpire.cpp
@@ -0,0 +1,87 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2010 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+class CommandNSSASetNoexpire : public Command
+{
+ public:
+ CommandNSSASetNoexpire(const ci::string &cname) : Command(cname, 1, 2, "nickserv/saset/noexpire")
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ NickAlias *na = findnick(params[0]);
+ assert(na);
+
+ ci::string param = params.size() > 1 ? params[1] : "";
+
+ 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
+ this->OnSyntaxError(u, "NOEXPIRE");
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_NOEXPIRE);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SASET NOEXPIRE", NICK_SASET_NOEXPIRE_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET_NOEXPIRE);
+ }
+};
+
+class NSSASetNoexpire : public Module
+{
+ public:
+ NSSASetNoexpire(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ {
+ this->SetAuthor("Anope");
+ this->SetVersion("$Id$");
+ this->SetType(CORE);
+
+ Command *c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->AddSubcommand(new CommandNSSASetNoexpire("NOEXPIRE"));
+ }
+
+ ~NSSASetNoexpire()
+ {
+ Command *c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->DelSubcommand("NOEXPRE");
+ }
+};
+
+MODULE_INIT(NSSASetNoexpire)
diff --git a/src/core/ns_set.cpp b/src/core/ns_set.cpp
index 9cc515700..ecb1355c3 100644
--- a/src/core/ns_set.cpp
+++ b/src/core/ns_set.cpp
@@ -16,515 +16,207 @@
class CommandNSSet : public Command
{
- private:
- CommandReturn DoSetDisplay(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ std::map<ci::string, Command *> subcommands;
+ public:
+ CommandNSSet(const ci::string &cname) : Command(cname, 1, 3)
{
- ci::string param = params.size() > 1 ? params[1] : "";
-
- if (param.empty())
- {
- this->OnSyntaxError(u, "DISPLAY");
- return MOD_CONT;
- }
-
- NickAlias *na = findnick(param);
-
- if (!na || na->nc != nc)
- {
- notice_lang(Config.s_NickServ, u, NICK_SET_DISPLAY_INVALID);
- return MOD_CONT;
- }
-
- change_core_display(nc, param.c_str());
- notice_lang(Config.s_NickServ, u, NICK_SET_DISPLAY_CHANGED, nc->display);
- return MOD_CONT;
}
- CommandReturn DoSetPassword(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ ~CommandNSSet()
{
- ci::string param = params.size() > 1 ? params[1] : "";
- 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 (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) < 0)
- {
- Alog() << Config.s_NickServ << ": Failed to encrypt password for " << nc->display << " (set)";
- notice_lang(Config.s_NickServ, u, NICK_SET_PASSWORD_FAILED);
- return MOD_CONT;
- }
-
- if (enc_decrypt(nc->pass, tmp_pass) == 1)
- notice_lang(Config.s_NickServ, u, NICK_SET_PASSWORD_CHANGED_TO, tmp_pass.c_str());
- else
- notice_lang(Config.s_NickServ, u, NICK_SET_PASSWORD_CHANGED);
-
- Alog() << Config.s_NickServ << ": " << u->GetMask() << " (e-mail: " << (nc->email ? nc->email : "none") << ") changed its password.";
-
- return MOD_CONT;
+ this->subcommands.clear();
}
- CommandReturn DoSetLanguage(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() > 1 ? params[1].c_str() : NULL;
-
- if (!param)
+ if (readonly)
{
- this->OnSyntaxError(u, "LANGUAGE");
+ notice_lang(Config.s_NickServ, u, NICK_SET_DISABLED);
return MOD_CONT;
}
- int langnum;
-
- if (param[strspn(param, "0123456789")]) /* i.e. not a number */
- {
- syntax_error(Config.s_NickServ, u, "SET LANGUAGE", NICK_SET_LANGUAGE_SYNTAX);
- return MOD_CONT;
- }
- langnum = atoi(param) - 1;
- if (langnum < 0 || langnum >= NUM_LANGS || langlist[langnum] < 0)
+ if (u->Account()->HasFlag(NI_SUSPENDED))
{
- notice_lang(Config.s_NickServ, u, NICK_SET_LANGUAGE_UNKNOWN, langnum + 1, Config.s_NickServ);
+ notice_lang(Config.s_NickServ, u, NICK_X_SUSPENDED, u->Account()->display);
return MOD_CONT;
}
- nc->language = langlist[langnum];
- notice_lang(Config.s_NickServ, u, NICK_SET_LANGUAGE_CHANGED);
- return MOD_CONT;
- }
- CommandReturn DoSetUrl(User *u, const std::vector<ci::string> &params, NickCore *nc)
- {
- const char *param = params.size() > 1 ? params[1].c_str() : NULL;
-
- if (nc->url)
- delete [] nc->url;
+ Command *c = this->FindCommand(params[0]);
- if (param)
+ if (c)
{
- nc->url = sstrdup(param);
- notice_lang(Config.s_NickServ, u, NICK_SET_URL_CHANGED, param);
+ ci::string cmdparams;
+ for (std::vector<ci::string>::const_iterator it = params.begin() + 1; it != params.end(); ++it)
+ cmdparams += " " + *it;
+ if (!cmdparams.empty())
+ cmdparams.erase(cmdparams.begin());
+ mod_run_cmd(NickServ, u, c, params[0], cmdparams);
}
else
{
- nc->url = NULL;
- notice_lang(Config.s_NickServ, u, NICK_SET_URL_UNSET);
+ notice_lang(Config.s_NickServ, u, NICK_SET_UNKNOWN_OPTION, params[0].c_str());
}
+
return MOD_CONT;
}
- CommandReturn DoSetEmail(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ bool OnHelp(User *u, const ci::string &subcommand)
{
- const char *param = params.size() > 1 ? params[1].c_str() : NULL;
-
- if (!param && Config.NSForceEmail)
- {
- notice_lang(Config.s_NickServ, u, NICK_SET_EMAIL_UNSET_IMPOSSIBLE);
- return MOD_CONT;
- }
- else if (param && !MailValidate(param))
- {
- notice_lang(Config.s_NickServ, u, MAIL_X_INVALID, param);
- return MOD_CONT;
- }
-
- Alog() << Config.s_NickServ << ": " << u->GetMask() << " (e-mail: " << (nc->email ? nc->email : "none") << ") changed its e-mail to " << (param ? param : "none");
-
- if (nc->email)
- delete [] nc->email;
-
- if (param)
+ if (subcommand.empty())
{
- nc->email = sstrdup(param);
- notice_lang(Config.s_NickServ, u, NICK_SET_EMAIL_CHANGED, param);
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_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_SET_TAIL);
+ return true;
}
else
{
- nc->email = NULL;
- notice_lang(Config.s_NickServ, u, NICK_SET_EMAIL_UNSET);
- }
- return MOD_CONT;
- }
-
- CommandReturn DoSetICQ(User *u, const std::vector<ci::string> &params, NickCore *nc)
- {
- const char *param = params.size() > 1 ? params[1].c_str() : NULL;
+ Command *c = this->FindCommand(subcommand);
- if (param)
- {
- int32 tmp = atol(param);
- if (!tmp)
- notice_lang(Config.s_NickServ, u, NICK_SET_ICQ_INVALID, param);
- else
+ if (c)
{
- nc->icq = tmp;
- notice_lang(Config.s_NickServ, u, NICK_SET_ICQ_CHANGED, param);
+ return c->OnHelp(u, subcommand);
}
}
- else
- {
- nc->icq = 0;
- notice_lang(Config.s_NickServ, u, NICK_SET_ICQ_UNSET);
- }
- return MOD_CONT;
+
+ return false;
}
- CommandReturn DoSetGreet(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ void OnSyntaxError(User *u, const ci::string &subcommand)
{
- const char *param = params.size() > 1 ? params[1].c_str() : NULL;
-
- if (nc->greet)
- delete [] nc->greet;
-
- if (param)
- {
- char buf[BUFSIZE];
- const char *rest = params.size() > 2 ? params[2].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_SET_GREET_CHANGED, buf);
- }
- else
- {
- nc->greet = NULL;
- notice_lang(Config.s_NickServ, u, NICK_SET_GREET_UNSET);
- }
- return MOD_CONT;
+ syntax_error(Config.s_NickServ, u, "SET", NICK_SET_SYNTAX);
}
- CommandReturn DoSetKill(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ void OnServHelp(User *u)
{
- ci::string param = params.size() > 1 ? params[1] : "";
-
- if (param.empty())
- {
- this->OnSyntaxError(u, "KILL");
- return MOD_CONT;
- }
-
- if (param == "ON")
- {
- nc->SetFlag(NI_KILLPROTECT);
- nc->UnsetFlag(NI_KILL_QUICK);
- nc->UnsetFlag(NI_KILL_IMMED);
- notice_lang(Config.s_NickServ, u, NICK_SET_KILL_ON);
- }
- 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_SET_KILL_QUICK);
- }
- else if (param == "IMMED")
- {
- if (Config.NSAllowKillImmed)
- {
- nc->SetFlag(NI_KILLPROTECT);
- nc->SetFlag(NI_KILL_IMMED);
- nc->UnsetFlag(NI_KILL_QUICK);
- notice_lang(Config.s_NickServ, u, NICK_SET_KILL_IMMED);
- }
- else
- notice_lang(Config.s_NickServ, u, NICK_SET_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_SET_KILL_OFF);
- }
- else
- syntax_error(Config.s_NickServ, u, "SET KILL", Config.NSAllowKillImmed ? NICK_SET_KILL_IMMED_SYNTAX : NICK_SET_KILL_SYNTAX);
- return MOD_CONT;
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SET);
}
- CommandReturn DoSetSecure(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ bool AddSubcommand(Command *c)
{
- ci::string param = params.size() > 1 ? params[1] : "";
-
- if (param.empty())
- {
- this->OnSyntaxError(u, "SECURE");
- return MOD_CONT;
- }
+ return this->subcommands.insert(std::make_pair(c->name, c)).second;
+ }
- if (param == "ON")
- {
- nc->SetFlag(NI_SECURE);
- notice_lang(Config.s_NickServ, u, NICK_SET_SECURE_ON);
- }
- else if (param == "OFF")
- {
- nc->UnsetFlag(NI_SECURE);
- notice_lang(Config.s_NickServ, u, NICK_SET_SECURE_OFF);
- }
- else
- syntax_error(Config.s_NickServ, u, "SET SECURE", NICK_SET_SECURE_SYNTAX);
- return MOD_CONT;
+ bool DelSubcommand(const ci::string &command)
+ {
+ return this->subcommands.erase(command);
}
- CommandReturn DoSetPrivate(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ Command *FindCommand(const ci::string &subcommand)
{
- ci::string param = params.size() > 1 ? params[1] : "";
+ std::map<ci::string, Command *>::const_iterator it = this->subcommands.find(subcommand);
- if (param.empty())
+ if (it != this->subcommands.end())
{
- this->OnSyntaxError(u, "PRIVATE");
- return MOD_CONT;
+ return it->second;
}
- if (param == "ON")
- {
- nc->SetFlag(NI_PRIVATE);
- notice_lang(Config.s_NickServ, u, NICK_SET_PRIVATE_ON);
- }
- else if (param == "OFF")
- {
- nc->UnsetFlag(NI_PRIVATE);
- notice_lang(Config.s_NickServ, u, NICK_SET_PRIVATE_OFF);
- }
- else
- syntax_error(Config.s_NickServ, u, "SET PRIVATE", NICK_SET_PRIVATE_SYNTAX);
- return MOD_CONT;
+ return NULL;
}
+};
- CommandReturn DoSetMsg(User *u, const std::vector<ci::string> &params, NickCore *nc)
+class CommandNSSetDisplay : public Command
+{
+ public:
+ CommandNSSetDisplay(const ci::string &cname) : Command(cname, 1)
{
- ci::string param = params.size() > 1 ? params[1] : "";
+ }
- if (param.empty())
- {
- this->OnSyntaxError(u, "MSG");
- return MOD_CONT;
- }
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ NickAlias *na = findnick(params[0]);
- if (!Config.UsePrivmsg)
+ if (!na || na->nc != u->Account())
{
- notice_lang(Config.s_NickServ, u, NICK_SET_OPTION_DISABLED, "MSG");
+ notice_lang(Config.s_NickServ, u, NICK_SET_DISPLAY_INVALID);
return MOD_CONT;
}
- if (param == "ON")
- {
- nc->SetFlag(NI_MSG);
- notice_lang(Config.s_NickServ, u, NICK_SET_MSG_ON);
- }
- else if (param == "OFF")
- {
- nc->UnsetFlag(NI_MSG);
- notice_lang(Config.s_NickServ, u, NICK_SET_MSG_OFF);
- }
- else
- syntax_error(Config.s_NickServ, u, "SET MSG", NICK_SET_MSG_SYNTAX);
+ change_core_display(u->Account(), params[0].c_str());
+ notice_lang(Config.s_NickServ, u, NICK_SET_DISPLAY_CHANGED, u->Account()->display);
return MOD_CONT;
}
- CommandReturn DoSetHide(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ bool OnHelp(User *u, const ci::string &)
{
- ci::string param = params.size() > 1 ? params[1] : "";
-
- if (param.empty())
- {
- this->OnSyntaxError(u, "HIDE");
- return MOD_CONT;
- }
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_DISPLAY);
+ return true;
+ }
- int onmsg, offmsg;
- NickCoreFlag flag;
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ // XXX
+ syntax_error(Config.s_NickServ, u, "SET", NICK_SET_SYNTAX);
+ }
- if (param == "EMAIL")
- {
- flag = NI_HIDE_EMAIL;
- onmsg = NICK_SET_HIDE_EMAIL_ON;
- offmsg = NICK_SET_HIDE_EMAIL_OFF;
- }
- else if (param == "USERMASK")
- {
- flag = NI_HIDE_MASK;
- onmsg = NICK_SET_HIDE_MASK_ON;
- offmsg = NICK_SET_HIDE_MASK_OFF;
- }
- else if (param == "STATUS")
- {
- flag = NI_HIDE_STATUS;
- onmsg = NICK_SET_HIDE_STATUS_ON;
- offmsg = NICK_SET_HIDE_STATUS_OFF;
- }
- else if (param == "QUIT")
- {
- flag = NI_HIDE_QUIT;
- onmsg = NICK_SET_HIDE_QUIT_ON;
- offmsg = NICK_SET_HIDE_QUIT_OFF;
- }
- else
- {
- syntax_error(Config.s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX);
- return MOD_CONT;
- }
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SET_DISPLAY);
+ }
+};
- param = params.size() > 2 ? params[2] : "";
- if (param.empty())
- syntax_error(Config.s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX);
- else if (param == "ON")
- {
- nc->SetFlag(flag);
- notice_lang(Config.s_NickServ, u, onmsg, Config.s_NickServ);
- }
- else if (param == "OFF")
- {
- nc->UnsetFlag(flag);
- notice_lang(Config.s_NickServ, u, offmsg, Config.s_NickServ);
- }
- else
- syntax_error(Config.s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX);
- return MOD_CONT;
+class CommandNSSetPassword : public Command
+{
+ public:
+ CommandNSSetPassword(const ci::string &cname) : Command(cname, 1)
+ {
}
- CommandReturn DoSetAutoOP(User *u, const std::vector<ci::string> &params, NickCore *nc)
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
{
- ci::string param = params.size() > 1 ? params[1] : "";
+ ci::string param = params[0];
- if (param.empty())
- {
- this->OnSyntaxError(u, "AUTOOP");
- return MOD_CONT;
- }
+ int len = param.size();
- /**
- * This works the other way around, the absence of this flag denotes ON
- * This is so when people upgrade, and dont have the flag
- * the default is on
- **/
- if (param == "ON")
+ if (u->Account()->display == param || (Config.StrictPasswords && len < 5))
{
- nc->SetFlag(NI_AUTOOP);
- notice_lang(Config.s_NickServ, u, NICK_SET_AUTOOP_ON);
+ notice_lang(Config.s_NickServ, u, MORE_OBSCURE_PASSWORD);
+ return MOD_CONT;
}
- else if (param == "OFF")
+ else if (len > Config.PassLen)
{
- nc->UnsetFlag(NI_AUTOOP);
- notice_lang(Config.s_NickServ, u, NICK_SET_AUTOOP_OFF);
+ notice_lang(Config.s_NickServ, u, PASSWORD_TOO_LONG);
+ return MOD_CONT;
}
- else
- syntax_error(Config.s_NickServ, u, "SET AUTOOP", NICK_SET_AUTOOP_SYNTAX);
- return MOD_CONT;
- }
- public:
- CommandNSSet() : Command("SET", 1, 3)
- {
- }
-
- CommandReturn Execute(User *u, const std::vector<ci::string> &params)
- {
- ci::string cmd = params[0];
-
- if (readonly)
+ std::string buf = param.c_str(); /* conversion from ci::string to std::string */
+ if (enc_encrypt(buf, u->Account()->pass) < 0)
{
- notice_lang(Config.s_NickServ, u, NICK_SET_DISABLED);
+ Alog() << Config.s_NickServ << ": Failed to encrypt password for " << u->Account()->display << " (set)";
+ notice_lang(Config.s_NickServ, u, NICK_SET_PASSWORD_FAILED);
return MOD_CONT;
}
-/*
- if (na->HasFlag(NS_FORBIDDEN))
- notice_lang(Config.s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
-*/
- if (u->Account()->HasFlag(NI_SUSPENDED))
- notice_lang(Config.s_NickServ, u, NICK_X_SUSPENDED, u->Account()->display);
- else if (cmd == "DISPLAY")
- return this->DoSetDisplay(u, params, u->Account());
- else if (cmd == "PASSWORD")
- return this->DoSetPassword(u, params, u->Account());
- else if (cmd == "LANGUAGE")
- return this->DoSetLanguage(u, params, u->Account());
- else if (cmd == "URL")
- return this->DoSetUrl(u, params, u->Account());
- else if (cmd == "EMAIL")
- return this->DoSetEmail(u, params, u->Account());
- else if (cmd == "ICQ")
- return this->DoSetICQ(u, params, u->Account());
- else if (cmd == "GREET")
- return this->DoSetGreet(u, params, u->Account());
- else if (cmd == "KILL")
- return this->DoSetKill(u, params, u->Account());
- else if (cmd == "SECURE")
- return this->DoSetSecure(u, params, u->Account());
- else if (cmd == "PRIVATE")
- return this->DoSetPrivate(u, params, u->Account());
- else if (cmd == "MSG")
- return this->DoSetMsg(u, params, u->Account());
- else if (cmd == "HIDE")
- return this->DoSetHide(u, params, u->Account());
- else if (cmd == "AUTOOP")
- return this->DoSetAutoOP(u, params, u->Account());
+ std::string tmp_pass;
+ if (enc_decrypt(u->Account()->pass, tmp_pass) == 1)
+ notice_lang(Config.s_NickServ, u, NICK_SET_PASSWORD_CHANGED_TO, tmp_pass.c_str());
else
- notice_lang(Config.s_NickServ, u, NICK_SET_UNKNOWN_OPTION, cmd.c_str());
+ notice_lang(Config.s_NickServ, u, NICK_SET_PASSWORD_CHANGED);
+
+ Alog() << Config.s_NickServ << ": " << u->GetMask() << " (e-mail: " << (u->Account()->email ? u->Account()->email : "none") << ") changed its password.";
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_SET);
- else if (subcommand == "DISPLAY")
- notice_help(Config.s_NickServ, u, NICK_HELP_SET_DISPLAY);
- else if (subcommand == "PASSWORD")
- notice_help(Config.s_NickServ, u, NICK_HELP_SET_PASSWORD);
- else if (subcommand == "URL")
- notice_help(Config.s_NickServ, u, NICK_HELP_SET_URL);
- else if (subcommand == "EMAIL")
- notice_help(Config.s_NickServ, u, NICK_HELP_SET_EMAIL);
- else if (subcommand == "ICQ")
- notice_help(Config.s_NickServ, u, NICK_HELP_SET_ICQ);
- else if (subcommand == "GREET")
- notice_help(Config.s_NickServ, u, NICK_HELP_SET_GREET);
- else if (subcommand == "KILL")
- notice_help(Config.s_NickServ, u, NICK_HELP_SET_KILL);
- else if (subcommand == "SECURE")
- notice_help(Config.s_NickServ, u, NICK_HELP_SET_SECURE);
- else if (subcommand == "PRIVATE")
- notice_help(Config.s_NickServ, u, NICK_HELP_SET_PRIVATE);
- else if (subcommand == "MSG")
- notice_help(Config.s_NickServ, u, NICK_HELP_SET_MSG);
- else if (subcommand == "HIDE")
- notice_help(Config.s_NickServ, u, NICK_HELP_SET_HIDE);
- else if (subcommand == "AUTOOP")
- notice_help(Config.s_NickServ, u, NICK_HELP_SET_AUTOOP);
- else
- return false;
-
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_PASSWORD);
return true;
}
- void OnSyntaxError(User *u, const ci::string &subcommand)
+ void OnSyntaxError(User *u, const ci::string &)
{
+ // XXX
syntax_error(Config.s_NickServ, u, "SET", NICK_SET_SYNTAX);
}
void OnServHelp(User *u)
{
- notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SET);
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SET_PASSWORD);
}
};
@@ -537,7 +229,10 @@ class NSSet : public Module
this->SetVersion(VERSION_STRING);
this->SetType(CORE);
- this->AddCommand(NickServ, new CommandNSSet());
+ Command *set = new CommandNSSet("SET");
+ this->AddCommand(NickServ, set);
+ set->AddSubcommand(new CommandNSSetDisplay("DISPLAY"));
+ set->AddSubcommand(new CommandNSSetPassword("PASSWORD"));
}
};
diff --git a/src/core/ns_set_autoop.cpp b/src/core/ns_set_autoop.cpp
new file mode 100644
index 000000000..d1c0d0d81
--- /dev/null
+++ b/src/core/ns_set_autoop.cpp
@@ -0,0 +1,131 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2010 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+class CommandNSSetAutoOp : public Command
+{
+ public:
+ CommandNSSetAutoOp(const ci::string &cname) : Command(cname, 2)
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ if (params[0] == "ON")
+ {
+ u->Account()->SetFlag(NI_AUTOOP);
+ notice_lang(Config.s_NickServ, u, NICK_SET_AUTOOP_ON);
+ }
+ else if (params[0] == "OFF")
+ {
+ u->Account()->UnsetFlag(NI_AUTOOP);
+ notice_lang(Config.s_NickServ, u, NICK_SET_AUTOOP_OFF);
+ }
+ else
+ this->OnSyntaxError(u, "AUTOOP");
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_AUTOOP);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SET AUTOOP", NICK_SET_AUTOOP_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SET_AUTOOP);
+ }
+};
+
+class CommandNSSASetAutoOp : public Command
+{
+ public:
+ CommandNSSASetAutoOp(const ci::string &cname) : Command(cname, 2, 2, "nickserv/saset/autoop")
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ NickCore *nc = findcore(params[0]);
+ assert(nc);
+
+ ci::string param = params[1];
+
+ 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
+ this->OnSyntaxError(u, "AUTOOP");
+
+ return MOD_CONT;
+ }
+
+ bool Help(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_AUTOOP);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SET AUTOOP", NICK_SASET_AUTOOP_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET_AUTOOP);
+ }
+};
+
+class NSSetAutoOp : public Module
+{
+ public:
+ NSSetAutoOp(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ {
+ this->SetAuthor("Anope");
+ this->SetVersion("$Id$");
+ this->SetType(CORE);
+
+ Command *set = FindCommand(NickServ, "SET");
+
+ if (set)
+ set->AddSubcommand(new CommandNSSetAutoOp("AUTOOP"));
+ }
+
+ ~NSSetAutoOp()
+ {
+ Command *set = FindCommand(NickServ, "SET");
+
+ if (set)
+ set->DelSubcommand("AUTOOP");
+ }
+};
+
+MODULE_INIT(NSSetAutoOp)
diff --git a/src/core/ns_set_email.cpp b/src/core/ns_set_email.cpp
new file mode 100644
index 000000000..ec1b78c83
--- /dev/null
+++ b/src/core/ns_set_email.cpp
@@ -0,0 +1,160 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2010 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+class CommandNSSetEmail : public Command
+{
+ public:
+ CommandNSSetEmail(const ci::string &cname) : Command(cname, 0)
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ if (params.empty() && Config.NSForceEmail)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_SET_EMAIL_UNSET_IMPOSSIBLE);
+ return MOD_CONT;
+ }
+ else if (!params.empty() && !MailValidate(params[0].c_str()))
+ {
+ notice_lang(Config.s_NickServ, u, MAIL_X_INVALID, params[0].c_str());
+ return MOD_CONT;
+ }
+
+ Alog() << Config.s_NickServ << ": " << u->GetMask() << " (e-mail: " << (u->Account()->email ? u->Account()->email : "none") << ") changed its e-mail to " << (!params.empty() ? params[0] : "none");
+
+ if (u->Account()->email)
+ delete [] u->Account()->email;
+
+ if (!params.empty())
+ {
+ u->Account()->email = sstrdup(params[0].c_str());
+ notice_lang(Config.s_NickServ, u, NICK_SET_EMAIL_CHANGED, params[0].c_str());
+ }
+ else
+ {
+ u->Account()->email = NULL;
+ notice_lang(Config.s_NickServ, u, NICK_SET_EMAIL_UNSET);
+ }
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_EMAIL);
+ return true;
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SET_EMAIL);
+ }
+};
+
+class CommandNSSASetEmail : public Command
+{
+ public:
+ CommandNSSASetEmail(const ci::string &cname) : Command(cname, 1, 2, "nickserv/saset/email")
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ NickCore *nc = findcore(params[0]);
+ assert(nc);
+
+ const char *param = params.size() > 1 ? params[1].c_str() : NULL;
+
+ 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))
+ {
+ notice_lang(Config.s_NickServ, u, MAIL_X_INVALID, param);
+ 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);
+ }
+ else
+ {
+ nc->email = NULL;
+ notice_lang(Config.s_NickServ, u, NICK_SASET_EMAIL_UNSET, nc->display);
+ }
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_EMAIL);
+ return true;
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET_EMAIL);
+ }
+};
+
+class NSSetEmail : public Module
+{
+ public:
+ NSSetEmail(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ {
+ this->SetAuthor("Anope");
+ this->SetVersion("$Id$");
+ this->SetType(CORE);
+
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->AddSubcommand(new CommandNSSetEmail("EMAIL"));
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->AddSubcommand(new CommandNSSASetEmail("EMAIL"));
+ }
+
+ ~NSSetEmail()
+ {
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->DelSubcommand("EMAIL");
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->DelSubcommand("EMAIL");
+ }
+};
+
+MODULE_INIT(NSSetEmail)
diff --git a/src/core/ns_set_greet.cpp b/src/core/ns_set_greet.cpp
new file mode 100644
index 000000000..0a1e94547
--- /dev/null
+++ b/src/core/ns_set_greet.cpp
@@ -0,0 +1,129 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2010 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+class CommandNSSetGreet : public Command
+{
+ public:
+ CommandNSSetGreet(const ci::string &cname) : Command(cname, 0)
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ if (u->Account()->greet)
+ delete [] u->Account()->greet;
+
+ if (!params.empty())
+ {
+ u->Account()->greet = sstrdup(params[0].c_str());
+ notice_lang(Config.s_NickServ, u, NICK_SET_GREET_CHANGED, u->Account()->greet);
+ }
+ else
+ {
+ u->Account()->greet = NULL;
+ notice_lang(Config.s_NickServ, u, NICK_SET_GREET_UNSET);
+ }
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_GREET);
+ return true;
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SET_GREET);
+ }
+};
+
+class CommandNSSASetGreet : public Command
+{
+ public:
+ CommandNSSASetGreet(const ci::string &cname) : Command(cname, 1, 2, "nickserv/saset/greet")
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ NickCore *nc = findcore(params[0]);
+ assert(nc);
+
+ const char *param = params.size() > 1 ? params[1].c_str() : NULL;
+
+ if (nc->greet)
+ delete [] nc->greet;
+
+ if (param)
+ {
+ nc->greet = sstrdup(param);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_GREET_CHANGED, nc->display, nc->greet);
+ }
+ else
+ {
+ nc->greet = NULL;
+ notice_lang(Config.s_NickServ, u, NICK_SASET_GREET_UNSET, nc->display);
+ }
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_GREET);
+ return true;
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET_GREET);
+ }
+};
+
+class NSSetGreet : public Module
+{
+ public:
+ NSSetGreet(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ {
+ this->SetAuthor("Anope");
+ this->SetVersion("$Id$");
+ this->SetType(CORE);
+
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->AddSubcommand(new CommandNSSetGreet("GREET"));
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->AddSubcommand(new CommandNSSASetGreet("GREET"));
+ }
+
+ ~NSSetGreet()
+ {
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->DelSubcommand("GREET");
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->DelSubcommand("GREET");
+ }
+};
+
+MODULE_INIT(NSSetGreet)
diff --git a/src/core/ns_set_hide.cpp b/src/core/ns_set_hide.cpp
new file mode 100644
index 000000000..e17fac21f
--- /dev/null
+++ b/src/core/ns_set_hide.cpp
@@ -0,0 +1,200 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2010 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+class CommandNSSetHide : public Command
+{
+ public:
+ CommandNSSetHide(const ci::string &cname) : Command(cname, 2)
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ int onmsg, offmsg;
+ NickCoreFlag flag;
+
+ if (params[0] == "EMAIL")
+ {
+ flag = NI_HIDE_EMAIL;
+ onmsg = NICK_SET_HIDE_EMAIL_ON;
+ offmsg = NICK_SET_HIDE_EMAIL_OFF;
+ }
+ else if (params[0] == "USERMASK")
+ {
+ flag = NI_HIDE_MASK;
+ onmsg = NICK_SET_HIDE_MASK_ON;
+ offmsg = NICK_SET_HIDE_MASK_OFF;
+ }
+ else if (params[0] == "STATUS")
+ {
+ flag = NI_HIDE_STATUS;
+ onmsg = NICK_SET_HIDE_STATUS_ON;
+ offmsg = NICK_SET_HIDE_STATUS_OFF;
+ }
+ else if (params[0] == "QUIT")
+ {
+ flag = NI_HIDE_QUIT;
+ onmsg = NICK_SET_HIDE_QUIT_ON;
+ offmsg = NICK_SET_HIDE_QUIT_OFF;
+ }
+ else
+ {
+ this->OnSyntaxError(u, "HIDE");
+ return MOD_CONT;
+ }
+
+ if (params[1] == "ON")
+ {
+ u->Account()->SetFlag(flag);
+ notice_lang(Config.s_NickServ, u, onmsg, Config.s_NickServ);
+ }
+ else if (params[1] == "OFF")
+ {
+ u->Account()->UnsetFlag(flag);
+ notice_lang(Config.s_NickServ, u, offmsg, Config.s_NickServ);
+ }
+ else
+ this->OnSyntaxError(u, "HIDE");
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_HIDE);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SET_HIDE);
+ }
+};
+
+class CommandNSSASetHide : public Command
+{
+ public:
+ CommandNSSASetHide(const ci::string &cname) : Command(cname, 3, 3, "nickserv/saset/command")
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ NickCore *nc = findcore(params[0]);
+ assert(nc);
+
+ ci::string param = params[1];
+
+ 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
+ {
+ this->OnSyntaxError(u, "HIDE");
+ return MOD_CONT;
+ }
+
+ param = params[2];
+ if (param.empty())
+ this->OnSyntaxError(u, "HIDE");
+ 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
+ this->OnSyntaxError(u, "HIDE");
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_HIDE);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SASET HIDE", NICK_SASET_HIDE_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET_HIDE);
+ }
+};
+
+class NSSetHide : public Module
+{
+ public:
+ NSSetHide(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ {
+ this->SetAuthor("Anope");
+ this->SetVersion("$Id$");
+ this->SetType(CORE);
+
+ Command *set = FindCommand(NickServ, "SET");
+
+ if (set)
+ set->AddSubcommand(new CommandNSSetHide("HIDE"));
+ }
+
+ ~NSSetHide()
+ {
+ Command *set = FindCommand(NickServ, "SET");
+
+ if (set)
+ set->DelSubcommand("HIDE");
+ }
+};
+
+MODULE_INIT(NSSetHide)
diff --git a/src/core/ns_set_icq.cpp b/src/core/ns_set_icq.cpp
new file mode 100644
index 000000000..a00810bac
--- /dev/null
+++ b/src/core/ns_set_icq.cpp
@@ -0,0 +1,136 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2010 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+class CommandNSSetICQ : public Command
+{
+ public:
+ CommandNSSetICQ(const ci::string &cname) : Command(cname, 0)
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ if (!params.empty())
+ {
+ int32 tmp = atol(params[0].c_str());
+ if (!tmp)
+ notice_lang(Config.s_NickServ, u, NICK_SET_ICQ_INVALID, params[0].c_str());
+ else
+ {
+ u->Account()->icq = tmp;
+ notice_lang(Config.s_NickServ, u, NICK_SET_ICQ_CHANGED, params[0].c_str());
+ }
+ }
+ else
+ {
+ u->Account()->icq = 0;
+ notice_lang(Config.s_NickServ, u, NICK_SET_ICQ_UNSET);
+ }
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_ICQ);
+ return true;
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SET_ICQ);
+ }
+};
+
+class CommandNSSASetICQ : public Command
+{
+ public:
+ CommandNSSASetICQ(const ci::string &cname) : Command(cname, 1, 2, "nickserv/saset/icq")
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ NickCore *nc = findcore(params[0]);
+ assert(nc);
+
+ const char *param = params.size() > 1 ? params[1].c_str() : NULL;
+
+ if (param)
+ {
+ int32 tmp = atol(param);
+
+ if (tmp)
+ notice_lang(Config.s_NickServ, u, NICK_SASET_ICQ_INVALID, param);
+ else
+ {
+ nc->icq = tmp;
+ notice_lang(Config.s_NickServ, u, NICK_SASET_ICQ_CHANGED, nc->display, param);
+ }
+ }
+ else
+ {
+ nc->icq = 0;
+ notice_lang(Config.s_NickServ, u, NICK_SASET_ICQ_UNSET, nc->display);
+ }
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_ICQ);
+ return true;
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET_ICQ);
+ }
+};
+
+class NSSetICQ : public Module
+{
+ public:
+ NSSetICQ(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ {
+ this->SetAuthor("Anope");
+ this->SetVersion("$Id$");
+ this->SetType(CORE);
+
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->AddSubcommand(new CommandNSSetICQ("ICQ"));
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->AddSubcommand(new CommandNSSASetICQ("ICQ"));
+ }
+
+ ~NSSetICQ()
+ {
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->DelSubcommand("ICQ");
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->DelSubcommand("ICQ");
+ }
+};
+
+MODULE_INIT(NSSetICQ)
diff --git a/src/core/ns_set_kill.cpp b/src/core/ns_set_kill.cpp
new file mode 100644
index 000000000..d9d6caa7c
--- /dev/null
+++ b/src/core/ns_set_kill.cpp
@@ -0,0 +1,183 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2010 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+class CommandNSSetKill : public Command
+{
+ public:
+ CommandNSSetKill(const ci::string &cname) : Command(cname, 1)
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ if (params[0] == "ON")
+ {
+ u->Account()->SetFlag(NI_KILLPROTECT);
+ u->Account()->UnsetFlag(NI_KILL_QUICK);
+ u->Account()->UnsetFlag(NI_KILL_IMMED);
+ notice_lang(Config.s_NickServ, u, NICK_SET_KILL_ON);
+ }
+ else if (params[0] == "QUICK")
+ {
+ u->Account()->SetFlag(NI_KILLPROTECT);
+ u->Account()->SetFlag(NI_KILL_QUICK);
+ u->Account()->UnsetFlag(NI_KILL_IMMED);
+ notice_lang(Config.s_NickServ, u, NICK_SET_KILL_QUICK);
+ }
+ else if (params[0] == "IMMED")
+ {
+ if (Config.NSAllowKillImmed)
+ {
+ u->Account()->SetFlag(NI_KILLPROTECT);
+ u->Account()->SetFlag(NI_KILL_IMMED);
+ u->Account()->UnsetFlag(NI_KILL_QUICK);
+ notice_lang(Config.s_NickServ, u, NICK_SET_KILL_IMMED);
+ }
+ else
+ notice_lang(Config.s_NickServ, u, NICK_SET_KILL_IMMED_DISABLED);
+ }
+ else if (params[0] == "OFF")
+ {
+ u->Account()->UnsetFlag(NI_KILLPROTECT);
+ u->Account()->UnsetFlag(NI_KILL_QUICK);
+ u->Account()->UnsetFlag(NI_KILL_IMMED);
+ notice_lang(Config.s_NickServ, u, NICK_SET_KILL_OFF);
+ }
+ else
+ this->OnSyntaxError(u, "KILL");
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_KILL);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SET KILL", Config.NSAllowKillImmed ? NICK_SET_KILL_IMMED_SYNTAX : NICK_SET_KILL_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SET_KILL);
+ }
+};
+
+class CommandNSSASetKill : public Command
+{
+ public:
+ CommandNSSASetKill(const ci::string &cname) : Command(cname, 2, 2, "nickserv/saset/kill")
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ NickCore *nc = findcore(params[0]);
+ assert(nc);
+
+ ci::string param = params[1];
+
+ 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)
+ {
+ 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);
+ }
+ 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
+ this->OnSyntaxError(u, "KILL");
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_KILL);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SASET KILL", Config.NSAllowKillImmed ? NICK_SASET_KILL_IMMED_SYNTAX : NICK_SASET_KILL_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET_KILL);
+ }
+};
+
+class NSSetKill : public Module
+{
+ public:
+ NSSetKill(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ {
+ this->SetAuthor("Anope");
+ this->SetVersion("$Id$");
+ this->SetType(CORE);
+
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->AddSubcommand(new CommandNSSetKill("KILL"));
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->AddSubcommand(new CommandNSSASetKill("KILL"));
+ }
+
+ ~NSSetKill()
+ {
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->DelSubcommand("KILL");
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->DelSubcommand("KILL");
+ }
+};
+
+MODULE_INIT(NSSetKill)
diff --git a/src/core/ns_set_language.cpp b/src/core/ns_set_language.cpp
new file mode 100644
index 000000000..a175f91a7
--- /dev/null
+++ b/src/core/ns_set_language.cpp
@@ -0,0 +1,143 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2010 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+class CommandNSSetLanguage : public Command
+{
+ public:
+ CommandNSSetLanguage(const ci::string &cname) : Command(cname, 1)
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ const char *param = params[0].c_str();
+
+ if (param[strspn(param, "0123456789")]) /* i.e. not a number */
+ {
+ this->OnSyntaxError(u, "");
+ return MOD_CONT;
+ }
+
+ int langnum = atoi(param) - 1;
+ if (langnum < 0 || langnum >= NUM_LANGS || langlist[langnum] < 0)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_SET_LANGUAGE_UNKNOWN, langnum + 1, Config.s_NickServ);
+ return MOD_CONT;
+ }
+
+ u->Account()->language = langlist[langnum];
+ notice_lang(Config.s_NickServ, u, NICK_SET_LANGUAGE_CHANGED);
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_LANGUAGE);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SET LANGUAGE", NICK_SET_LANGUAGE_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SET_LANGUAGE);
+ }
+};
+
+class CommandNSSASetLanguage : public Command
+{
+ public:
+ CommandNSSASetLanguage(const ci::string &cname) : Command(cname, 2, 2, "nickserv/saset/language")
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ NickCore *nc = findcore(params[0]);
+ assert(nc);
+
+ const char *param = params[1].c_str();
+
+ if (param[strspn(param, "0123456789")]) /* i.e. not a number */
+ {
+ this->OnSyntaxError(u, "LANGUAGE");
+ return MOD_CONT;
+ }
+ int langnum = atoi(param) - 1;
+ if (langnum < 0 || langnum >= NUM_LANGS || langlist[langnum] < 0)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_SASET_LANGUAGE_UNKNOWN, langnum + 1, Config.s_NickServ);
+ return MOD_CONT;
+ }
+ nc->language = langlist[langnum];
+ notice_lang(Config.s_NickServ, u, NICK_SASET_LANGUAGE_CHANGED);
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_LANGUAGE);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SASET LANGUAGE", NICK_SASET_LANGUAGE_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET_LANGUAGE);
+ }
+};
+
+class NSSetLanguage : public Module
+{
+ public:
+ NSSetLanguage(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ {
+ this->SetAuthor("Anope");
+ this->SetVersion("$Id$");
+ this->SetType(CORE);
+
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->AddSubcommand(new CommandNSSetLanguage("LANGUAGE"));
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->AddSubcommand(new CommandNSSASetLanguage("LANGUAGE"));
+ }
+
+ ~NSSetLanguage()
+ {
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->DelSubcommand("LANGUAGE");
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->DelSubcommand("LANGUAGE");
+ }
+};
+
+MODULE_INIT(NSSetLanguage)
diff --git a/src/core/ns_set_message.cpp b/src/core/ns_set_message.cpp
new file mode 100644
index 000000000..89f3cca0a
--- /dev/null
+++ b/src/core/ns_set_message.cpp
@@ -0,0 +1,149 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2010 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+class CommandNSSetMessage : public Command
+{
+ public:
+ CommandNSSetMessage(const ci::string &cname) : Command(cname, 1)
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ if (!Config.UsePrivmsg)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_SET_OPTION_DISABLED, "MSG");
+ return MOD_CONT;
+ }
+
+ if (params[0] == "ON")
+ {
+ u->Account()->SetFlag(NI_MSG);
+ notice_lang(Config.s_NickServ, u, NICK_SET_MSG_ON);
+ }
+ else if (params[0] == "OFF")
+ {
+ u->Account()->UnsetFlag(NI_MSG);
+ notice_lang(Config.s_NickServ, u, NICK_SET_MSG_OFF);
+ }
+ else
+ this->OnSyntaxError(u, "MSG");
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_MSG);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SET MSG", NICK_SET_MSG_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SET_MSG);
+ }
+};
+
+class CommandNSSASetMessage : public Command
+{
+ public:
+ CommandNSSASetMessage(const ci::string &cname) : Command(cname, 2, 2, "nickserv/saset/message")
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ NickCore *nc = findcore(params[0]);
+ assert(nc);
+
+ ci::string param = params[1];
+
+ if (!Config.UsePrivmsg)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_SASET_OPTION_DISABLED, "MSG");
+ return MOD_CONT;
+ }
+
+ 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
+ this->OnSyntaxError(u, "MSG");
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_MSG);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SASET MSG", NICK_SASET_MSG_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET_MSG);
+ }
+};
+
+class NSSetMessage : public Module
+{
+ public:
+ NSSetMessage(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ {
+ this->SetAuthor("Anope");
+ this->SetVersion("$Id$");
+ this->SetType(CORE);
+
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->AddSubcommand(new CommandNSSetMessage("MSG"));
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->AddSubcommand(new CommandNSSASetMessage("MSG"));
+ }
+
+ ~NSSetMessage()
+ {
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->DelSubcommand("MSG");
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->DelSubcommand("MSG");
+ }
+};
+
+MODULE_INIT(NSSetMessage)
diff --git a/src/core/ns_set_private.cpp b/src/core/ns_set_private.cpp
new file mode 100644
index 000000000..661287929
--- /dev/null
+++ b/src/core/ns_set_private.cpp
@@ -0,0 +1,137 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2010 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+class CommandNSSetPrivate : public Command
+{
+ public:
+ CommandNSSetPrivate(const ci::string &cname) : Command(cname, 1)
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ if (params[0] == "ON")
+ {
+ u->Account()->SetFlag(NI_PRIVATE);
+ notice_lang(Config.s_NickServ, u, NICK_SET_PRIVATE_ON);
+ }
+ else if (params[0] == "OFF")
+ {
+ u->Account()->UnsetFlag(NI_PRIVATE);
+ notice_lang(Config.s_NickServ, u, NICK_SET_PRIVATE_OFF);
+ }
+ else
+ this->OnSyntaxError(u, "PRIVATE");
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_PRIVATE);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SET PRIVATE", NICK_SET_PRIVATE_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_CMD_SET_PRIVATE);
+ }
+};
+
+class CommandNSSASetPrivate : public Command
+{
+ public:
+ CommandNSSASetPrivate(const ci::string &cname) : Command(cname, 2, 2, "nickserv/saset/private")
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ NickCore *nc = findcore(params[0]);
+ assert(nc);
+
+ ci::string param = params[1];
+
+ 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
+ this->OnSyntaxError(u, "PRIVATE");
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_PRIVATE);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SASET PRIVATE", NICK_SASET_PRIVATE_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_CMD_SASET_PRIVATE);
+ }
+};
+
+class NSSetPrivate : public Module
+{
+ public:
+ NSSetPrivate(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ {
+ this->SetAuthor("Anope");
+ this->SetVersion("$Id$");
+ this->SetType(CORE);
+
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->AddSubcommand(new CommandNSSetPrivate("PRIVATE"));
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->AddSubcommand(new CommandNSSASetPrivate("PRIVATE"));
+ }
+
+ ~NSSetPrivate()
+ {
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->DelSubcommand("PRIVATE");
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->DelSubcommand("PRIVATE");
+ }
+};
+
+MODULE_INIT(NSSetPrivate)
diff --git a/src/core/ns_set_secure.cpp b/src/core/ns_set_secure.cpp
new file mode 100644
index 000000000..a452a31f3
--- /dev/null
+++ b/src/core/ns_set_secure.cpp
@@ -0,0 +1,137 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2010 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+class CommandNSSetSecure : public Command
+{
+ public:
+ CommandNSSetSecure(const ci::string &cname) : Command(cname, 1)
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ if (params[0] == "ON")
+ {
+ u->Account()->SetFlag(NI_SECURE);
+ notice_lang(Config.s_NickServ, u, NICK_SET_SECURE_ON);
+ }
+ else if (params[0] == "OFF")
+ {
+ u->Account()->UnsetFlag(NI_SECURE);
+ notice_lang(Config.s_NickServ, u, NICK_SET_SECURE_OFF);
+ }
+ else
+ this->OnSyntaxError(u, "SECURE");
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_SECURE);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SET SECURE", NICK_SET_SECURE_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SET_SECURE);
+ }
+};
+
+class CommandNSSASetSecure : public Command
+{
+ public:
+ CommandNSSASetSecure(const ci::string &cname) : Command(cname, 2, 2, "nickserv/saset/secure")
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ NickCore *nc = findcore(params[0]);
+ assert(nc);
+
+ ci::string param = params[1];
+
+ 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
+ this->OnSyntaxError(u, "SECURE");
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_SECURE);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const ci::string &)
+ {
+ syntax_error(Config.s_NickServ, u, "SASET SECURE", NICK_SASET_SECURE_SYNTAX);
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET_SECURE);
+ }
+};
+
+class NSSetSecure : public Module
+{
+ public:
+ NSSetSecure(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ {
+ this->SetAuthor("Anope");
+ this->SetVersion("$Id$");
+ this->SetType(CORE);
+
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->AddSubcommand(new CommandNSSetSecure("SECURE"));
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->AddSubcommand(new CommandNSSASetSecure("SECURE"));
+ }
+
+ ~NSSetSecure()
+ {
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->DelSubcommand("SECURE");
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->DelSubcommand("SECURE");
+ }
+};
+
+MODULE_INIT(NSSetSecure)
diff --git a/src/core/ns_set_url.cpp b/src/core/ns_set_url.cpp
new file mode 100644
index 000000000..5ef83d32e
--- /dev/null
+++ b/src/core/ns_set_url.cpp
@@ -0,0 +1,128 @@
+/* NickServ core functions
+ *
+ * (C) 2003-2010 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+class CommandNSSetURL : public Command
+{
+ public:
+ CommandNSSetURL(const ci::string &cname) : Command(cname, 0)
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ if (u->Account()->url)
+ delete [] u->Account()->url;
+
+ if (!params.empty())
+ {
+ u->Account()->url = sstrdup(params[0].c_str());
+ notice_lang(Config.s_NickServ, u, NICK_SET_URL_CHANGED, params[0].c_str());
+ }
+ else
+ {
+ u->Account()->url = NULL;
+ notice_lang(Config.s_NickServ, u, NICK_SET_URL_UNSET);
+ }
+
+ return MOD_CONT;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_URL);
+ return true;
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SET_URL);
+ }
+};
+
+class CommandNSSASetURL : public Command
+{
+ public:
+ CommandNSSASetURL(const ci::string &cname) : Command(cname, 1, 2, "nickserv/saset/url")
+ {
+ }
+
+ CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ {
+ NickCore *nc = findcore(params[0]);
+ assert(nc);
+
+ const char *param = params.size() > 1 ? params[1].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;
+ }
+
+ bool OnHelp(User *u, const ci::string &)
+ {
+ notice_help(Config.s_NickServ, u, NICK_HELP_SASET_URL);
+ return true;
+ }
+
+ void OnServHelp(User *u)
+ {
+ notice_lang(Config.s_NickServ, u, NICK_HELP_CMD_SASET_URL);
+ }
+};
+
+class NSSetURL : public Module
+{
+ public:
+ NSSetURL(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ {
+ this->SetAuthor("Anope");
+ this->SetVersion("$Id$");
+ this->SetType(CORE);
+
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->AddSubcommand(new CommandNSSetURL("URL"));
+
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->AddSubcommand(new CommandNSSASetURL("URL"));
+ }
+
+ ~NSSetURL()
+ {
+ Command *c = FindCommand(NickServ, "SET");
+ if (c)
+ c->DelSubcommand("URL");
+ c = FindCommand(NickServ, "SASET");
+ if (c)
+ c->DelSubcommand("URL");
+ }
+};
+
+MODULE_INIT(NSSetURL)