summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-08-03 01:49:15 -0400
committerAdam <Adam@anope.org>2010-08-03 01:49:15 -0400
commit59ee16c7cb14d1ac80b9ed9b89d868af45de5ee5 (patch)
tree68e41ef54f6a77f8e8b75e80ef5eeda9a2ecdf04
parent7b27a4e49192645b67eddba829a588e9e6d978ee (diff)
Made ns set/saset work like cs set/saset, cleans up a lot of code
-rw-r--r--modules/core/ns_saset_noexpire.cpp4
-rw-r--r--modules/core/ns_set.cpp12
-rw-r--r--modules/core/ns_set_autoop.cpp48
-rw-r--r--modules/core/ns_set_email.cpp73
-rw-r--r--modules/core/ns_set_greet.cpp44
-rw-r--r--modules/core/ns_set_hide.cpp109
-rw-r--r--modules/core/ns_set_kill.cpp94
-rw-r--r--modules/core/ns_set_language.cpp41
-rw-r--r--modules/core/ns_set_message.cpp56
-rw-r--r--modules/core/ns_set_private.cpp48
-rw-r--r--modules/core/ns_set_secure.cpp48
11 files changed, 169 insertions, 408 deletions
diff --git a/modules/core/ns_saset_noexpire.cpp b/modules/core/ns_saset_noexpire.cpp
index a041e5304..3404a0db2 100644
--- a/modules/core/ns_saset_noexpire.cpp
+++ b/modules/core/ns_saset_noexpire.cpp
@@ -16,7 +16,7 @@
class CommandNSSASetNoexpire : public Command
{
public:
- CommandNSSASetNoexpire() : Command("NOEXPIRE", 1, 3, "nickserv/saset/noexpire")
+ CommandNSSASetNoexpire() : Command("NOEXPIRE", 1, 2, "nickserv/saset/noexpire")
{
}
@@ -26,7 +26,7 @@ class CommandNSSASetNoexpire : public Command
if (!na)
throw CoreException("NULL na in CommandNSSASsetNoexpire");
- Anope::string param = params.size() > 1 ? params[2] : "";
+ Anope::string param = params.size() > 1 ? params[1] : "";
if (param.equals_ci("ON"))
{
diff --git a/modules/core/ns_set.cpp b/modules/core/ns_set.cpp
index fff85538e..ee426931b 100644
--- a/modules/core/ns_set.cpp
+++ b/modules/core/ns_set.cpp
@@ -46,11 +46,9 @@ class CommandNSSet : public Command
if (c)
{
- Anope::string cmdparams;
+ Anope::string cmdparams = u->Account()->display;
for (std::vector<Anope::string>::const_iterator it = params.begin() + 1, it_end = params.end(); it != it_end; ++it)
cmdparams += " " + *it;
- if (!cmdparams.empty())
- cmdparams.erase(cmdparams.begin());
mod_run_cmd(NickServ, u, c, params[0], cmdparams);
}
else
@@ -124,7 +122,7 @@ class CommandNSSetDisplay : public Command
if (!na || na->nc != u->Account())
{
- notice_lang(Config.s_NickServ, u, NICK_SET_DISPLAY_INVALID);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_DISPLAY_INVALID, u->Account()->display.c_str());
return MOD_CONT;
}
@@ -178,15 +176,15 @@ class CommandNSSetPassword : public Command
if (enc_encrypt(param, u->Account()->pass) < 0)
{
Alog() << Config.s_NickServ << ": Failed to encrypt password for " << u->Account()->display << " (set)";
- notice_lang(Config.s_NickServ, u, NICK_SET_PASSWORD_FAILED);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_PASSWORD_FAILED);
return MOD_CONT;
}
Anope::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());
+ notice_lang(Config.s_NickServ, u, NICK_SASET_PASSWORD_CHANGED_TO, u->Account()->display.c_str(), tmp_pass.c_str());
else
- notice_lang(Config.s_NickServ, u, NICK_SET_PASSWORD_CHANGED);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_PASSWORD_CHANGED, u->Account()->display.c_str());
Alog() << Config.s_NickServ << ": " << u->GetMask() << " (e-mail: " << (!u->Account()->email.empty() ? u->Account()->email : "none") << ") changed its password.";
return MOD_CONT;
diff --git a/modules/core/ns_set_autoop.cpp b/modules/core/ns_set_autoop.cpp
index 1e6e0d812..8e0c0a8ad 100644
--- a/modules/core/ns_set_autoop.cpp
+++ b/modules/core/ns_set_autoop.cpp
@@ -16,21 +16,27 @@
class CommandNSSetAutoOp : public Command
{
public:
- CommandNSSetAutoOp() : Command("AUTOOP", 1)
+ CommandNSSetAutoOp(const Anope::string &spermission = "") : Command("AUTOOP", 1, 2, spermission)
{
}
CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
{
- if (params[0].equals_ci("ON"))
+ NickCore *nc = findcore(params[0]);
+ if (!nc)
+ throw CoreException("NULL nc in CommandNSSetAutoOp");
+
+ Anope::string param = params.size() > 1 ? params[1] : "";
+
+ if (param.equals_ci("ON"))
{
- u->Account()->SetFlag(NI_AUTOOP);
- notice_lang(Config.s_NickServ, u, NICK_SET_AUTOOP_ON);
+ nc->SetFlag(NI_AUTOOP);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_AUTOOP_ON, nc->display.c_str());
}
- else if (params[0].equals_ci("OFF"))
+ else if (param.equals_ci("OFF"))
{
- u->Account()->UnsetFlag(NI_AUTOOP);
- notice_lang(Config.s_NickServ, u, NICK_SET_AUTOOP_OFF);
+ nc->UnsetFlag(NI_AUTOOP);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_AUTOOP_OFF, nc->display.c_str());
}
else
this->OnSyntaxError(u, "AUTOOP");
@@ -55,35 +61,11 @@ class CommandNSSetAutoOp : public Command
}
};
-class CommandNSSASetAutoOp : public Command
+class CommandNSSASetAutoOp : public CommandNSSetAutoOp
{
public:
- CommandNSSASetAutoOp() : Command("AUTOOP", 2, 2, "nickserv/saset/autoop")
- {
- }
-
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandNSSASetAutoOp() : CommandNSSetAutoOp("nickserv/saset/autoop")
{
- NickCore *nc = findcore(params[0]);
- if (!nc)
- throw CoreException("NULL nc in CommandNSSASetAutoOp");
-
- Anope::string param = params[1];
-
- if (param.equals_ci("ON"))
- {
- nc->SetFlag(NI_AUTOOP);
- notice_lang(Config.s_NickServ, u, NICK_SASET_AUTOOP_ON, nc->display.c_str());
- }
- else if (param.equals_ci("OFF"))
- {
- nc->UnsetFlag(NI_AUTOOP);
- notice_lang(Config.s_NickServ, u, NICK_SASET_AUTOOP_OFF, nc->display.c_str());
- }
- else
- this->OnSyntaxError(u, "AUTOOP");
-
- return MOD_CONT;
}
bool Help(User *u, const Anope::string &)
diff --git a/modules/core/ns_set_email.cpp b/modules/core/ns_set_email.cpp
index 8b10f01ad..6b52dc011 100644
--- a/modules/core/ns_set_email.cpp
+++ b/modules/core/ns_set_email.cpp
@@ -16,55 +16,7 @@
class CommandNSSetEmail : public Command
{
public:
- CommandNSSetEmail() : Command("EMAIL", 0)
- {
- }
-
- CommandReturn Execute(User *u, const std::vector<Anope::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]))
- {
- 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.empty() ? u->Account()->email : "none") << ") changed its e-mail to " << (!params.empty() ? params[0] : "none");
-
- if (!params.empty())
- {
- u->Account()->email = params[0];
- notice_lang(Config.s_NickServ, u, NICK_SET_EMAIL_CHANGED, params[0].c_str());
- }
- else
- {
- u->Account()->email.clear();
- notice_lang(Config.s_NickServ, u, NICK_SET_EMAIL_UNSET);
- }
-
- return MOD_CONT;
- }
-
- bool OnHelp(User *u, const Anope::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() : Command("EMAIL", 1, 2, "nickserv/saset/email")
+ CommandNSSetEmail(const Anope::string &spermission = "") : Command("EMAIL", 1, 2, spermission)
{
}
@@ -72,7 +24,7 @@ class CommandNSSASetEmail : public Command
{
NickCore *nc = findcore(params[0]);
if (!nc)
- throw CoreException("NULL nc in CommandNSSASetEmail");
+ throw CoreException("NULL nc in CommandNSSetEmail");
Anope::string param = params.size() > 1 ? params[1] : "";
@@ -92,7 +44,7 @@ class CommandNSSASetEmail : public Command
return MOD_CONT;
}
- Alog() << Config.s_NickServ << ": " << u->GetMask() << " used SASET EMAIL on " << nc->display << " (e-mail: " << (!nc->email.empty() ? nc->email : "none") << ")";
+ Alog() << Config.s_NickServ << ": " << u->GetMask() << " (e-mail: " << (!u->Account()->email.empty() ? u->Account()->email : "none") << ") changed the e-mail of " << nc->display << " to " << (!param.empty() ? param : "none");
if (!param.empty())
{
@@ -110,6 +62,25 @@ class CommandNSSASetEmail : public Command
bool OnHelp(User *u, const Anope::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 CommandNSSetEmail
+{
+ public:
+ CommandNSSASetEmail() : CommandNSSetEmail("nickserv/saset/email")
+ {
+ }
+
+ bool OnHelp(User *u, const Anope::string &)
+ {
notice_help(Config.s_NickServ, u, NICK_HELP_SASET_EMAIL);
return true;
}
diff --git a/modules/core/ns_set_greet.cpp b/modules/core/ns_set_greet.cpp
index d807f3afc..effa0d64f 100644
--- a/modules/core/ns_set_greet.cpp
+++ b/modules/core/ns_set_greet.cpp
@@ -16,21 +16,27 @@
class CommandNSSetGreet : public Command
{
public:
- CommandNSSetGreet() : Command("GREET", 0)
+ CommandNSSetGreet(const Anope::string &spermission = "") : Command("GREET", 1, 2, spermission)
{
}
CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
{
- if (!params.empty())
+ NickCore *nc = findcore(params[0]);
+ if (!nc)
+ throw CoreException("NULL nc in CommandNSSetGreet");
+
+ Anope::string param = params.size() > 1 ? params[1] : "";
+
+ if (!param.empty())
{
- u->Account()->greet = params[0];
- notice_lang(Config.s_NickServ, u, NICK_SET_GREET_CHANGED, u->Account()->greet.c_str());
+ nc->greet = param;
+ notice_lang(Config.s_NickServ, u, NICK_SASET_GREET_CHANGED, nc->display.c_str(), nc->greet.c_str());
}
else
{
- u->Account()->greet.clear();
- notice_lang(Config.s_NickServ, u, NICK_SET_GREET_UNSET);
+ nc->greet.clear();
+ notice_lang(Config.s_NickServ, u, NICK_SASET_GREET_UNSET, nc->display.c_str());
}
return MOD_CONT;
@@ -48,33 +54,11 @@ class CommandNSSetGreet : public Command
}
};
-class CommandNSSASetGreet : public Command
+class CommandNSSASetGreet : public CommandNSSetGreet
{
public:
- CommandNSSASetGreet() : Command("GREET", 1, 2, "nickserv/saset/greet")
- {
- }
-
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandNSSASetGreet() : CommandNSSetGreet("nickserv/saset/greet")
{
- NickCore *nc = findcore(params[0]);
- if (!nc)
- throw CoreException("NULL nc in CommandNSSASetGreet");
-
- Anope::string param = params.size() > 1 ? params[1] : "";
-
- if (!param.empty())
- {
- nc->greet = param;
- notice_lang(Config.s_NickServ, u, NICK_SASET_GREET_CHANGED, nc->display.c_str(), nc->greet.c_str());
- }
- else
- {
- nc->greet.clear();
- notice_lang(Config.s_NickServ, u, NICK_SASET_GREET_UNSET, nc->display.c_str());
- }
-
- return MOD_CONT;
}
bool OnHelp(User *u, const Anope::string &)
diff --git a/modules/core/ns_set_hide.cpp b/modules/core/ns_set_hide.cpp
index 7cfef2dc7..631df77bb 100644
--- a/modules/core/ns_set_hide.cpp
+++ b/modules/core/ns_set_hide.cpp
@@ -16,38 +16,45 @@
class CommandNSSetHide : public Command
{
public:
- CommandNSSetHide() : Command("HIDE", 2)
+ CommandNSSetHide(const Anope::string &spermission = "") : Command("HIDE", 2, 3, spermission)
{
}
CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
{
+ NickCore *nc = findcore(params[0]);
+ if (!nc)
+ throw CoreException("NULL nc in CommandNSSetHide");
+
int onmsg, offmsg;
NickCoreFlag flag;
- if (params[0].equals_ci("EMAIL"))
+ Anope::string param = params[1];
+ Anope::string arg = params.size() > 2 ? params[2] : "";
+
+ if (param.equals_ci("EMAIL"))
{
flag = NI_HIDE_EMAIL;
- onmsg = NICK_SET_HIDE_EMAIL_ON;
- offmsg = NICK_SET_HIDE_EMAIL_OFF;
+ onmsg = NICK_SASET_HIDE_EMAIL_ON;
+ offmsg = NICK_SASET_HIDE_EMAIL_OFF;
}
- else if (params[0].equals_ci("USERMASK"))
+ else if (param.equals_ci("USERMASK"))
{
flag = NI_HIDE_MASK;
- onmsg = NICK_SET_HIDE_MASK_ON;
- offmsg = NICK_SET_HIDE_MASK_OFF;
+ onmsg = NICK_SASET_HIDE_MASK_ON;
+ offmsg = NICK_SASET_HIDE_MASK_OFF;
}
- else if (params[0].equals_ci("STATUS"))
+ else if (param.equals_ci("STATUS"))
{
flag = NI_HIDE_STATUS;
- onmsg = NICK_SET_HIDE_STATUS_ON;
- offmsg = NICK_SET_HIDE_STATUS_OFF;
+ onmsg = NICK_SASET_HIDE_STATUS_ON;
+ offmsg = NICK_SASET_HIDE_STATUS_OFF;
}
- else if (params[0].equals_ci("QUIT"))
+ else if (param.equals_ci("QUIT"))
{
flag = NI_HIDE_QUIT;
- onmsg = NICK_SET_HIDE_QUIT_ON;
- offmsg = NICK_SET_HIDE_QUIT_OFF;
+ onmsg = NICK_SASET_HIDE_QUIT_ON;
+ offmsg = NICK_SASET_HIDE_QUIT_OFF;
}
else
{
@@ -55,15 +62,15 @@ class CommandNSSetHide : public Command
return MOD_CONT;
}
- if (params[1].equals_ci("ON"))
+ if (arg.equals_ci("ON"))
{
- u->Account()->SetFlag(flag);
- notice_lang(Config.s_NickServ, u, onmsg, Config.s_NickServ.c_str());
+ nc->SetFlag(flag);
+ notice_lang(Config.s_NickServ, u, onmsg, nc->display.c_str(), Config.s_NickServ.c_str());
}
- else if (params[1].equals_ci("OFF"))
+ else if (arg.equals_ci("OFF"))
{
- u->Account()->UnsetFlag(flag);
- notice_lang(Config.s_NickServ, u, offmsg, Config.s_NickServ.c_str());
+ nc->UnsetFlag(flag);
+ notice_lang(Config.s_NickServ, u, offmsg, nc->display.c_str(), Config.s_NickServ.c_str());
}
else
this->OnSyntaxError(u, "HIDE");
@@ -88,71 +95,11 @@ class CommandNSSetHide : public Command
}
};
-class CommandNSSASetHide : public Command
+class CommandNSSASetHide : public CommandNSSetHide
{
public:
- CommandNSSASetHide() : Command("HIDE", 3, 3, "nickserv/saset/command")
- {
- }
-
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandNSSASetHide() : CommandNSSetHide("nickserv/saset/command")
{
- NickCore *nc = findcore(params[0]);
- if (!nc)
- throw CoreException("NULL nc in CommandNSSASetHide");
-
- Anope::string param = params[1];
-
- int onmsg, offmsg;
- NickCoreFlag flag;
-
- if (param.equals_ci("EMAIL"))
- {
- flag = NI_HIDE_EMAIL;
- onmsg = NICK_SASET_HIDE_EMAIL_ON;
- offmsg = NICK_SASET_HIDE_EMAIL_OFF;
- }
- else if (param.equals_ci("USERMASK"))
- {
- flag = NI_HIDE_MASK;
- onmsg = NICK_SASET_HIDE_MASK_ON;
- offmsg = NICK_SASET_HIDE_MASK_OFF;
- }
- else if (param.equals_ci("STATUS"))
- {
- flag = NI_HIDE_STATUS;
- onmsg = NICK_SASET_HIDE_STATUS_ON;
- offmsg = NICK_SASET_HIDE_STATUS_OFF;
- }
- else if (param.equals_ci("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.equals_ci("ON"))
- {
- nc->SetFlag(flag);
- notice_lang(Config.s_NickServ, u, onmsg, nc->display.c_str(), Config.s_NickServ.c_str());
- }
- else if (param.equals_ci("OFF"))
- {
- nc->UnsetFlag(flag);
- notice_lang(Config.s_NickServ, u, offmsg, nc->display.c_str(), Config.s_NickServ.c_str());
- }
- else
- this->OnSyntaxError(u, "HIDE");
-
- return MOD_CONT;
}
bool OnHelp(User *u, const Anope::string &)
diff --git a/modules/core/ns_set_kill.cpp b/modules/core/ns_set_kill.cpp
index 5293625cb..c85570d87 100644
--- a/modules/core/ns_set_kill.cpp
+++ b/modules/core/ns_set_kill.cpp
@@ -16,72 +16,7 @@
class CommandNSSetKill : public Command
{
public:
- CommandNSSetKill() : Command("KILL", 1)
- {
- }
-
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
- {
- if (params[0].equals_ci("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].equals_ci("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].equals_ci("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].equals_ci("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 Anope::string &)
- {
- notice_help(Config.s_NickServ, u, NICK_HELP_SET_KILL);
- return true;
- }
-
- void OnSyntaxError(User *u, const Anope::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() : Command("KILL", 2, 2, "nickserv/saset/kill")
+ CommandNSSetKill(const Anope::string &spermission = "") : Command("KILL", 2, 3, spermission)
{
}
@@ -89,9 +24,10 @@ class CommandNSSASetKill : public Command
{
NickCore *nc = findcore(params[0]);
if (!nc)
- throw CoreException("NULL nc in CommandNSSASetKill");
+ throw CoreException("NULL nc in CommandNSSetKill");
Anope::string param = params[1];
+ Anope::string arg = params.size() > 2 ? params[2] : "";
if (param.equals_ci("ON"))
{
@@ -134,6 +70,30 @@ class CommandNSSASetKill : public Command
bool OnHelp(User *u, const Anope::string &)
{
+ notice_help(Config.s_NickServ, u, NICK_HELP_SET_KILL);
+ return true;
+ }
+
+ void OnSyntaxError(User *u, const Anope::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 CommandNSSetKill
+{
+ public:
+ CommandNSSASetKill() : CommandNSSetKill("nickserv/saset/kill")
+ {
+ }
+
+ bool OnHelp(User *u, const Anope::string &)
+ {
notice_help(Config.s_NickServ, u, NICK_HELP_SASET_KILL);
return true;
}
diff --git a/modules/core/ns_set_language.cpp b/modules/core/ns_set_language.cpp
index 6535376e5..844826204 100644
--- a/modules/core/ns_set_language.cpp
+++ b/modules/core/ns_set_language.cpp
@@ -16,13 +16,17 @@
class CommandNSSetLanguage : public Command
{
public:
- CommandNSSetLanguage() : Command("LANGUAGE", 1)
+ CommandNSSetLanguage(const Anope::string &spermission = "") : Command("LANGUAGE", 2, 2, spermission)
{
}
CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
{
- Anope::string param = params[0];
+ NickCore *nc = findcore(params[0]);
+ if (!nc)
+ throw CoreException("NULL nc in CommandNSSetLanguage");
+
+ Anope::string param = params[1];
if (param.find_first_not_of("0123456789") != Anope::string::npos) /* i.e. not a number */
{
@@ -37,8 +41,8 @@ class CommandNSSetLanguage : public Command
return MOD_CONT;
}
- u->Account()->language = langlist[langnum];
- notice_lang(Config.s_NickServ, u, NICK_SET_LANGUAGE_CHANGED);
+ nc->language = langlist[langnum];
+ notice_lang(Config.s_NickServ, u, NICK_SASET_LANGUAGE_CHANGED);
return MOD_CONT;
}
@@ -60,36 +64,11 @@ class CommandNSSetLanguage : public Command
}
};
-class CommandNSSASetLanguage : public Command
+class CommandNSSASetLanguage : public CommandNSSetLanguage
{
public:
- CommandNSSASetLanguage() : Command("LANGUAGE", 2, 2, "nickserv/saset/language")
- {
- }
-
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandNSSASetLanguage() : CommandNSSetLanguage("nickserv/saset/language")
{
- NickCore *nc = findcore(params[0]);
- if (!nc)
- throw CoreException("NULL nc in CommandNSSASetLanguage");
-
- Anope::string param = params[1];
-
- if (param.find_first_not_of("0123456789") != Anope::string::npos) /* i.e. not a number */
- {
- this->OnSyntaxError(u, "LANGUAGE");
- return MOD_CONT;
- }
- int langnum = convertTo<int>(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.c_str());
- 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 Anope::string &)
diff --git a/modules/core/ns_set_message.cpp b/modules/core/ns_set_message.cpp
index 45b6bbc91..2152777f6 100644
--- a/modules/core/ns_set_message.cpp
+++ b/modules/core/ns_set_message.cpp
@@ -16,27 +16,33 @@
class CommandNSSetMessage : public Command
{
public:
- CommandNSSetMessage() : Command("MESSAGE", 1)
+ CommandNSSetMessage(const Anope::string &spermission = "") : Command("MSG", 2, 2, spermission)
{
}
CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
{
+ NickCore *nc = findcore(params[0]);
+ if (!nc)
+ throw CoreException("NULL nc in CommandNSSetMessage");
+
if (!Config.UsePrivmsg)
{
- notice_lang(Config.s_NickServ, u, NICK_SET_OPTION_DISABLED, "MSG");
+ notice_lang(Config.s_NickServ, u, NICK_SASET_OPTION_DISABLED, "MSG");
return MOD_CONT;
}
- if (params[0].equals_ci("ON"))
+ Anope::string param = params.size() > 1 ? params[1] : "";
+
+ if (param.equals_ci("ON"))
{
- u->Account()->SetFlag(NI_MSG);
- notice_lang(Config.s_NickServ, u, NICK_SET_MSG_ON);
+ nc->SetFlag(NI_MSG);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_MSG_ON, nc->display.c_str());
}
- else if (params[0].equals_ci("OFF"))
+ else if (param.equals_ci("OFF"))
{
- u->Account()->UnsetFlag(NI_MSG);
- notice_lang(Config.s_NickServ, u, NICK_SET_MSG_OFF);
+ nc->UnsetFlag(NI_MSG);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_MSG_OFF, nc->display.c_str());
}
else
this->OnSyntaxError(u, "MSG");
@@ -61,41 +67,11 @@ class CommandNSSetMessage : public Command
}
};
-class CommandNSSASetMessage : public Command
+class CommandNSSASetMessage : public CommandNSSetMessage
{
public:
- CommandNSSASetMessage() : Command("MESSAGE", 2, 2, "nickserv/saset/message")
- {
- }
-
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandNSSASetMessage() : CommandNSSetMessage("nickserv/saset/message")
{
- NickCore *nc = findcore(params[0]);
- if (!nc)
- throw CoreException("NULL nc in CommandNSSASetMessage");
-
- Anope::string param = params[1];
-
- if (!Config.UsePrivmsg)
- {
- notice_lang(Config.s_NickServ, u, NICK_SASET_OPTION_DISABLED, "MSG");
- return MOD_CONT;
- }
-
- if (param.equals_ci("ON"))
- {
- nc->SetFlag(NI_MSG);
- notice_lang(Config.s_NickServ, u, NICK_SASET_MSG_ON, nc->display.c_str());
- }
- else if (param.equals_ci("OFF"))
- {
- nc->UnsetFlag(NI_MSG);
- notice_lang(Config.s_NickServ, u, NICK_SASET_MSG_OFF, nc->display.c_str());
- }
- else
- this->OnSyntaxError(u, "MSG");
-
- return MOD_CONT;
}
bool OnHelp(User *u, const Anope::string &)
diff --git a/modules/core/ns_set_private.cpp b/modules/core/ns_set_private.cpp
index dabfaa09f..776d8fcad 100644
--- a/modules/core/ns_set_private.cpp
+++ b/modules/core/ns_set_private.cpp
@@ -16,21 +16,27 @@
class CommandNSSetPrivate : public Command
{
public:
- CommandNSSetPrivate() : Command("PRIVATE", 1)
+ CommandNSSetPrivate(const Anope::string &spermission = "") : Command("PRIVATE", 2, 2, spermission)
{
}
CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
{
- if (params[0].equals_ci("ON"))
+ NickCore *nc = findcore(params[0]);
+ if (!nc)
+ throw CoreException("NULL nc in CommandNSSetPrivate");
+
+ Anope::string param = params[1];
+
+ if (param.equals_ci("ON"))
{
- u->Account()->SetFlag(NI_PRIVATE);
- notice_lang(Config.s_NickServ, u, NICK_SET_PRIVATE_ON);
+ nc->SetFlag(NI_PRIVATE);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_PRIVATE_ON, nc->display.c_str());
}
- else if (params[0].equals_ci("OFF"))
+ else if (param.equals_ci("OFF"))
{
- u->Account()->UnsetFlag(NI_PRIVATE);
- notice_lang(Config.s_NickServ, u, NICK_SET_PRIVATE_OFF);
+ nc->UnsetFlag(NI_PRIVATE);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_PRIVATE_OFF, nc->display.c_str());
}
else
this->OnSyntaxError(u, "PRIVATE");
@@ -55,35 +61,11 @@ class CommandNSSetPrivate : public Command
}
};
-class CommandNSSASetPrivate : public Command
+class CommandNSSASetPrivate : public CommandNSSetPrivate
{
public:
- CommandNSSASetPrivate() : Command("PRIVATE", 2, 2, "nickserv/saset/private")
- {
- }
-
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandNSSASetPrivate() : CommandNSSetPrivate("nickserv/saset/private")
{
- NickCore *nc = findcore(params[0]);
- if (!nc)
- throw CoreException("NULL nc in CommandNSSASetPrivate");
-
- Anope::string param = params[1];
-
- if (param.equals_ci("ON"))
- {
- nc->SetFlag(NI_PRIVATE);
- notice_lang(Config.s_NickServ, u, NICK_SASET_PRIVATE_ON, nc->display.c_str());
- }
- else if (param.equals_ci("OFF"))
- {
- nc->UnsetFlag(NI_PRIVATE);
- notice_lang(Config.s_NickServ, u, NICK_SASET_PRIVATE_OFF, nc->display.c_str());
- }
- else
- this->OnSyntaxError(u, "PRIVATE");
-
- return MOD_CONT;
}
bool OnHelp(User *u, const Anope::string &)
diff --git a/modules/core/ns_set_secure.cpp b/modules/core/ns_set_secure.cpp
index bfaddce48..035140bf7 100644
--- a/modules/core/ns_set_secure.cpp
+++ b/modules/core/ns_set_secure.cpp
@@ -16,21 +16,27 @@
class CommandNSSetSecure : public Command
{
public:
- CommandNSSetSecure() : Command("SECURE", 1)
+ CommandNSSetSecure(const Anope::string &cpermission = "") : Command("SECURE", 2, 2, cpermission)
{
}
CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
{
- if (params[0].equals_ci("ON"))
+ NickCore *nc = findcore(params[0]);
+ if (!nc)
+ throw CoreException("NULL nc in CommandNSSetSecure");
+
+ Anope::string param = params[1];
+
+ if (param.equals_ci("ON"))
{
- u->Account()->SetFlag(NI_SECURE);
- notice_lang(Config.s_NickServ, u, NICK_SET_SECURE_ON);
+ nc->SetFlag(NI_SECURE);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_SECURE_ON, nc->display.c_str());
}
- else if (params[0].equals_ci("OFF"))
+ else if (param.equals_ci("OFF"))
{
- u->Account()->UnsetFlag(NI_SECURE);
- notice_lang(Config.s_NickServ, u, NICK_SET_SECURE_OFF);
+ nc->UnsetFlag(NI_SECURE);
+ notice_lang(Config.s_NickServ, u, NICK_SASET_SECURE_OFF, nc->display.c_str());
}
else
this->OnSyntaxError(u, "SECURE");
@@ -55,35 +61,11 @@ class CommandNSSetSecure : public Command
}
};
-class CommandNSSASetSecure : public Command
+class CommandNSSASetSecure : public CommandNSSetSecure
{
public:
- CommandNSSASetSecure() : Command("SECURE", 2, 2, "nickserv/saset/secure")
- {
- }
-
- CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
+ CommandNSSASetSecure() : CommandNSSetSecure("nickserv/saset/secure")
{
- NickCore *nc = findcore(params[0]);
- if (!nc)
- throw CoreException("NULL nc in CommandNSSASetSecure");
-
- Anope::string param = params[1];
-
- if (param.equals_ci("ON"))
- {
- nc->SetFlag(NI_SECURE);
- notice_lang(Config.s_NickServ, u, NICK_SASET_SECURE_ON, nc->display.c_str());
- }
- else if (param.equals_ci("OFF"))
- {
- nc->UnsetFlag(NI_SECURE);
- notice_lang(Config.s_NickServ, u, NICK_SASET_SECURE_OFF, nc->display.c_str());
- }
- else
- this->OnSyntaxError(u, "SECURE");
-
- return MOD_CONT;
}
bool OnHelp(User *u, const Anope::string &)