summaryrefslogtreecommitdiff
path: root/src
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
parent6cd88494662c5c4af2da891926dcc82367596cb9 (diff)
Added in a subcommand system and switched ns_set and ns_saset to use it
Diffstat (limited to 'src')
-rw-r--r--src/botserv.cpp2
-rw-r--r--src/chanserv.cpp2
-rw-r--r--src/command.cpp19
-rw-r--r--src/commands.cpp23
-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
-rw-r--r--src/hostserv.cpp2
-rw-r--r--src/memoserv.cpp2
-rw-r--r--src/nickserv.cpp2
-rw-r--r--src/operserv.cpp2
-rw-r--r--src/protocol/inspircd11.cpp2
-rw-r--r--src/protocol/inspircd12.cpp2
-rw-r--r--src/protocol/inspircd20.cpp314
-rw-r--r--src/protocol/unreal32.cpp6
-rw-r--r--src/users.cpp2
27 files changed, 2145 insertions, 1057 deletions
diff --git a/src/botserv.cpp b/src/botserv.cpp
index 7f64c0c63..2dd96706d 100644
--- a/src/botserv.cpp
+++ b/src/botserv.cpp
@@ -85,7 +85,7 @@ void botserv(User *u, BotInfo *bi, const std::string &buf)
}
else
{
- mod_run_cmd(bi, u, buf.c_str());
+ mod_run_cmd(bi, u, buf);
}
}
diff --git a/src/chanserv.cpp b/src/chanserv.cpp
index 256909bb9..10acd3731 100644
--- a/src/chanserv.cpp
+++ b/src/chanserv.cpp
@@ -273,7 +273,7 @@ void chanserv(User *u, const std::string &buf)
}
else
{
- mod_run_cmd(ChanServ, u, buf.c_str());
+ mod_run_cmd(ChanServ, u, buf);
}
}
diff --git a/src/command.cpp b/src/command.cpp
index 7fd5975ef..922f298c3 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -20,16 +20,31 @@ Command::~Command()
{
}
-CommandReturn Command::Execute(User *u, const std::vector<ci::string> &) { return MOD_CONT; }
+CommandReturn Command::Execute(User *u, const std::vector<ci::string> &)
+{
+ return MOD_CONT;
+}
void Command::OnServHelp(User *u) { }
bool Command::OnHelp(User *u, const ci::string &subcommand) { return false; }
-void Command::OnSyntaxError(User *u, const ci::string &subcommand) { }
+void Command::OnSyntaxError(User *u, const ci::string &subcommand)
+{
+}
void Command::SetPermission(const std::string &reststr)
{
this->permission = reststr;
}
+bool Command::AddSubcommand(Command *c)
+{
+ return false;
+}
+
+bool Command::DelSubcommand(const ci::string &cname)
+{
+ return false;
+}
+
diff --git a/src/commands.cpp b/src/commands.cpp
index 3226bff59..f066b2885 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -29,22 +29,26 @@ Command *FindCommand(BotInfo *bi, const ci::string &name)
return NULL;
}
-void mod_run_cmd(BotInfo *bi, User *u, const ci::string &message)
+void mod_run_cmd(BotInfo *bi, User *u, const std::string &message)
{
- if (!bi || !u || message.empty())
- return;
-
- spacesepstream sep(message);
- ci::string command;
+ spacesepstream sep(ci::string(message.c_str()));
+ ci::string cmd;
- if (!sep.GetToken(command))
+ if (sep.GetToken(cmd))
+ {
+ mod_run_cmd(bi, u, FindCommand(bi, cmd), cmd, sep.GetRemaining().c_str());
+ }
+}
+
+void mod_run_cmd(BotInfo *bi, User *u, Command *c, const ci::string &command, const ci::string &message)
+{
+ if (!bi || !u)
return;
- Command *c = FindCommand(bi, command);
CommandReturn ret = MOD_CONT;
EventReturn MOD_RESULT;
- FOREACH_RESULT(I_OnPreCommandRun, OnPreCommandRun(u, bi, command, sep.GetRemaining().c_str(), c));
+ FOREACH_RESULT(I_OnPreCommandRun, OnPreCommandRun(u, bi, command, message, c));
if (MOD_RESULT == EVENT_STOP)
return;
@@ -67,6 +71,7 @@ void mod_run_cmd(BotInfo *bi, User *u, const ci::string &message)
std::vector<ci::string> params;
ci::string curparam, endparam;
+ spacesepstream sep(message);
while (sep.GetToken(curparam))
{
// - 1 because params[0] corresponds with a maxparam of 1.
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)
diff --git a/src/hostserv.cpp b/src/hostserv.cpp
index 04bb61e4c..8cce7783f 100644
--- a/src/hostserv.cpp
+++ b/src/hostserv.cpp
@@ -97,7 +97,7 @@ void hostserv(User *u, const std::string &buf)
}
else
{
- mod_run_cmd(HostServ, u, buf.c_str());
+ mod_run_cmd(HostServ, u, buf);
}
}
diff --git a/src/memoserv.cpp b/src/memoserv.cpp
index b4d33fdd0..505b4ed18 100644
--- a/src/memoserv.cpp
+++ b/src/memoserv.cpp
@@ -65,7 +65,7 @@ void memoserv(User *u, const std::string &buf)
}
else
{
- mod_run_cmd(MemoServ, u, buf.c_str());
+ mod_run_cmd(MemoServ, u, buf);
}
}
diff --git a/src/nickserv.cpp b/src/nickserv.cpp
index ce574b098..c14de6ae6 100644
--- a/src/nickserv.cpp
+++ b/src/nickserv.cpp
@@ -182,7 +182,7 @@ void nickserv(User *u, const std::string &buf)
}
else
{
- mod_run_cmd(NickServ, u, buf.c_str());
+ mod_run_cmd(NickServ, u, buf);
}
}
diff --git a/src/operserv.cpp b/src/operserv.cpp
index 863fb459e..8e3a3c90f 100644
--- a/src/operserv.cpp
+++ b/src/operserv.cpp
@@ -55,7 +55,7 @@ void operserv(User *u, const std::string &buf)
}
else
{
- mod_run_cmd(OperServ, u, buf.c_str());
+ mod_run_cmd(OperServ, u, buf);
}
}
diff --git a/src/protocol/inspircd11.cpp b/src/protocol/inspircd11.cpp
index 8fe766824..09c329f0c 100644
--- a/src/protocol/inspircd11.cpp
+++ b/src/protocol/inspircd11.cpp
@@ -321,7 +321,7 @@ class InspIRCdProto : public IRCDProto
u->Account()->Shrink("authenticationtoken");
u->Account()->Extend("authenticationtoken", new ExtensibleItemPointerArray<char>(sstrdup(svidbuf)));
- u->SetMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
+ u->SetMode(NickServ, UMODE_REGISTERED);
}
} ircd_proto;
diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp
index 3690fcea6..9a9f88fea 100644
--- a/src/protocol/inspircd12.cpp
+++ b/src/protocol/inspircd12.cpp
@@ -1400,7 +1400,7 @@ class ProtoInspIRCd : public Module
/* InspIRCd 1.2 doesn't set -r on nick change, remove -r here. Note that if we have to set +r later
* this will cancel out this -r, resulting in no mode changes.
*/
- u->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
+ u->RemoveMode(NickServ, UMODE_REGISTERED);
}
};
diff --git a/src/protocol/inspircd20.cpp b/src/protocol/inspircd20.cpp
index 4b37e8c1c..4d333658c 100644
--- a/src/protocol/inspircd20.cpp
+++ b/src/protocol/inspircd20.cpp
@@ -1,4 +1,4 @@
-/* inspircd 1.2 functions
+/* Inspircd 2.0 functions
*
* (C) 2003-2010 Anope Team
* Contact us at team@anope.org
@@ -14,7 +14,7 @@
/*************************************************************************/
#include "services.h"
-#include "pseudo.h"
+#include "modules.h"
#include "hashcomp.h"
#ifndef _WIN32
@@ -40,7 +40,7 @@ IRCDVar myIrcd[] = {
"+ao", /* Channel Umode used by Botserv bots */
1, /* SVSNICK */
1, /* Vhost */
- 0, /* Supports SGlines */
+ 0, /* Supports SNlines */
1, /* Supports SQlines */
1, /* Supports SZlines */
4, /* Number of server args */
@@ -93,11 +93,11 @@ void inspircd_cmd_chghost(const char *nick, const char *vhost)
{
if (has_chghostmod != 1)
{
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "CHGHOST not loaded!");
+ ircdproto->SendGlobops(OperServ, "CHGHOST not loaded!");
return;
}
- BotInfo *bi = findbot(Config.s_OperServ);
+ BotInfo *bi = OperServ;
send_cmd(bi->uid, "CHGHOST %s %s", nick, vhost);
}
@@ -122,10 +122,10 @@ void inspircd_cmd_pass(const char *pass)
class InspIRCdProto : public IRCDProto
{
- void SendAkillDel(Akill *ak)
+ void SendAkillDel(XLine *x)
{
- BotInfo *bi = findbot(Config.s_OperServ);
- send_cmd(bi->uid, "GLINE %s@%s", ak->user, ak->host);
+ BotInfo *bi = OperServ;
+ send_cmd(bi->uid, "GLINE %s", x->Mask.c_str());
}
void SendTopic(BotInfo *whosets, Channel *c, const char *whosetit, const char *topic)
@@ -146,14 +146,14 @@ class InspIRCdProto : public IRCDProto
}
}
- void SendAkill(Akill *ak)
+ void SendAkill(XLine *x)
{
// Calculate the time left before this would expire, capping it at 2 days
- time_t timeleft = ak->expires - time(NULL);
- if (timeleft > 172800 || !ak->expires)
+ time_t timeleft = x->Expires - time(NULL);
+ if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
- BotInfo *bi = findbot(Config.s_OperServ);
- send_cmd(bi->uid, "ADDLINE G %s@%s %s %ld %ld :%s", ak->user, ak->host, ak->by, static_cast<long>(time(NULL)), static_cast<long>(timeleft), ak->reason);
+ BotInfo *bi = OperServ;
+ send_cmd(bi->uid, "ADDLINE G %s@%s %s %ld %ld :%s", x->GetUser().c_str(), x->GetHost().c_str(), x->By.c_str(), static_cast<long>(time(NULL)), static_cast<long>(timeleft), x->Reason.c_str());
}
void SendSVSKillInternal(BotInfo *source, User *user, const char *buf)
@@ -208,7 +208,7 @@ class InspIRCdProto : public IRCDProto
/* SERVER services-dev.chatspike.net password 0 :Description here */
void SendServer(Server *server)
{
- send_cmd(NULL, "SERVER %s %s %d %s :%s", server->name, currentpass, server->hops, server->suid, server->desc);
+ send_cmd(NULL, "SERVER %s %s %d %s :%s", server->GetName().c_str(), currentpass, server->GetHops(), server->GetSID().c_str(), server->GetDescription().c_str());
}
/* JOIN */
@@ -218,19 +218,15 @@ class InspIRCdProto : public IRCDProto
}
/* UNSQLINE */
- void SendSQLineDel(const std::string &user)
+ void SendSQLineDel(XLine *x)
{
- if (user.empty())
- return;
- send_cmd(TS6SID, "DELLINE Q %s", user.c_str());
+ send_cmd(TS6SID, "DELLINE Q %s", x->Mask.c_str());
}
/* SQLINE */
- void SendSQLine(const std::string &mask, const std::string &reason)
+ void SendSQLine(XLine *x)
{
- if (mask.empty() || reason.empty())
- return;
- send_cmd(TS6SID, "ADDLINE Q %s %s %ld 0 :%s", mask.c_str(), Config.s_OperServ, static_cast<long>(time(NULL)), reason.c_str());
+ send_cmd(TS6SID, "ADDLINE Q %s %s %ld 0 :%s", x->Mask.c_str(), Config.s_OperServ, static_cast<long>(time(NULL)), x->Reason.c_str());
}
/* SQUIT */
@@ -251,11 +247,11 @@ class InspIRCdProto : public IRCDProto
void SendConnect()
{
+ Me = new Server(NULL, Config.ServerName, 0, Config.ServerDesc, TS6SID);
inspircd_cmd_pass(uplink_server->password);
- me_server = new_server(NULL, Config.ServerName, Config.ServerDesc, SERVER_ISME, TS6SID);
- SendServer(me_server);
+ SendServer(Me);
send_cmd(TS6SID, "BURST");
- send_cmd(TS6SID, "VERSION :Anope-%s %s :%s - %s (%s) -- %s", version_number, Config.ServerName, ircd->name, version_flags, Config.EncModuleList.begin()->c_str(), version_build);
+ send_cmd(TS6SID, "VERSION :Anope-%s %s :%s - (%s) -- %s", version_number, Config.ServerName, ircd->name, Config.EncModuleList.begin()->c_str(), version_build);
}
/* CHGIDENT */
@@ -263,11 +259,11 @@ class InspIRCdProto : public IRCDProto
{
if (has_chgidentmod == 0)
{
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "CHGIDENT not loaded!");
+ ircdproto->SendGlobops(OperServ, "CHGIDENT not loaded!");
}
else
{
- BotInfo *bi = findbot(Config.s_OperServ);
+ BotInfo *bi = OperServ;
send_cmd(bi->uid, "CHGIDENT %s %s", nick, vIdent);
}
}
@@ -275,33 +271,33 @@ class InspIRCdProto : public IRCDProto
/* SVSHOLD - set */
void SendSVSHold(const char *nick)
{
- BotInfo *bi = findbot(Config.s_OperServ);
+ BotInfo *bi = OperServ;
send_cmd(bi->uid, "SVSHOLD %s %u :%s", nick, static_cast<unsigned>(Config.NSReleaseTimeout), "Being held for registered user");
}
/* SVSHOLD - release */
void SendSVSHoldDel(const char *nick)
{
- BotInfo *bi = findbot(Config.s_OperServ);
+ BotInfo *bi = OperServ;
send_cmd(bi->uid, "SVSHOLD %s", nick);
}
/* UNSZLINE */
- void SendSZLineDel(SXLine *sx)
+ void SendSZLineDel(XLine *x)
{
- send_cmd(TS6SID, "DELLINE Z %s", sx->mask);
+ send_cmd(TS6SID, "DELLINE Z %s", x->Mask.c_str());
}
/* SZLINE */
- void SendSZLine(SXLine *sx)
+ void SendSZLine(XLine *x)
{
- send_cmd(TS6SID, "ADDLINE Z %s %s %ld 0 :%s", sx->mask, sx->by, static_cast<long>(time(NULL)), sx->reason);
+ send_cmd(TS6SID, "ADDLINE Z %s %s %ld 0 :%s", x->Mask.c_str(), x->By.c_str(), static_cast<long>(time(NULL)), x->Reason.c_str());
}
/* SVSMODE -r */
void SendUnregisteredNick(User *u)
{
- u->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
+ u->RemoveMode(NickServ, UMODE_REGISTERED);
}
void SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param)
@@ -361,7 +357,7 @@ class InspIRCdProto : public IRCDProto
if (!u->Account())
return;
- u->SetMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
+ u->SetMode(NickServ, UMODE_REGISTERED);
}
} ircd_proto;
@@ -396,8 +392,8 @@ int anope_event_mode(const char *source, int ac, const char **av)
users modes, we have to kludge this
as it slightly breaks RFC1459
*/
- User *u = find_byuid(source);
- User *u2 = find_byuid(av[0]);
+ User *u = finduser(source);
+ User *u2 = finduser(av[0]);
// This can happen with server-origin modes.
if (u == NULL)
@@ -553,7 +549,7 @@ int anope_event_fjoin(const char *source, int ac, const char **av)
}
buf.erase(buf.begin());
- User *u = find_byuid(buf);
+ User *u = finduser(buf);
if (!u)
{
Alog(LOG_DEBUG) << "FJOIN for nonexistant user " << buf << " on " << c->name;
@@ -645,7 +641,7 @@ int anope_event_topic(const char *source, int ac, const char **av)
{
Channel *c = findchan(av[0]);
time_t topic_time = time(NULL);
- User *u = find_byuid(source);
+ User *u = finduser(source);
if (!c)
{
@@ -687,12 +683,10 @@ int anope_event_squit(const char *source, int ac, const char **av)
int anope_event_rsquit(const char *source, int ac, const char **av)
{
/* On InspIRCd we must send a SQUIT when we recieve RSQUIT for a server we have juped */
- Server *s = findserver(servlist, av[0]);
- if (!s)
- s = findserver_uid(servlist, av[0]);
+ Server *s = Server::Find(av[0]);
if (s && s->HasFlag(SERVER_JUPED))
{
- send_cmd(TS6SID, "SQUIT %s :%s", s->suid, ac > 1 ? av[1] : "");
+ send_cmd(TS6SID, "SQUIT %s :%s", s->GetSID().c_str(), ac > 1 ? av[1] : "");
}
do_squit(source, ac, av);
@@ -709,7 +703,7 @@ int anope_event_quit(const char *source, int ac, const char **av)
int anope_event_kill(const char *source, int ac, const char **av)
{
- User *u = find_byuid(av[0]);
+ User *u = finduser(av[0]);
BotInfo *bi = findbot(av[0]);
m_kill(u ? u->nick.c_str() : (bi ? bi->nick : av[0]), av[1]);
return MOD_CONT;
@@ -836,7 +830,7 @@ int anope_event_uid(const char *source, int ac, const char **av)
User *user;
NickAlias *na;
struct in_addr addy;
- Server *s = findserver_uid(servlist, source);
+ Server *s = Server::Find(source ? source : "");
uint32 *ad = reinterpret_cast<uint32 *>(&addy);
int ts = strtoul(av[1], NULL, 10);
@@ -845,11 +839,11 @@ int anope_event_uid(const char *source, int ac, const char **av)
user = prev_u_intro;
prev_u_intro = NULL;
if (user) na = findnick(user->nick);
- if (user && user->server->sync == SSYNC_IN_PROGRESS && (!na || na->nc != user->Account()))
+ if (user && !user->server->IsSynced() && (!na || na->nc != user->Account()))
{
validate_user(user);
if (user->HasMode(UMODE_REGISTERED))
- user->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
+ user->RemoveMode(NickServ, UMODE_REGISTERED);
}
user = NULL;
@@ -857,14 +851,14 @@ int anope_event_uid(const char *source, int ac, const char **av)
user = do_nick("", av[2], /* nick */
av[5], /* username */
av[3], /* realhost */
- s->name, /* server */
+ s->GetName().c_str(), /* server */
av[ac - 1], /* realname */
ts, htonl(*ad), av[4], av[0]);
if (user)
{
UserSetInternalModes(user, 1, &av[8]);
user->SetCloakedHost(av[4]);
- if (user->server->sync == SSYNC_IN_PROGRESS)
+ if (!user->server->IsSynced())
{
prev_u_intro = user;
}
@@ -902,24 +896,17 @@ int anope_event_chghost(const char *source, int ac, const char **av)
*/
int anope_event_server(const char *source, int ac, const char **av)
{
- if (!stricmp(av[2], "0"))
- {
- uplink = sstrdup(av[0]);
- }
- do_server(source, av[0], av[2], av[4], av[3]);
+ do_server(source, av[0], atoi(av[2]), av[4], av[3]);
return MOD_CONT;
}
int anope_event_privmsg(const char *source, int ac, const char **av)
{
- User *u = find_byuid(source);
- BotInfo *bi = findbot(av[0]);
-
- if (!u)
+ if (!finduser(source))
return MOD_CONT; // likely a message from a server, which can happen.
- m_privmsg(u->nick.c_str(), bi ? bi->nick: av[0], av[1]);
+ m_privmsg(source, av[0], av[1]);
return MOD_CONT;
}
@@ -943,7 +930,7 @@ int anope_event_metadata(const char *source, int ac, const char **av)
return MOD_CONT;
else if (!strcmp(av[1], "accountname"))
{
- if ((u = find_byuid(av[0])))
+ if ((u = finduser(av[0])))
{
/* Identify the user for this account - Adam */
u->AutoID(av[2]);
@@ -1025,14 +1012,14 @@ int anope_event_capab(const char *source, int ac, const char **av)
continue;
/* InspIRCd sends q and a here if they have no prefixes */
case 'q':
- ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OWNER, 'q', '@'));
+ ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OWNER, "CMODE_OWNER", 'q', '@'));
continue;
case 'a':
- ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_PROTECT , 'a', '@'));
+ ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_PROTECT , "CMODE_PROTECT", 'a', '@'));
continue;
// XXX list modes needs a bit of a rewrite, we need to be able to support +g here
default:
- ModeManager::AddChannelMode(new ChannelModeList(CMODE_END, modebuf[t]));
+ ModeManager::AddChannelMode(new ChannelModeList(CMODE_END, "", modebuf[t]));
}
}
@@ -1045,7 +1032,7 @@ int anope_event_capab(const char *source, int ac, const char **av)
ModeManager::AddChannelMode(new ChannelModeKey('k'));
continue;
default:
- ModeManager::AddChannelMode(new ChannelModeParam(CMODE_END, modebuf[t]));
+ ModeManager::AddChannelMode(new ChannelModeParam(CMODE_END, "", modebuf[t]));
}
}
@@ -1055,25 +1042,25 @@ int anope_event_capab(const char *source, int ac, const char **av)
switch (modebuf[t])
{
case 'F':
- ModeManager::AddChannelMode(new ChannelModeParam(CMODE_NICKFLOOD, 'F', true));
+ ModeManager::AddChannelMode(new ChannelModeParam(CMODE_NICKFLOOD, "CMODE_NICKFLOOD", 'F', true));
continue;
case 'J':
- ModeManager::AddChannelMode(new ChannelModeParam(CMODE_NOREJOIN, 'J', true));
+ ModeManager::AddChannelMode(new ChannelModeParam(CMODE_NOREJOIN, "CMODE_NOREJOIN", 'J', true));
continue;
case 'L':
- ModeManager::AddChannelMode(new ChannelModeParam(CMODE_REDIRECT, 'L', true));
+ ModeManager::AddChannelMode(new ChannelModeParam(CMODE_REDIRECT, "CMODE_REDIRECT", 'L', true));
continue;
case 'f':
ModeManager::AddChannelMode(new ChannelModeFlood('f', true));
continue;
case 'j':
- ModeManager::AddChannelMode(new ChannelModeParam(CMODE_JOINFLOOD, 'j', true));
+ ModeManager::AddChannelMode(new ChannelModeParam(CMODE_JOINFLOOD, "CMODE_JOINFLOOD", 'j', true));
continue;
case 'l':
- ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, 'l', true));
+ ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, "CMODE_LIMIT", 'l', true));
continue;
default:
- ModeManager::AddChannelMode(new ChannelModeParam(CMODE_END, modebuf[t], true));
+ ModeManager::AddChannelMode(new ChannelModeParam(CMODE_END, "", modebuf[t], true));
}
}
@@ -1083,79 +1070,79 @@ int anope_event_capab(const char *source, int ac, const char **av)
switch (modebuf[t])
{
case 'A':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_ALLINVITE, 'A'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_ALLINVITE, "CMODE_ALLINVITE", 'A'));
continue;
case 'B':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_BLOCKCAPS, 'B'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_BLOCKCAPS, "CMODE_BLOCKCAPS", 'B'));
continue;
case 'C':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_NOCTCP, 'C'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_NOCTCP, "CMODE_NOCTCP", 'C'));
continue;
case 'D':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_DELAYEDJOIN, 'D'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_DELAYEDJOIN, "CMODE_DELAYEDJOIN", 'D'));
continue;
case 'G':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_FILTER, 'G'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_FILTER, "CMODE_FILTER", 'G'));
continue;
case 'K':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_NOKNOCK, 'K'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_NOKNOCK, "CMODE_NOKNOCK", 'K'));
continue;
case 'M':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_REGMODERATED, 'M'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_REGMODERATED, "CMODE_REGMODERATED", 'M'));
continue;
case 'N':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_NONICK, 'N'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_NONICK, "CMODE_NONICK", 'N'));
continue;
case 'O':
ModeManager::AddChannelMode(new ChannelModeOper('O'));
continue;
case 'P':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_PERM, 'P'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_PERM, "CMODE_PERM", 'P'));
continue;
case 'Q':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_NOKICK, 'Q'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_NOKICK, "CMODE_NOKICK", 'Q'));
continue;
case 'R':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_REGISTEREDONLY, 'R'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_REGISTEREDONLY, "CMODE_REGISTEREDONLY", 'R'));
continue;
case 'S':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_STRIPCOLOR, 'S'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_STRIPCOLOR, "CMODE_STRIPCOLOR", 'S'));
continue;
case 'T':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_NONOTICE, 'T'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_NONOTICE, "CMODE_NONOTICE", 'T'));
continue;
case 'c':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_BLOCKCOLOR, 'c'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_BLOCKCOLOR, "CMODE_BLOCKCOLOR", 'c'));
continue;
case 'i':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, 'i'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, "CMODE_INVITE", 'i'));
continue;
case 'm':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, 'm'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, "CMODE_MODERATED", 'm'));
continue;
case 'n':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, 'n'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, "CMODE_NOEXTERNAL", 'n'));
continue;
case 'p':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_PRIVATE, 'p'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_PRIVATE, "CMODE_PRIVATE", 'p'));
continue;
case 'r':
ModeManager::AddChannelMode(new ChannelModeRegistered('r'));
continue;
case 's':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, 's'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, "CMODE_SECRET", 's'));
continue;
case 't':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, 't'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, "CMODE_TOPIC", 't'));
continue;
case 'u':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_AUDITORIUM, 'u'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_AUDITORIUM, "CMODE_AUDITORIUM", 'u'));
continue;
case 'z':
- ModeManager::AddChannelMode(new ChannelMode(CMODE_SSL, 'z'));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_SSL, "CMODE_SSL", 'z'));
continue;
default:
- ModeManager::AddChannelMode(new ChannelMode(CMODE_END, modebuf[t]));
+ ModeManager::AddChannelMode(new ChannelMode(CMODE_END, "", modebuf[t]));
}
}
}
@@ -1172,64 +1159,64 @@ int anope_event_capab(const char *source, int ac, const char **av)
switch (modebuf[t])
{
case 'h':
- ModeManager::AddUserMode(new UserMode(UMODE_HELPOP, 'h'));
+ ModeManager::AddUserMode(new UserMode(UMODE_HELPOP, "UMODE_HELPOP", 'h'));
continue;
case 's':
- ModeManager::AddUserMode(new UserMode(UMODE_STRIPCOLOR, 'S'));
+ ModeManager::AddUserMode(new UserMode(UMODE_STRIPCOLOR, "UMODE_STRIPCOLOR", 'S'));
continue;
case 'B':
- ModeManager::AddUserMode(new UserMode(UMODE_BOT, 'B'));
+ ModeManager::AddUserMode(new UserMode(UMODE_BOT, "UMODE_BOT", 'B'));
continue;
case 'G':
- ModeManager::AddUserMode(new UserMode(UMODE_FILTER, 'G'));
+ ModeManager::AddUserMode(new UserMode(UMODE_FILTER, "UMODE_FILTER", 'G'));
continue;
case 'H':
- ModeManager::AddUserMode(new UserMode(UMODE_HIDEOPER, 'H'));
+ ModeManager::AddUserMode(new UserMode(UMODE_HIDEOPER, "UMODE_HIDEOPER", 'H'));
continue;
case 'I':
- ModeManager::AddUserMode(new UserMode(UMODE_PRIV, 'I'));
+ ModeManager::AddUserMode(new UserMode(UMODE_PRIV, "UMODE_PRIV", 'I'));
continue;
case 'Q':
- ModeManager::AddUserMode(new UserMode(UMODE_HIDDEN, 'Q'));
+ ModeManager::AddUserMode(new UserMode(UMODE_HIDDEN, "UMODE_HIDDEN", 'Q'));
continue;
case 'R':
- ModeManager::AddUserMode(new UserMode(UMODE_REGPRIV, 'R'));
+ ModeManager::AddUserMode(new UserMode(UMODE_REGPRIV, "UMODE_REGPRIV", 'R'));
continue;
case 'S':
- ModeManager::AddUserMode(new UserMode(UMODE_STRIPCOLOR, 'S'));
+ ModeManager::AddUserMode(new UserMode(UMODE_STRIPCOLOR, "UMODE_STRIPCOLOR", 'S'));
continue;
case 'W':
- ModeManager::AddUserMode(new UserMode(UMODE_WHOIS, 'W'));
+ ModeManager::AddUserMode(new UserMode(UMODE_WHOIS, "UMODE_WHOIS", 'W'));
continue;
case 'c':
- ModeManager::AddUserMode(new UserMode(UMODE_COMMONCHANS, 'c'));
+ ModeManager::AddUserMode(new UserMode(UMODE_COMMONCHANS, "UMODE_COMMONCHANS", 'c'));
continue;
case 'g':
- ModeManager::AddUserMode(new UserMode(UMODE_CALLERID, 'g'));
+ ModeManager::AddUserMode(new UserMode(UMODE_CALLERID, "UMODE_CALLERID", 'g'));
continue;
case 'i':
- ModeManager::AddUserMode(new UserMode(UMODE_INVIS, 'i'));
+ ModeManager::AddUserMode(new UserMode(UMODE_INVIS, "UMODE_INVIS", 'i'));
continue;
case 'k':
- ModeManager::AddUserMode(new UserMode(UMODE_PROTECTED, 'k'));
+ ModeManager::AddUserMode(new UserMode(UMODE_PROTECTED, "UMODE_PROTECTED", 'k'));
continue;
case 'o':
- ModeManager::AddUserMode(new UserMode(UMODE_OPER, 'o'));
+ ModeManager::AddUserMode(new UserMode(UMODE_OPER, "UMODE_OPER", 'o'));
continue;
case 'r':
- ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, 'r'));
+ ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, "UMODE_REGISTERED", 'r'));
continue;
case 'w':
- ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, 'w'));
+ ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, "UMODE_WALLOPS", 'w'));
continue;
case 'x':
- ModeManager::AddUserMode(new UserMode(UMODE_CLOAK, 'x'));
+ ModeManager::AddUserMode(new UserMode(UMODE_CLOAK, "UMODE_CLOAK", 'x'));
continue;
case 'd':
- ModeManager::AddUserMode(new UserMode(UMODE_DEAF, 'd'));
+ ModeManager::AddUserMode(new UserMode(UMODE_DEAF, "UMODE_DEAF", 'd'));
continue;
default:
- ModeManager::AddUserMode(new UserMode(UMODE_END, modebuf[t]));
+ ModeManager::AddUserMode(new UserMode(UMODE_END, "", modebuf[t]));
}
}
}
@@ -1244,19 +1231,19 @@ int anope_event_capab(const char *source, int ac, const char **av)
switch (modes[t])
{
case 'q':
- ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OWNER, 'q', chars[t]));
+ ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OWNER, "CMODE_OWNER", 'q', chars[t]));
continue;
case 'a':
- ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_PROTECT, 'a', chars[t]));
+ ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_PROTECT, "CMODE_PROTECT", 'a', chars[t]));
continue;
case 'o':
- ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, 'o', chars[t]));
+ ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, "CMODE_OP", 'o', chars[t]));
continue;
case 'h':
- ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_HALFOP, 'h', chars[t]));
+ ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_HALFOP, "CMODE_HALFOP", 'h', chars[t]));
continue;
case 'v':
- ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, 'v', chars[t]));
+ ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, "CMODE_VOICE", 'v', chars[t]));
continue;
}
}
@@ -1287,13 +1274,13 @@ int anope_event_capab(const char *source, int ac, const char **av)
return MOD_STOP;
}
if (!has_svsholdmod) {
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "SVSHOLD missing, Usage disabled until module is loaded.");
+ ircdproto->SendGlobops(OperServ, "SVSHOLD missing, Usage disabled until module is loaded.");
}
if (!has_chghostmod) {
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "CHGHOST missing, Usage disabled until module is loaded.");
+ ircdproto->SendGlobops(OperServ, "CHGHOST missing, Usage disabled until module is loaded.");
}
if (!has_chgidentmod) {
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "CHGIDENT missing, Usage disabled until module is loaded.");
+ ircdproto->SendGlobops(OperServ, "CHGIDENT missing, Usage disabled until module is loaded.");
}
ircd->svshold = has_svsholdmod;
}
@@ -1307,7 +1294,8 @@ int anope_event_endburst(const char *source, int ac, const char **av)
{
NickAlias *na;
User *u = prev_u_intro;
- Server *s = findserver_uid(servlist, source);
+ Server *s = Server::Find(source ? source : "");
+
if (!s)
{
throw new CoreException("Got ENDBURST without a source");
@@ -1317,56 +1305,55 @@ int anope_event_endburst(const char *source, int ac, const char **av)
* If not, validate the user. ~ Viper*/
prev_u_intro = NULL;
if (u) na = findnick(u->nick);
- if (u && u->server->sync == SSYNC_IN_PROGRESS && (!na || na->nc != u->Account()))
+ if (u && !u->server->IsSynced() && (!na || na->nc != u->Account()))
{
validate_user(u);
if (u->HasMode(UMODE_REGISTERED))
- u->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
+ u->RemoveMode(NickServ, UMODE_REGISTERED);
}
- Alog() << "Processed ENDBURST for " << s->name;
+ Alog() << "Processed ENDBURST for " << s->GetName();
- finish_sync(s, 1);
+ s->Sync(true);
return MOD_CONT;
}
-void moduleAddIRCDMsgs() {
- Message *m;
-
- m = createMessage("ENDBURST", anope_event_endburst); addCoreMessage(IRCD, m);
- m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m);
- m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m);
- m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m);
- m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m);
- m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m);
- m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m);
- m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m);
- m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m);
- m = createMessage("UID", anope_event_uid); addCoreMessage(IRCD,m);
- m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m);
- m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m);
- m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m);
- m = createMessage("TIME", anope_event_time); addCoreMessage(IRCD,m);
- m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m);
- m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m);
- m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m);
- m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m);
- m = createMessage("RSQUIT", anope_event_rsquit); addCoreMessage(IRCD,m);
- m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m);
- m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m);
- m = createMessage("SVSMODE", anope_event_mode) ;addCoreMessage(IRCD,m);
- m = createMessage("FHOST", anope_event_chghost); addCoreMessage(IRCD,m);
- m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m);
- m = createMessage("FNAME", anope_event_chgname); addCoreMessage(IRCD,m);
- m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m);
- m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m);
- m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m);
- m = createMessage("FJOIN", anope_event_fjoin); addCoreMessage(IRCD,m);
- m = createMessage("FMODE", anope_event_fmode); addCoreMessage(IRCD,m);
- m = createMessage("FTOPIC", anope_event_ftopic); addCoreMessage(IRCD,m);
- m = createMessage("OPERTYPE", anope_event_opertype); addCoreMessage(IRCD,m);
- m = createMessage("IDLE", anope_event_idle); addCoreMessage(IRCD,m);
- m = createMessage("METADATA", anope_event_metadata); addCoreMessage(IRCD,m);
+void moduleAddIRCDMsgs()
+{
+ Anope::AddMessage("ENDBURST", anope_event_endburst);
+ Anope::AddMessage("436", anope_event_436);
+ Anope::AddMessage("AWAY", anope_event_away);
+ Anope::AddMessage("JOIN", anope_event_join);
+ Anope::AddMessage("KICK", anope_event_kick);
+ Anope::AddMessage("KILL", anope_event_kill);
+ Anope::AddMessage("MODE", anope_event_mode);
+ Anope::AddMessage("MOTD", anope_event_motd);
+ Anope::AddMessage("NICK", anope_event_nick);
+ Anope::AddMessage("UID", anope_event_uid);
+ Anope::AddMessage("CAPAB", anope_event_capab);
+ Anope::AddMessage("PART", anope_event_part);
+ Anope::AddMessage("PING", anope_event_ping);
+ Anope::AddMessage("TIME", anope_event_time);
+ Anope::AddMessage("PRIVMSG", anope_event_privmsg);
+ Anope::AddMessage("QUIT", anope_event_quit);
+ Anope::AddMessage("SERVER", anope_event_server);
+ Anope::AddMessage("SQUIT", anope_event_squit);
+ Anope::AddMessage("RSQUIT", anope_event_rsquit);
+ Anope::AddMessage("TOPIC", anope_event_topic);
+ Anope::AddMessage("WHOIS", anope_event_whois);
+ Anope::AddMessage("SVSMODE", anope_event_mode);
+ Anope::AddMessage("FHOST", anope_event_chghost);
+ Anope::AddMessage("CHGIDENT", anope_event_chgident);
+ Anope::AddMessage("FNAME", anope_event_chgname);
+ Anope::AddMessage("SETHOST", anope_event_sethost);
+ Anope::AddMessage("SETIDENT", anope_event_setident);
+ Anope::AddMessage("SETNAME", anope_event_setname);
+ Anope::AddMessage("FJOIN", anope_event_fjoin);
+ Anope::AddMessage("FMODE", anope_event_fmode);
+ Anope::AddMessage("FTOPIC", anope_event_ftopic);
+ Anope::AddMessage("OPERTYPE", anope_event_opertype);
+ Anope::AddMessage("IDLE", anope_event_idle);
+ Anope::AddMessage("METADATA", anope_event_metadata);
}
bool ChannelModeFlood::IsValid(const std::string &value)
@@ -1409,7 +1396,6 @@ class ProtoInspIRCd : public Module
void OnUserNickChange(User *u, const std::string &)
{
- /* InspIRCd 2.0 removes r on nick change and doesn't tell services, even though it tells the user */
u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED));
}
};
diff --git a/src/protocol/unreal32.cpp b/src/protocol/unreal32.cpp
index 4d90e6bcf..65ee9d3e2 100644
--- a/src/protocol/unreal32.cpp
+++ b/src/protocol/unreal32.cpp
@@ -594,9 +594,9 @@ int anope_event_ping(const char *source, int ac, const char **av)
*/
int anope_event_pong(const char *source, int ac, const char **av)
{
- Server *s = findserver(servlist, source);
- if (s && !is_sync(s))
- finish_sync(s, 0);
+ Server *s = Server::Find(source);
+ if (s && !s->IsSynced())
+ s->Sync(false);
return MOD_CONT;
}
diff --git a/src/users.cpp b/src/users.cpp
index 5c88f9666..a1890f6c5 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -412,7 +412,7 @@ void User::AutoID(const std::string &account)
delete [] na->last_realname;
na->last_realname = sstrdup(this->realname);
na->last_seen = time(NULL);
- this->SetMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
+ this->SetMode(NickServ, UMODE_REGISTERED);
this->UpdateHost();
check_memos(this);