summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-06-25 11:02:19 -0400
committerAdam <Adam@anope.org>2014-06-25 11:02:19 -0400
commitee3289029d61da12013e0f5a3e4faf2d07543a0e (patch)
treedf7391c321a913fc56db2d075292c0a6ddb0536d /modules
parentfd9bb0ea7e3c8a39f1632c2ebbdc25d0fac192a0 (diff)
Remove the rest of the 1.8 logic "let's write all of the command handler with no return statement!"
Fix if (something) else if (!something) tests Remove returns at the bottom of void functions
Diffstat (limited to 'modules')
-rw-r--r--modules/commands/bs_badwords.cpp19
-rw-r--r--modules/commands/bs_bot.cpp4
-rw-r--r--modules/commands/bs_botlist.cpp15
-rw-r--r--modules/commands/bs_info.cpp2
-rw-r--r--modules/commands/cs_access.cpp54
-rw-r--r--modules/commands/cs_akick.cpp19
-rw-r--r--modules/commands/cs_enforce.cpp18
-rw-r--r--modules/commands/cs_flags.cpp12
-rw-r--r--modules/commands/cs_log.cpp44
-rw-r--r--modules/commands/cs_register.cpp107
-rw-r--r--modules/commands/cs_updown.cpp8
-rw-r--r--modules/commands/cs_xop.cpp6
-rw-r--r--modules/commands/help.cpp14
-rw-r--r--modules/commands/hs_del.cpp40
-rw-r--r--modules/commands/hs_group.cpp21
-rw-r--r--modules/commands/hs_off.cpp13
-rw-r--r--modules/commands/hs_on.cpp27
-rw-r--r--modules/commands/hs_request.cpp72
-rw-r--r--modules/commands/ms_del.cpp52
-rw-r--r--modules/commands/ms_list.cpp121
-rw-r--r--modules/commands/ms_read.cpp57
-rw-r--r--modules/commands/ms_rsend.cpp1
-rw-r--r--modules/commands/ms_set.cpp2
-rw-r--r--modules/commands/ns_ajoin.cpp40
-rw-r--r--modules/commands/ns_drop.cpp21
-rw-r--r--modules/commands/ns_getpass.cpp28
-rw-r--r--modules/commands/ns_group.cpp143
-rw-r--r--modules/commands/ns_identify.cpp54
-rw-r--r--modules/commands/ns_info.cpp117
-rw-r--r--modules/commands/ns_logout.cpp47
-rw-r--r--modules/commands/ns_register.cpp197
-rw-r--r--modules/commands/ns_resetpass.cpp23
-rw-r--r--modules/commands/ns_set.cpp38
-rw-r--r--modules/commands/os_akill.cpp6
-rw-r--r--modules/commands/os_chankill.cpp59
-rw-r--r--modules/commands/os_defcon.cpp1
36 files changed, 856 insertions, 646 deletions
diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp
index 5e9dd363a..a29209e31 100644
--- a/modules/commands/bs_badwords.cpp
+++ b/modules/commands/bs_badwords.cpp
@@ -245,19 +245,20 @@ class CommandBSBadwords : public Command
}
if (list.IsEmpty())
- source.Reply(_("No matching entries on the bad word list of \002{0}\002."), ci->name);
- else
{
- std::vector<Anope::string> replies;
- list.Process(replies);
+ source.Reply(_("No matching entries on the bad word list of \002{0}\002."), ci->name);
+ return;
+ }
- source.Reply(_("Bad words list for \002{0}\002:"), ci->name);
+ std::vector<Anope::string> replies;
+ list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ source.Reply(_("Bad words list for \002{0}\002:"), ci->name);
- source.Reply(_("End of bad words list."));
- }
+ for (unsigned i = 0; i < replies.size(); ++i)
+ source.Reply(replies[i]);
+
+ source.Reply(_("End of bad words list."));
}
void DoAdd(CommandSource &source, ChanServ::Channel *ci, const Anope::string &word)
diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp
index f4beba6e6..79c23a764 100644
--- a/modules/commands/bs_bot.cpp
+++ b/modules/commands/bs_bot.cpp
@@ -76,7 +76,7 @@ class CommandBSBot : public Command
NickServ::Nick *na = NickServ::FindNick(nick);
if (na)
{
- source.Reply(_("Nickname \002{0}\002 is already registered!"), na->nick);
+ source.Reply(_("\002{0}\002 is already registered!"), na->nick);
return;
}
@@ -188,7 +188,7 @@ class CommandBSBot : public Command
NickServ::Nick *na = NickServ::FindNick(nick);
if (na)
{
- source.Reply(_("Nickname \002{0}\002 is already registered."), na->nick);
+ source.Reply(_("\002{0}\002 is already registered."), na->nick);
return;
}
diff --git a/modules/commands/bs_botlist.cpp b/modules/commands/bs_botlist.cpp
index 85855bb82..58b763d47 100644
--- a/modules/commands/bs_botlist.cpp
+++ b/modules/commands/bs_botlist.cpp
@@ -44,16 +44,17 @@ class CommandBSBotList : public Command
list.Process(replies);
if (!count)
- source.Reply(_("There are no bots available at this time."));
- else
{
- source.Reply(_("Bot list:"));
+ source.Reply(_("There are no bots available"));
+ return;
+ }
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ source.Reply(_("Bot list:"));
- source.Reply(_("{0} bots available."), count);
- }
+ for (unsigned i = 0; i < replies.size(); ++i)
+ source.Reply(replies[i]);
+
+ source.Reply(_("{0} bots available."), count);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/bs_info.cpp b/modules/commands/bs_info.cpp
index 677dfaaf6..4d7bc0765 100644
--- a/modules/commands/bs_info.cpp
+++ b/modules/commands/bs_info.cpp
@@ -81,7 +81,7 @@ class CommandBSInfo : public Command
source.Reply(replies[i]);
}
else
- source.Reply(_("\002{0}\002 is not a valid bot or registered channel."), query.c_str());
+ source.Reply(_("\002{0}\002 is not a valid bot or registered channel."), query);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp
index a1153cac6..5f38dc09a 100644
--- a/modules/commands/cs_access.cpp
+++ b/modules/commands/cs_access.cpp
@@ -437,20 +437,20 @@ class CommandCSAccess : public Command
}
if (list.IsEmpty())
- source.Reply(_("No matching entries on the access list of \002{0}\002."), ci->name);
- else
{
- std::vector<Anope::string> replies;
- list.Process(replies);
+ source.Reply(_("No matching entries on the access list of \002{0}\002."), ci->name);
+ return;
+ }
- source.Reply(_("Access list for \002{0}\002:"), ci->name);
+ std::vector<Anope::string> replies;
+ list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ source.Reply(_("Access list for \002{0}\002:"), ci->name);
- source.Reply(_("End of access list"));
- }
+ for (unsigned i = 0; i < replies.size(); ++i)
+ source.Reply(replies[i]);
+ source.Reply(_("End of access list."));
}
void DoList(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> &params)
@@ -546,12 +546,24 @@ class CommandCSAccess : public Command
* If DEL, we require a nick and no level.
* Else (ADD), we require a level (which implies a nick). */
if (is_list || is_clear ? 0 : (cmd.equals_ci("DEL") ? (nick.empty() || !s.empty()) : s.empty()))
+ {
this->OnSyntaxError(source, cmd);
- else if (!has_access)
+ return;
+ }
+
+ if (!has_access)
+ {
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), is_list ? "ACCESS_LIST" : "ACCESS_CHANGE", ci->name);
- else if (Anope::ReadOnly && !is_list)
+ return;
+ }
+
+ if (Anope::ReadOnly && !is_list)
+ {
source.Reply(_("Sorry, channel access list modification is temporarily disabled."));
- else if (cmd.equals_ci("ADD"))
+ return;
+ }
+
+ if (cmd.equals_ci("ADD"))
this->DoAdd(source, ci, params);
else if (cmd.equals_ci("DEL"))
this->DoDel(source, ci, params);
@@ -813,12 +825,24 @@ class CommandCSLevels : public Command
* one; else, we want none.
*/
if (cmd.equals_ci("SET") ? s.empty() : (cmd.substr(0, 3).equals_ci("DIS") ? (what.empty() || !s.empty()) : !what.empty()))
+ {
this->OnSyntaxError(source, cmd);
- else if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasPriv("chanserv/access/modify"))
+ return;
+ }
+
+ if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasPriv("chanserv/access/modify"))
+ {
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "FOUNDER", ci->name);
- else if (Anope::ReadOnly && !cmd.equals_ci("LIST"))
+ return;
+ }
+
+ if (Anope::ReadOnly && !cmd.equals_ci("LIST"))
+ {
source.Reply(_("Services are in read-only mode."));
- else if (cmd.equals_ci("SET"))
+ return;
+ }
+
+ if (cmd.equals_ci("SET"))
this->DoSet(source, ci, params);
else if (cmd.equals_ci("DIS") || cmd.equals_ci("DISABLE"))
this->DoDisable(source, ci, params);
diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp
index 435373810..9f69810fc 100644
--- a/modules/commands/cs_akick.cpp
+++ b/modules/commands/cs_akick.cpp
@@ -418,19 +418,20 @@ class CommandCSAKick : public Command
}
if (list.IsEmpty())
- source.Reply(_("No matching entries on %s autokick list."), ci->name.c_str());
- else
{
- std::vector<Anope::string> replies;
- list.Process(replies);
+ source.Reply(_("No matching entries on %s autokick list."), ci->name.c_str());
+ return;
+ }
- source.Reply(_("Autokick list for %s:"), ci->name.c_str());
+ std::vector<Anope::string> replies;
+ list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ source.Reply(_("Autokick list for %s:"), ci->name.c_str());
- source.Reply(_("End of autokick list"));
- }
+ for (unsigned i = 0; i < replies.size(); ++i)
+ source.Reply(replies[i]);
+
+ source.Reply(_("End of autokick list"));
}
void DoList(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> &params)
diff --git a/modules/commands/cs_enforce.cpp b/modules/commands/cs_enforce.cpp
index 64ef9ab0d..80abed196 100644
--- a/modules/commands/cs_enforce.cpp
+++ b/modules/commands/cs_enforce.cpp
@@ -235,12 +235,24 @@ class CommandCSEnforce : public Command
ChanServ::Channel *ci = ChanServ::Find(params[0]);
if (!ci)
+ {
source.Reply(_("Channel \002{0}\002 isn't registered."), params[0]);
- else if (!ci->c)
+ return;
+ }
+
+ if (!ci->c)
+ {
source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->name);
- else if (!source.AccessFor(ci).HasPriv("AKICK") && !source.HasPriv("chanserv/access/modify"))
+ return;
+ }
+
+ if (!source.AccessFor(ci).HasPriv("AKICK") && !source.HasPriv("chanserv/access/modify"))
+ {
source.Reply("Access denied. You do not have the \002{0}\002 privilege on \002{1}\002.", "AKICK", ci->name);
- else if (what.equals_ci("SECUREOPS"))
+ return;
+ }
+
+ if (what.equals_ci("SECUREOPS"))
this->DoSecureOps(source, ci);
else if (what.equals_ci("RESTRICTED"))
this->DoRestricted(source, ci);
diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp
index 7e17a1b47..ac03febb7 100644
--- a/modules/commands/cs_flags.cpp
+++ b/modules/commands/cs_flags.cpp
@@ -396,10 +396,18 @@ class CommandCSFlags : public Command
has_access = true;
if (!has_access)
+ {
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), is_list ? "ACCESS_LIST" : "ACCESS_CHANGE", ci->name);
- else if (Anope::ReadOnly && !is_list)
+ return;
+ }
+
+ if (Anope::ReadOnly && !is_list)
+ {
source.Reply(_("Sorry, channel access list modification is temporarily disabled."));
- else if (cmd.equals_ci("MODIFY"))
+ return;
+ }
+
+ if (cmd.equals_ci("MODIFY"))
this->DoModify(source, ci, params);
else if (is_list)
this->DoList(source, ci, params);
diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp
index 9fd1a2fdf..5c80448c2 100644
--- a/modules/commands/cs_log.cpp
+++ b/modules/commands/cs_log.cpp
@@ -129,33 +129,35 @@ public:
{
LogSettings *ls = ci->Require<LogSettings>("logsettings");
if (!ls || (*ls)->empty())
- source.Reply(_("There currently are no logging configurations for \002{0}\002."), ci->name);
- else
{
- ListFormatter list(source.GetAccount());
- list.AddColumn(_("Number")).AddColumn(_("Service")).AddColumn(_("Command")).AddColumn(_("Method")).AddColumn("");
+ source.Reply(_("There currently are no logging configurations for \002{0}\002."), ci->name);
+ return;
+ }
- for (unsigned i = 0; i < (*ls)->size(); ++i)
- {
- const LogSetting *log = (*ls)->at(i);
-
- ListFormatter::ListEntry entry;
- entry["Number"] = stringify(i + 1);
- entry["Service"] = log->command_service;
- entry["Command"] = !log->command_name.empty() ? log->command_name : log->service_name;
- entry["Method"] = log->method;
- entry[""] = log->extra;
- list.AddEntry(entry);
- }
- source.Reply(_("Log list for \002{0}\002:"), ci->name);
+ ListFormatter list(source.GetAccount());
+ list.AddColumn(_("Number")).AddColumn(_("Service")).AddColumn(_("Command")).AddColumn(_("Method")).AddColumn("");
- std::vector<Anope::string> replies;
- list.Process(replies);
+ for (unsigned i = 0; i < (*ls)->size(); ++i)
+ {
+ const LogSetting *log = (*ls)->at(i);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ ListFormatter::ListEntry entry;
+ entry["Number"] = stringify(i + 1);
+ entry["Service"] = log->command_service;
+ entry["Command"] = !log->command_name.empty() ? log->command_name : log->service_name;
+ entry["Method"] = log->method;
+ entry[""] = log->extra;
+ list.AddEntry(entry);
}
+
+ source.Reply(_("Log list for \002{0}\002:"), ci->name);
+
+ std::vector<Anope::string> replies;
+ list.Process(replies);
+
+ for (unsigned i = 0; i < replies.size(); ++i)
+ source.Reply(replies[i]);
}
else if (params.size() > 2)
{
diff --git a/modules/commands/cs_register.cpp b/modules/commands/cs_register.cpp
index 594babe2f..36803e608 100644
--- a/modules/commands/cs_register.cpp
+++ b/modules/commands/cs_register.cpp
@@ -24,66 +24,97 @@ class CommandCSRegister : public Command
{
const Anope::string &chan = params[0];
const Anope::string &chdesc = params.size() > 1 ? params[1] : "";
- unsigned maxregistered = Config->GetModule("chanserv")->Get<unsigned>("maxregistered");
User *u = source.GetUser();
NickServ::Account *nc = source.nc;
- Channel *c = Channel::Find(params[0]);
- ChanServ::Channel *ci = ChanServ::Find(params[0]);
if (Anope::ReadOnly)
+ {
source.Reply(_("Sorry, channel registration is temporarily disabled."));
- else if (nc->HasExt("UNCONFIRMED"))
+ return;
+ }
+
+ if (nc->HasExt("UNCONFIRMED"))
+ {
source.Reply(_("You must confirm your account before you can register a channel."));
- else if (chan[0] == '&')
+ return;
+ }
+
+ if (chan[0] == '&')
+ {
source.Reply(_("Local channels can not be registered."));
- else if (chan[0] != '#')
+ return;
+ }
+
+ if (chan[0] != '#')
+ {
source.Reply(_("Please use the symbol of \002#\002 when attempting to register."));
- else if (!IRCD->IsChannelValid(chan))
+ return;
+ }
+
+ if (!IRCD->IsChannelValid(chan))
+ {
source.Reply(_("Channel \002{0}\002 is not a valid channel."), chan);
- else if (!c && u)
+ return;
+ }
+
+ Channel *c = Channel::Find(params[0]);
+ if (!c && u)
+ {
source.Reply(_("Channel \002{0}\002 doesn't exist."), chan);
- else if (ci)
- source.Reply(_("Channel \002%s\002 is already registered!"), chan.c_str());
- else if (c && !c->HasUserStatus(u, "OP"))
+ return;
+ }
+
+ ChanServ::Channel *ci = ChanServ::Find(chan);
+ if (ci)
+ {
+ source.Reply(_("Channel \002{0}\002 is already registered!"), chan);
+ return;
+ }
+
+ if (c && !c->HasUserStatus(u, "OP"))
+ {
source.Reply(_("You must be a channel operator to register the channel."));
- else if (maxregistered && nc->channelcount >= maxregistered && !source.HasPriv("chanserv/no-register-limit"))
+ return;
+ }
+
+ unsigned maxregistered = Config->GetModule("chanserv")->Get<unsigned>("maxregistered");
+ if (maxregistered && nc->channelcount >= maxregistered && !source.HasPriv("chanserv/no-register-limit"))
{
if (nc->channelcount > maxregistered)
source.Reply(_("Sorry, you have already exceeded your limit of \002{0}\002 channels."), maxregistered);
else
source.Reply(_("Sorry, you have already reached your limit of \002{0}\002 channels."), maxregistered);
+ return;
}
- else
- {
- if (!ChanServ::service)
- return;
- ci = ChanServ::service->Create(chan);
- ci->SetFounder(nc);
- ci->desc = chdesc;
-
- if (c && !c->topic.empty())
- {
- ci->last_topic = c->topic;
- ci->last_topic_setter = c->topic_setter;
- ci->last_topic_time = c->topic_time;
- }
- else
- ci->last_topic_setter = source.service->nick;
- Log(LOG_COMMAND, source, this, ci);
- source.Reply(_("Channel \002{0}\002 registered under your account: \002{1}\002"), chan, nc->display);
+ if (!ChanServ::service)
+ return;
+ ci = ChanServ::service->Create(chan);
+ ci->SetFounder(nc);
+ ci->desc = chdesc;
- /* Implement new mode lock */
- if (c)
- {
- c->CheckModes();
- if (u)
- c->SetCorrectModes(u, true);
- }
+ if (c && !c->topic.empty())
+ {
+ ci->last_topic = c->topic;
+ ci->last_topic_setter = c->topic_setter;
+ ci->last_topic_time = c->topic_time;
+ }
+ else
+ ci->last_topic_setter = source.service->nick;
+
+ Log(LOG_COMMAND, source, this, ci);
+ source.Reply(_("Channel \002{0}\002 registered under your account: \002{1}\002"), chan, nc->display);
- Event::OnChanRegistered(&Event::ChanRegistered::OnChanRegistered, ci);
+ /* Implement new mode lock */
+ if (c)
+ {
+ c->CheckModes();
+ if (u)
+ c->SetCorrectModes(u, true);
}
+
+ Event::OnChanRegistered(&Event::ChanRegistered::OnChanRegistered, ci);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/cs_updown.cpp b/modules/commands/cs_updown.cpp
index 0e487ff6c..5339d7f73 100644
--- a/modules/commands/cs_updown.cpp
+++ b/modules/commands/cs_updown.cpp
@@ -90,12 +90,14 @@ class CommandCSUp : public Command
source.Reply(_("User \002{0}\002 isn't currently online."), nick);
return;
}
+
if (srcu && !srcu->FindChannel(c))
{
source.Reply(_("You must be in \002%s\002 to use this command."), c->name.c_str());
return;
}
- else if (!u->FindChannel(c))
+
+ if (!u->FindChannel(c))
{
source.Reply(_("You must be on channel \002{0}\002 to use this command."), c->name);
return;
@@ -201,12 +203,14 @@ class CommandCSDown : public Command
source.Reply(_("You must be on channel \002{0}\002 to use this command."), c->name);
return;
}
+
if (srcu && !srcu->FindChannel(c))
{
source.Reply(_("You must be in \002%s\002 to use this command."), c->name.c_str());
return;
}
- else if (!u->FindChannel(c))
+
+ if (!u->FindChannel(c))
{
source.Reply(_("\002%s\002 is not on channel %s."), u->nick, c->name);
return;
diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp
index c3b43cd3e..44af355ec 100644
--- a/modules/commands/cs_xop.cpp
+++ b/modules/commands/cs_xop.cpp
@@ -149,7 +149,8 @@ class CommandCSXOP : public Command
source.Reply(_("Channel \002{0}\002 isn't registered."), mask);
return;
}
- else if (ci == targ_ci)
+
+ if (ci == targ_ci)
{
source.Reply(_("You can't add a channel to its own access list."));
return;
@@ -165,7 +166,8 @@ class CommandCSXOP : public Command
source.Reply(_("Masks and unregistered users may not be on access lists."));
return;
}
- else if (mask.find_first_of("!*@") == Anope::string::npos && !na)
+
+ if (mask.find_first_of("!*@") == Anope::string::npos && !na)
{
User *targ = User::Find(mask, true);
if (targ != NULL)
diff --git a/modules/commands/help.cpp b/modules/commands/help.cpp
index 4d8ee27bb..fc367760b 100644
--- a/modules/commands/help.cpp
+++ b/modules/commands/help.cpp
@@ -14,8 +14,6 @@
class CommandHelp : public Command
{
- static const unsigned help_wrap_len = 40;
-
static CommandGroup *FindGroup(const Anope::string &name)
{
for (unsigned i = 0; i < Config->CommandGroups.size(); ++i)
@@ -108,20 +106,10 @@ class CommandHelp : public Command
for (std::list<Anope::string>::iterator it2 = it->second.begin(), it2_end = it->second.end(); it2 != it2_end; ++it2)
{
const Anope::string &c_name = *it2;
-
buf += ", " + c_name;
-
- if (buf.length() > help_wrap_len)
- {
- source.Reply(" {0}", buf.substr(2));
- buf.clear();
- }
}
if (buf.length() > 2)
- {
source.Reply(" {0}", buf.substr(2));
- buf.clear();
- }
}
if (!groups.empty())
{
@@ -156,6 +144,8 @@ class CommandHelp : public Command
const Anope::string &subcommand = params.size() > max ? params[max] : "";
source.command = it->first;
+
+ c->SendSyntax(source);
if (!c->OnHelp(source, subcommand))
continue;
diff --git a/modules/commands/hs_del.cpp b/modules/commands/hs_del.cpp
index 02727185e..907b3e12c 100644
--- a/modules/commands/hs_del.cpp
+++ b/modules/commands/hs_del.cpp
@@ -30,15 +30,16 @@ class CommandHSDel : public Command
const Anope::string &nick = params[0];
NickServ::Nick *na = NickServ::FindNick(nick);
- if (na)
+ if (!na)
{
- Log(LOG_ADMIN, source, this) << "for user " << na->nick;
- this->OnDeleteVhost(&Event::DeleteVhost::OnDeleteVhost, na);
- na->RemoveVhost();
- source.Reply(_("Vhost for \002{0}\002 has been removed."), na->nick);
- }
- else
source.Reply(_("\002{0}\002 isn't registered."), nick);
+ return;
+ }
+
+ Log(LOG_ADMIN, source, this) << "for user " << na->nick;
+ this->OnDeleteVhost(&Event::DeleteVhost::OnDeleteVhost, na);
+ na->RemoveVhost();
+ source.Reply(_("Vhost for \002{0}\002 has been removed."), na->nick);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
@@ -66,20 +67,21 @@ class CommandHSDelAll : public Command
const Anope::string &nick = params[0];
NickServ::Nick *na = NickServ::FindNick(nick);
- if (na)
+ if (!na)
{
- this->ondeletevhost(&Event::DeleteVhost::OnDeleteVhost, na);
- const NickServ::Account *nc = na->nc;
- for (unsigned i = 0; i < nc->aliases->size(); ++i)
- {
- na = nc->aliases->at(i);
- na->RemoveVhost();
- }
- Log(LOG_ADMIN, source, this) << "for all nicks in group " << nc->display;
- source.Reply(_("Vhosts for group \002{0}\002 have been removed."), nc->display);
- }
- else
source.Reply(_("\002{0}\002 isn't registered."), nick);
+ return;
+ }
+
+ this->ondeletevhost(&Event::DeleteVhost::OnDeleteVhost, na);
+ const NickServ::Account *nc = na->nc;
+ for (unsigned i = 0; i < nc->aliases->size(); ++i)
+ {
+ na = nc->aliases->at(i);
+ na->RemoveVhost();
+ }
+ Log(LOG_ADMIN, source, this) << "for all nicks in group " << nc->display;
+ source.Reply(_("Vhosts for group \002{0}\002 have been removed."), nc->display);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp
index 8b84d0f65..a3d68844b 100644
--- a/modules/commands/hs_group.cpp
+++ b/modules/commands/hs_group.cpp
@@ -52,16 +52,23 @@ class CommandHSGroup : public Command
}
NickServ::Nick *na = NickServ::FindNick(source.GetNick());
- if (na && source.GetAccount() == na->nc && na->HasVhost())
+ if (!na || na->nc != source.GetAccount())
{
- this->Sync(na);
- if (!na->GetVhostIdent().empty())
- source.Reply(_("All vhosts in the group \002{0}\002 have been set to \002{1}\002@\002{2}\002."), source.nc->display, na->GetVhostIdent(), na->GetVhostHost());
- else
- source.Reply(_("All vhosts in the group \002{0}\002 have been set to \002{1}\002."), source.nc->display, na->GetVhostHost());
+ source.Reply(_("Access denied."));
+ return;
}
- else
+
+ if (!na->HasVhost())
+ {
source.Reply(_("There is no vhost assigned to this nickname."));
+ return;
+ }
+
+ this->Sync(na);
+ if (!na->GetVhostIdent().empty())
+ source.Reply(_("All vhosts in the group \002{0}\002 have been set to \002{1}\002@\002{2}\002."), source.nc->display, na->GetVhostIdent(), na->GetVhostHost());
+ else
+ source.Reply(_("All vhosts in the group \002{0}\002 have been set to \002{1}\002."), source.nc->display, na->GetVhostHost());
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/hs_off.cpp b/modules/commands/hs_off.cpp
index 2d8c23b80..e847963d6 100644
--- a/modules/commands/hs_off.cpp
+++ b/modules/commands/hs_off.cpp
@@ -25,14 +25,15 @@ class CommandHSOff : public Command
User *u = source.GetUser();
const NickServ::Nick *na = NickServ::FindNick(u->nick);
- if (!na || !na->HasVhost())
- source.Reply(_("There is no vhost assigned to this nickname."));
- else
+ if (!na || !na->HasVhost() || na->nc != source.GetAccount())
{
- IRCD->SendVhostDel(u);
- Log(LOG_COMMAND, source, this) << "to disable their vhost";
- source.Reply(_("Your vhost was removed and the normal cloaking restored."));
+ source.Reply(_("There is no vhost assigned to this nickname."));
+ return;
}
+
+ IRCD->SendVhostDel(u);
+ Log(LOG_COMMAND, source, this) << "to disable their vhost";
+ source.Reply(_("Your vhost was removed and the normal cloaking restored."));
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/hs_on.cpp b/modules/commands/hs_on.cpp
index c9e686131..8ec26f565 100644
--- a/modules/commands/hs_on.cpp
+++ b/modules/commands/hs_on.cpp
@@ -27,21 +27,24 @@ class CommandHSOn : public Command
User *u = source.GetUser();
const NickServ::Nick *na = NickServ::FindNick(u->nick);
- if (na && u->Account() == na->nc && na->HasVhost())
+
+ if (!na || !na->HasVhost() || na->nc != u->Account())
{
- if (!na->GetVhostIdent().empty())
- source.Reply(_("Your vhost of \002{0}\002@\002{1}\002 is now activated."), na->GetVhostIdent(), na->GetVhostHost());
- else
- source.Reply(_("Your vhost of \002{0}\002 is now activated."), na->GetVhostHost());
- Log(LOG_COMMAND, source, this) << "to enable their vhost of " << (!na->GetVhostIdent().empty() ? na->GetVhostIdent() + "@" : "") << na->GetVhostHost();
- IRCD->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost());
- u->vhost = na->GetVhostHost();
- if (IRCD->CanSetVIdent && !na->GetVhostIdent().empty())
- u->SetVIdent(na->GetVhostIdent());
- u->UpdateHost();
+ source.Reply(_("There is no vhost assigned to this nickname."));
+ return;
}
+
+ if (!na->GetVhostIdent().empty())
+ source.Reply(_("Your vhost of \002{0}\002@\002{1}\002 is now activated."), na->GetVhostIdent(), na->GetVhostHost());
else
- source.Reply(_("There is no vhost assigned to this nickname."));
+ source.Reply(_("Your vhost of \002{0}\002 is now activated."), na->GetVhostHost());
+
+ Log(LOG_COMMAND, source, this) << "to enable their vhost of " << (!na->GetVhostIdent().empty() ? na->GetVhostIdent() + "@" : "") << na->GetVhostHost();
+ IRCD->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost());
+ u->vhost = na->GetVhostHost();
+ if (IRCD->CanSetVIdent && !na->GetVhostIdent().empty())
+ u->SetVIdent(na->GetVhostIdent());
+ u->UpdateHost();
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp
index 1d9207e05..d1fb0e640 100644
--- a/modules/commands/hs_request.cpp
+++ b/modules/commands/hs_request.cpp
@@ -185,23 +185,30 @@ class CommandHSActivate : public Command
}
const Anope::string &nick = params[0];
-
NickServ::Nick *na = NickServ::FindNick(nick);
- HostRequest *req = na ? na->GetExt<HostRequest>("hostrequest") : NULL;
- if (req)
- {
- na->SetVhost(req->ident, req->host, source.GetNick(), req->time);
- Event::OnSetVhost(&Event::SetVhost::OnSetVhost, na);
- if (Config->GetModule(this->owner)->Get<bool>("memouser") && MemoServ::service)
- MemoServ::service->Send(source.service->nick, na->nick, _("[auto memo] Your requested vHost has been approved."), true);
+ if (!na)
+ {
+ source.Reply(_("\002{0}\002 isn't registered."), nick);
+ return;
+ }
- source.Reply(_("Vhost for \002{0}\002 has been activated."), na->nick);
- Log(LOG_COMMAND, source, this) << "for " << na->nick << " for vhost " << (!req->ident.empty() ? req->ident + "@" : "") << req->host;
- na->Shrink<HostRequest>("hostrequest");
+ HostRequest *req = na->GetExt<HostRequest>("hostrequest");
+ if (!req)
+ {
+ source.Reply(_("\002{0}\002 does not have a pending vhost request."), na->nick);
+ return;
}
- else
- source.Reply(_("\002{0}\002 does not have a pending vhost request."), nick);
+
+ na->SetVhost(req->ident, req->host, source.GetNick(), req->time);
+ Event::OnSetVhost(&Event::SetVhost::OnSetVhost, na);
+
+ if (Config->GetModule(this->owner)->Get<bool>("memouser") && MemoServ::service)
+ MemoServ::service->Send(source.service->nick, na->nick, _("[auto memo] Your requested vHost has been approved."), true);
+
+ source.Reply(_("Vhost for \002{0}\002 has been activated."), na->nick);
+ Log(LOG_COMMAND, source, this) << "for " << na->nick << " for vhost " << (!req->ident.empty() ? req->ident + "@" : "") << req->host;
+ na->Shrink<HostRequest>("hostrequest");
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
@@ -235,27 +242,34 @@ class CommandHSReject : public Command
const Anope::string &reason = params.size() > 1 ? params[1] : "";
NickServ::Nick *na = NickServ::FindNick(nick);
- HostRequest *req = na ? na->GetExt<HostRequest>("hostrequest") : NULL;
- if (req)
+ if (!na)
{
- na->Shrink<HostRequest>("hostrequest");
+ source.Reply(_("\002{0}\002 isn't registered."), nick);
+ return;
+ }
- if (Config->GetModule(this->owner)->Get<bool>("memouser") && MemoServ::service)
- {
- Anope::string message;
- if (!reason.empty())
- message = Anope::printf(_("[auto memo] Your requested vHost has been rejected. Reason: %s"), reason.c_str());
- else
- message = _("[auto memo] Your requested vHost has been rejected.");
+ HostRequest *req = na->GetExt<HostRequest>("hostrequest");
+ if (!req)
+ {
+ source.Reply(_("\002{0}\002 does not have a pending vhost request."), na->nick);
+ return;
+ }
- MemoServ::service->Send(source.service->nick, nick, Language::Translate(source.GetAccount(), message.c_str()), true);
- }
+ na->Shrink<HostRequest>("hostrequest");
+
+ if (Config->GetModule(this->owner)->Get<bool>("memouser") && MemoServ::service)
+ {
+ Anope::string message;
+ if (!reason.empty())
+ message = Anope::printf(_("[auto memo] Your requested vHost has been rejected. Reason: %s"), reason.c_str());
+ else
+ message = _("[auto memo] Your requested vHost has been rejected.");
- source.Reply(_("Vhost for \002{0}\002 has been rejected."), na->nick);
- Log(LOG_COMMAND, source, this) << "to reject vhost for " << nick << " (" << (!reason.empty() ? reason : "no reason") << ")";
+ MemoServ::service->Send(source.service->nick, nick, Language::Translate(source.GetAccount(), message.c_str()), true);
}
- else
- source.Reply(_("\002{0}\002 does not have a pending vhost request."), nick);
+
+ source.Reply(_("Vhost for \002{0}\002 has been rejected."), na->nick);
+ Log(LOG_COMMAND, source, this) << "to reject vhost for " << nick << " (" << (!reason.empty() ? reason : "no reason") << ")";
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/ms_del.cpp b/modules/commands/ms_del.cpp
index 4e4ca5ed4..17722d340 100644
--- a/modules/commands/ms_del.cpp
+++ b/modules/commands/ms_del.cpp
@@ -73,49 +73,53 @@ class CommandMSDel : public Command
source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "MEMO", ci->name);
return;
}
+
mi = ci->memos;
}
else
mi = source.nc->memos;
if (numstr.empty() || (!isdigit(numstr[0]) && !numstr.equals_ci("ALL") && !numstr.equals_ci("LAST")))
+ {
this->OnSyntaxError(source, numstr);
- else if (!mi || mi->memos->empty())
+ return;
+ }
+
+ if (!mi || mi->memos->empty())
{
if (!chan.empty())
source.Reply(_("\002{0}\002 has no memos."), chan);
else
source.Reply(_("You have no memos."));
+ return;
+ }
+
+ if (isdigit(numstr[0]))
+ {
+ MemoDelCallback list(source, ci, mi, numstr);
+ list.Process();
+ }
+ else if (numstr.equals_ci("LAST"))
+ {
+ /* Delete last memo. */
+ if (MemoServ::Event::OnMemoDel)
+ MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ci ? ci->name : source.nc->display, mi, mi->GetMemo(mi->memos->size() - 1));
+ mi->Del(mi->memos->size() - 1);
+ source.Reply(_("Memo \002{0}\002 has been deleted."), mi->memos->size() + 1);
}
else
{
- if (isdigit(numstr[0]))
- {
- MemoDelCallback list(source, ci, mi, numstr);
- list.Process();
- }
- else if (numstr.equals_ci("LAST"))
+ /* Delete all memos. */
+ for (unsigned i = mi->memos->size(); i > 0; --i)
{
- /* Delete last memo. */
if (MemoServ::Event::OnMemoDel)
- MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ci ? ci->name : source.nc->display, mi, mi->GetMemo(mi->memos->size() - 1));
- mi->Del(mi->memos->size() - 1);
- source.Reply(_("Memo \002{0}\002 has been deleted."), mi->memos->size() + 1);
+ MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ci ? ci->name : source.nc->display, mi, mi->GetMemo(i));
+ mi->Del(i - 1);
}
+ if (!chan.empty())
+ source.Reply(_("All memos for channel \002{0}\002 have been deleted."), chan);
else
- {
- /* Delete all memos. */
- for (unsigned i = mi->memos->size(); i > 0; --i)
- {
- if (MemoServ::Event::OnMemoDel)
- MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ci ? ci->name : source.nc->display, mi, mi->GetMemo(i));
- mi->Del(i - 1);
- }
- if (!chan.empty())
- source.Reply(_("All memos for channel \002{0}\002 have been deleted."), chan);
- else
- source.Reply(_("All of your memos have been deleted."));
- }
+ source.Reply(_("All of your memos have been deleted."));
}
}
diff --git a/modules/commands/ms_list.cpp b/modules/commands/ms_list.cpp
index 89f3dc7a5..543e132e3 100644
--- a/modules/commands/ms_list.cpp
+++ b/modules/commands/ms_list.cpp
@@ -51,89 +51,92 @@ class CommandMSList : public Command
mi = source.nc->memos;
if (!param.empty() && !isdigit(param[0]) && !param.equals_ci("NEW"))
+ {
this->OnSyntaxError(source, param);
- else if (!mi->memos->size())
+ return;
+ }
+
+ if (!mi->memos->size())
{
if (!chan.empty())
source.Reply(_("\002{0}\002 has no memos."), chan);
else
source.Reply(_("You have no memos."));
+ return;
}
- else
- {
- ListFormatter list(source.GetAccount());
- list.AddColumn(_("Number")).AddColumn(_("Sender")).AddColumn(_("Date/Time"));
+ ListFormatter list(source.GetAccount());
- if (!param.empty() && isdigit(param[0]))
- {
- class MemoListCallback : public NumberList
- {
- ListFormatter &list;
- CommandSource &source;
- const MemoServ::MemoInfo *mi;
- public:
- MemoListCallback(ListFormatter &_list, CommandSource &_source, const MemoServ::MemoInfo *_mi, const Anope::string &numlist) : NumberList(numlist, false), list(_list), source(_source), mi(_mi)
- {
- }
-
- void HandleNumber(unsigned number) override
- {
- if (!number || number > mi->memos->size())
- return;
-
- const MemoServ::Memo *m = mi->GetMemo(number - 1);
-
- ListFormatter::ListEntry entry;
- entry["Number"] = (m->unread ? "* " : " ") + stringify(number);
- entry["Sender"] = m->sender;
- entry["Date/Time"] = Anope::strftime(m->time, source.GetAccount());
- this->list.AddEntry(entry);
- }
- }
- mlc(list, source, mi, param);
- mlc.Process();
- }
- else
+ list.AddColumn(_("Number")).AddColumn(_("Sender")).AddColumn(_("Date/Time"));
+
+ if (!param.empty() && isdigit(param[0]))
+ {
+ class MemoListCallback : public NumberList
{
- if (!param.empty())
+ ListFormatter &list;
+ CommandSource &source;
+ const MemoServ::MemoInfo *mi;
+ public:
+ MemoListCallback(ListFormatter &_list, CommandSource &_source, const MemoServ::MemoInfo *_mi, const Anope::string &numlist) : NumberList(numlist, false), list(_list), source(_source), mi(_mi)
{
- unsigned i, end;
- for (i = 0, end = mi->memos->size(); i < end; ++i)
- if (mi->GetMemo(i)->unread)
- break;
- if (i == end)
- {
- if (!chan.empty())
- source.Reply(_("\002{0}\002 has no new memos."), chan);
- else
- source.Reply(_("You have no new memos."));
- return;
- }
}
- for (unsigned i = 0, end = mi->memos->size(); i < end; ++i)
+ void HandleNumber(unsigned number) override
{
- if (!param.empty() && !mi->GetMemo(i)->unread)
- continue;
+ if (!number || number > mi->memos->size())
+ return;
- const MemoServ::Memo *m = mi->GetMemo(i);
+ const MemoServ::Memo *m = mi->GetMemo(number - 1);
ListFormatter::ListEntry entry;
- entry["Number"] = (m->unread ? "* " : " ") + stringify(i + 1);
+ entry["Number"] = (m->unread ? "* " : " ") + stringify(number);
entry["Sender"] = m->sender;
entry["Date/Time"] = Anope::strftime(m->time, source.GetAccount());
- list.AddEntry(entry);
+ this->list.AddEntry(entry);
}
}
+ mlc(list, source, mi, param);
+ mlc.Process();
+ }
+ else
+ {
+ if (!param.empty())
+ {
+ unsigned i, end;
+ for (i = 0, end = mi->memos->size(); i < end; ++i)
+ if (mi->GetMemo(i)->unread)
+ break;
+ if (i == end)
+ {
+ if (!chan.empty())
+ source.Reply(_("\002{0}\002 has no new memos."), chan);
+ else
+ source.Reply(_("You have no new memos."));
+ return;
+ }
+ }
+
+ for (unsigned i = 0, end = mi->memos->size(); i < end; ++i)
+ {
+ if (!param.empty() && !mi->GetMemo(i)->unread)
+ continue;
- std::vector<Anope::string> replies;
- list.Process(replies);
+ const MemoServ::Memo *m = mi->GetMemo(i);
- source.Reply(_("Memos for \002{0}\002:"), ci ? ci->name.c_str() : source.GetNick().c_str());
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
+ ListFormatter::ListEntry entry;
+ entry["Number"] = (m->unread ? "* " : " ") + stringify(i + 1);
+ entry["Sender"] = m->sender;
+ entry["Date/Time"] = Anope::strftime(m->time, source.GetAccount());
+ list.AddEntry(entry);
+ }
}
+
+ std::vector<Anope::string> replies;
+ list.Process(replies);
+
+ source.Reply(_("Memos for \002{0}\002:"), ci ? ci->name.c_str() : source.GetNick().c_str());
+ for (unsigned i = 0; i < replies.size(); ++i)
+ source.Reply(replies[i]);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/ms_read.cpp b/modules/commands/ms_read.cpp
index 2cbecf70b..d7e5a6ed1 100644
--- a/modules/commands/ms_read.cpp
+++ b/modules/commands/ms_read.cpp
@@ -134,46 +134,49 @@ class CommandMSRead : public Command
mi = source.nc->memos;
if (numstr.empty() || (!numstr.equals_ci("LAST") && !numstr.equals_ci("NEW") && !numstr.is_number_only()))
+ {
this->OnSyntaxError(source, numstr);
- else if (mi->memos->empty())
+ return;
+ }
+
+ if (mi->memos->empty())
{
if (!chan.empty())
source.Reply(_("\002{0}\002 has no memos."), chan);
else
source.Reply(_("You have no memos."));
+ return;
}
- else
- {
- int i, end;
- if (numstr.equals_ci("NEW"))
- {
- int readcount = 0;
- for (i = 0, end = mi->memos->size(); i < end; ++i)
- if (mi->GetMemo(i)->unread)
- {
- MemoListCallback::DoRead(source, mi, ci, i);
- ++readcount;
- }
- if (!readcount)
+ int i, end;
+
+ if (numstr.equals_ci("NEW"))
+ {
+ int readcount = 0;
+ for (i = 0, end = mi->memos->size(); i < end; ++i)
+ if (mi->GetMemo(i)->unread)
{
- if (!chan.empty())
- source.Reply(_("\002{0}\002 has no new memos."), chan);
- else
- source.Reply(_("You have no new memos."));
+ MemoListCallback::DoRead(source, mi, ci, i);
+ ++readcount;
}
- }
- else if (numstr.equals_ci("LAST"))
- {
- for (i = 0, end = mi->memos->size() - 1; i < end; ++i);
- MemoListCallback::DoRead(source, mi, ci, i);
- }
- else /* number[s] */
+ if (!readcount)
{
- MemoListCallback list(source, mi, ci, numstr);
- list.Process();
+ if (!chan.empty())
+ source.Reply(_("\002{0}\002 has no new memos."), chan);
+ else
+ source.Reply(_("You have no new memos."));
}
}
+ else if (numstr.equals_ci("LAST"))
+ {
+ for (i = 0, end = mi->memos->size() - 1; i < end; ++i);
+ MemoListCallback::DoRead(source, mi, ci, i);
+ }
+ else /* number[s] */
+ {
+ MemoListCallback list(source, mi, ci, numstr);
+ list.Process();
+ }
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/ms_rsend.cpp b/modules/commands/ms_rsend.cpp
index 101a67816..80e5c5434 100644
--- a/modules/commands/ms_rsend.cpp
+++ b/modules/commands/ms_rsend.cpp
@@ -96,6 +96,7 @@ class MSRSend : public Module
{
if (!MemoServ::service)
throw ModuleException("No MemoServ!");
+ throw ModuleException("XXX");
}
};
diff --git a/modules/commands/ms_set.cpp b/modules/commands/ms_set.cpp
index 42bce16cf..462cc72a8 100644
--- a/modules/commands/ms_set.cpp
+++ b/modules/commands/ms_set.cpp
@@ -154,7 +154,7 @@ class CommandMSSet : public Command
source.Reply(_("The memo limit for \002{0}\002 may not be changed."), chan);
return;
}
- else if (chan.empty() && nc->HasExt("MEMO_HARDMAX"))
+ if (chan.empty() && nc->HasExt("MEMO_HARDMAX"))
{
source.Reply(_("You are not permitted to change your memo limit."));
return;
diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp
index 94df860d6..81015dc71 100644
--- a/modules/commands/ns_ajoin.cpp
+++ b/modules/commands/ns_ajoin.cpp
@@ -92,30 +92,32 @@ class CommandNSAJoin : public Command
{
AJoinList *channels = nc->Require<AJoinList>("ajoinlist");
- if ((*channels)->empty())
+ if ((*channels)->empty())\
+ {
source.Reply(_("The auto join list of \002{0}\002 is empty."), nc->display);
- else
+ return;
+ }
+
+
+ ListFormatter list(source.GetAccount());
+ list.AddColumn(_("Number")).AddColumn(_("Channel")).AddColumn(_("Key"));
+ for (unsigned i = 0; i < (*channels)->size(); ++i)
{
- ListFormatter list(source.GetAccount());
- list.AddColumn(_("Number")).AddColumn(_("Channel")).AddColumn(_("Key"));
- for (unsigned i = 0; i < (*channels)->size(); ++i)
- {
- AJoinEntry *aj = (*channels)->at(i);
- ListFormatter::ListEntry entry;
- entry["Number"] = stringify(i + 1);
- entry["Channel"] = aj->channel;
- entry["Key"] = aj->key;
- list.AddEntry(entry);
- }
+ AJoinEntry *aj = (*channels)->at(i);
+ ListFormatter::ListEntry entry;
+ entry["Number"] = stringify(i + 1);
+ entry["Channel"] = aj->channel;
+ entry["Key"] = aj->key;
+ list.AddEntry(entry);
+ }
- source.Reply(_("Auto join list of \002{0}\002:"), nc->display);
+ source.Reply(_("Auto join list of \002{0}\002:"), nc->display);
- std::vector<Anope::string> replies;
- list.Process(replies);
+ std::vector<Anope::string> replies;
+ list.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
- }
+ for (unsigned i = 0; i < replies.size(); ++i)
+ source.Reply(replies[i]);
}
void DoAdd(CommandSource &source, NickServ::Account *nc, const Anope::string &chans, const Anope::string &keys)
diff --git a/modules/commands/ns_drop.cpp b/modules/commands/ns_drop.cpp
index 345521504..deeee7170 100644
--- a/modules/commands/ns_drop.cpp
+++ b/modules/commands/ns_drop.cpp
@@ -43,18 +43,23 @@ class CommandNSDrop : public Command
bool is_mine = source.GetAccount() == na->nc;
if (!is_mine && !source.HasPriv("nickserv/drop"))
+ {
source.Reply(_("Access denied. You do not have the correct operator privileges to drop other user's nicknames."));
- else if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && !is_mine && na->nc->IsServicesOper())
- source.Reply(_("You may not drop other Services Operators' nicknames."));
- else
+ return;
+ }
+
+ if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && !is_mine && na->nc->IsServicesOper())
{
- this->onnickdrop(&Event::NickDrop::OnNickDrop, source, na);
+ source.Reply(_("You may not drop other Services Operators' nicknames."));
+ return;
+ }
- Log(!is_mine ? LOG_ADMIN : LOG_COMMAND, source, this) << "to drop nickname " << na->nick << " (group: " << na->nc->display << ") (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")";
- delete na;
+ this->onnickdrop(&Event::NickDrop::OnNickDrop, source, na);
- source.Reply(_("\002{0}\002 has been dropped."), nick);
- }
+ Log(!is_mine ? LOG_ADMIN : LOG_COMMAND, source, this) << "to drop nickname " << na->nick << " (group: " << na->nc->display << ") (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")";
+ delete na;
+
+ source.Reply(_("\002{0}\002 has been dropped."), nick);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/ns_getpass.cpp b/modules/commands/ns_getpass.cpp
index 166dded78..09b7c72b7 100644
--- a/modules/commands/ns_getpass.cpp
+++ b/modules/commands/ns_getpass.cpp
@@ -24,22 +24,28 @@ class CommandNSGetPass : public Command
{
const Anope::string &nick = params[0];
Anope::string tmp_pass;
- const NickServ::Nick *na;
+ const NickServ::Nick *na = NickServ::FindNick(nick);
- if (!(na = NickServ::FindNick(nick)))
+ if (!na)
+ {
source.Reply(_("\002{0}\002 isn't registered."), nick);
- else if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && na->nc->IsServicesOper())
+ return;
+ }
+
+ if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && na->nc->IsServicesOper())
+ {
source.Reply(_("You may not get the password of other Services Operators."));
- else
+ return;
+ }
+
+ if (!Anope::Decrypt(na->nc->pass, tmp_pass))
{
- if (Anope::Decrypt(na->nc->pass, tmp_pass) == 1)
- {
- Log(LOG_ADMIN, source, this) << "for " << nick;
- source.Reply(_("Password of \002{0}\02 is \002%s\002."), nick, tmp_pass);
- }
- else
- source.Reply(_("The \002{0}\002 command is unavailable because encryption is in use."), source.command);
+ source.Reply(_("The \002{0}\002 command is unavailable because encryption is in use."), source.command);
+ return;
}
+
+ Log(LOG_ADMIN, source, this) << "for " << na->nick;
+ source.Reply(_("Password of \002{0}\02 is \002%s\002."), na->nick, tmp_pass);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp
index 7a67337f9..380fe4631 100644
--- a/modules/commands/ns_group.cpp
+++ b/modules/commands/ns_group.cpp
@@ -130,55 +130,84 @@ class CommandNSGroup : public Command
time_t reg_delay = Config->GetModule("nickserv")->Get<time_t>("regdelay");
unsigned maxaliases = Config->GetModule(this->owner)->Get<unsigned>("maxaliases");
if (!(target = NickServ::FindNick(nick)))
+ {
source.Reply(_("\002{0}\002 isn't registered."), nick);
- else if (Anope::CurTime < u->lastnickreg + reg_delay)
+ return;
+ }
+
+ if (Anope::CurTime < u->lastnickreg + reg_delay)
+ {
source.Reply(_("Please wait \002{0}\002 seconds before using the \002{1}\002 command again."), (reg_delay + u->lastnickreg) - Anope::CurTime, source.command);
- else if (target->nc->HasExt("NS_SUSPENDED"))
+ return;
+ }
+
+ if (target->nc->HasExt("NS_SUSPENDED"))
{
Log(LOG_COMMAND, source, this) << "and tried to group to suspended nick " << target->nick;
source.Reply(_("\002{0}\002 is suspended."), target->nick);
+ return;
}
- else if (na && Config->GetModule(this->owner)->Get<bool>("nogroupchange"))
+
+ if (na && Config->GetModule(this->owner)->Get<bool>("nogroupchange"))
+ {
source.Reply(_("Your nick is already registered."));
- else if (na && *target->nc == *na->nc)
+ return;
+ }
+
+ if (na && *target->nc == *na->nc)
+ {
source.Reply(_("You are already a member of the group of \002{0}\002."), target->nick);
- else if (na && na->nc != u->Account())
+ return;
+ }
+
+ if (na && na->nc != u->Account())
+ {
source.Reply(_("\002{0}\002 is already registered."), na->nick);
- else if (na && Config->GetModule(this->owner)->Get<bool>("nogroupchange"))
+ return;
+ }
+
+ if (na && Config->GetModule(this->owner)->Get<bool>("nogroupchange"))
+ {
source.Reply(_("You are already registered."));
- else if (maxaliases && target->nc->aliases->size() >= maxaliases && !target->nc->IsServicesOper())
+ return;
+ }
+
+ if (maxaliases && target->nc->aliases->size() >= maxaliases && !target->nc->IsServicesOper())
+ {
source.Reply(_("There are too many nicknames in your group."));
- else if (u->nick.length() <= guestnick.length() + 7 &&
+ return;
+ }
+
+ if (u->nick.length() <= guestnick.length() + 7 &&
u->nick.length() >= guestnick.length() + 1 &&
!u->nick.find_ci(guestnick) && !u->nick.substr(guestnick.length()).find_first_not_of("1234567890"))
{
source.Reply(_("\002{0}\002 may not be registered."), u->nick);
+ return;
+ }
+
+ bool ok = false;
+ if (!na && u->Account() == target->nc)
+ ok = true;
+
+ NSCertList *cl = target->nc->GetExt<NSCertList>("certificates");
+ if (!u->fingerprint.empty() && cl && cl->FindCert(u->fingerprint))
+ ok = true;
+
+ if (ok == false && !pass.empty())
+ {
+ NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new NSGroupRequestListener(onnickgroup, source, this, u->nick, target), owner, target->nc->display, pass);
+ Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, source.GetUser(), req);
+ req->Dispatch();
}
else
{
- bool ok = false;
- if (!na && u->Account() == target->nc)
- ok = true;
-
- NSCertList *cl = target->nc->GetExt<NSCertList>("certificates");
- if (!u->fingerprint.empty() && cl && cl->FindCert(u->fingerprint))
- ok = true;
+ NSGroupRequestListener req(onnickgroup, source, this, u->nick, target);
- if (ok == false && !pass.empty())
- {
- NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new NSGroupRequestListener(onnickgroup, source, this, u->nick, target), owner, target->nc->display, pass);
- Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, source.GetUser(), req);
- req->Dispatch();
- }
+ if (ok)
+ req.OnSuccess(nullptr);
else
- {
- NSGroupRequestListener req(onnickgroup, source, this, u->nick, target);
-
- if (ok)
- req.OnSuccess(nullptr);
- else
- req.OnFail(nullptr);
- }
+ req.OnFail(nullptr);
}
}
@@ -212,38 +241,48 @@ class CommandNSUngroup : public Command
NickServ::Nick *na = NickServ::FindNick(!nick.empty() ? nick : u->nick);
if (u->Account()->aliases->size() == 1)
+ {
source.Reply(_("Your nickname is not grouped to anything, so you can't ungroup it."));
- else if (!na)
+ return;
+ }
+
+ if (!na)
+ {
source.Reply(_("\002{0}\002 isn't registered."), !nick.empty() ? nick : u->nick);
- else if (na->nc != u->Account())
- source.Reply(_("\002{0}\002 is not in your group."), na->nick);
- else
+ return;
+ }
+
+ if (na->nc != u->Account())
{
- NickServ::Account *oldcore = na->nc;
+ source.Reply(_("\002{0}\002 is not in your group."), na->nick);
+ return;
+ }
- std::vector<NickServ::Nick *>::iterator it = std::find(oldcore->aliases->begin(), oldcore->aliases->end(), na);
- if (it != oldcore->aliases->end())
- oldcore->aliases->erase(it);
- if (na->nick.equals_ci(oldcore->display))
- oldcore->SetDisplay(oldcore->aliases->front());
+ NickServ::Account *oldcore = na->nc;
- NickServ::Account *nc = NickServ::service->CreateAccount(na->nick);
- na->nc = nc;
- nc->aliases->push_back(na);
+ std::vector<NickServ::Nick *>::iterator it = std::find(oldcore->aliases->begin(), oldcore->aliases->end(), na);
+ if (it != oldcore->aliases->end())
+ oldcore->aliases->erase(it);
- nc->pass = oldcore->pass;
- if (!oldcore->email.empty())
- nc->email = oldcore->email;
- nc->language = oldcore->language;
+ if (na->nick.equals_ci(oldcore->display))
+ oldcore->SetDisplay(oldcore->aliases->front());
- source.Reply(_("\002{0}\002 has been ungrouped from \002{1}\002."), na->nick, oldcore->display);
+ NickServ::Account *nc = NickServ::service->CreateAccount(na->nick);
+ na->nc = nc;
+ nc->aliases->push_back(na);
- User *user = User::Find(na->nick);
- if (user)
- /* The user on the nick who was ungrouped may be identified to the old group, set -r */
- user->RemoveMode(source.service, "REGISTERED");
- }
+ nc->pass = oldcore->pass;
+ if (!oldcore->email.empty())
+ nc->email = oldcore->email;
+ nc->language = oldcore->language;
+
+ source.Reply(_("\002{0}\002 has been ungrouped from \002{1}\002."), na->nick, oldcore->display);
+
+ User *user = User::Find(na->nick);
+ if (user)
+ /* The user on the nick who was ungrouped may be identified to the old group, set -r */
+ user->RemoveMode(source.service, "REGISTERED");
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/ns_identify.cpp b/modules/commands/ns_identify.cpp
index 07616635e..c8384d8a8 100644
--- a/modules/commands/ns_identify.cpp
+++ b/modules/commands/ns_identify.cpp
@@ -28,32 +28,33 @@ class NSIdentifyRequestListener : public NickServ::IdentifyRequestListener
NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
if (!na)
- source.Reply(_("\002{0}\002 isn't registered."), req->GetAccount());
- else
{
- if (u->IsIdentified())
- Log(LOG_COMMAND, source, cmd) << "to log out of account " << u->Account()->display;
-
- Log(LOG_COMMAND, source, cmd) << "and identified for account " << na->nc->display;
- source.Reply(_("Password accepted - you are now recognized as \002{0}\002."), na->nc->display);
- u->Identify(na);
+ source.Reply(_("\002{0}\002 isn't registered."), req->GetAccount());
+ return;
}
+
+ if (u->IsIdentified())
+ Log(LOG_COMMAND, source, cmd) << "to log out of account " << u->Account()->display;
+
+ Log(LOG_COMMAND, source, cmd) << "and identified for account " << na->nc->display;
+ source.Reply(_("Password accepted - you are now recognized as \002{0}\002."), na->nc->display);
+ u->Identify(na);
}
void OnFail(NickServ::IdentifyRequest *req) override
{
- if (source.GetUser())
+ if (!source.GetUser())
+ return;
+
+ bool accountexists = NickServ::FindNick(req->GetAccount()) != NULL;
+ Log(LOG_COMMAND, source, cmd) << "and failed to identify to" << (accountexists ? " " : " nonexistent ") << "account " << req->GetAccount();
+ if (accountexists)
{
- bool accountexists = NickServ::FindNick(req->GetAccount()) != NULL;
- Log(LOG_COMMAND, source, cmd) << "and failed to identify to" << (accountexists ? " " : " nonexistent ") << "account " << req->GetAccount();
- if (accountexists)
- {
- source.Reply(_("Password incorrect."));
- source.GetUser()->BadPassword();
- }
- else
- source.Reply("\002{0}\002 isn't registered.", req->GetAccount());
+ source.Reply(_("Password incorrect."));
+ source.GetUser()->BadPassword();
}
+ else
+ source.Reply("\002{0}\002 isn't registered.", req->GetAccount());
}
};
@@ -77,15 +78,20 @@ class CommandNSIdentify : public Command
NickServ::Nick *na = NickServ::FindNick(nick);
if (na && na->nc->HasExt("NS_SUSPENDED"))
+ {
source.Reply(_("\002{0}\002 is suspended."), na->nick);
- else if (u->Account() && na && u->Account() == na->nc)
- source.Reply(_("You are already identified."));
- else
+ return;
+ }
+
+ if (u->Account() && na && u->Account() == na->nc)
{
- NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new NSIdentifyRequestListener(source, this), owner, na ? na->nc->display : nick, pass);
- Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, u, req);
- req->Dispatch();
+ source.Reply(_("You are already identified."));
+ return;
}
+
+ NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new NSIdentifyRequestListener(source, this), owner, na ? na->nc->display : nick, pass);
+ Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, u, req);
+ req->Dispatch();
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp
index bbec0fef0..9bbf5c418 100644
--- a/modules/commands/ns_info.cpp
+++ b/modules/commands/ns_info.cpp
@@ -38,88 +38,87 @@ class CommandNSInfo : public Command
source.Reply(_("\002{0}\002 is part of this Network's Services."), nick);
else
source.Reply(_("\002{0}\002 isn't registered."), nick);
+ return;
}
- else
- {
- bool nick_online = false, show_hidden = false;
- /* Is the real owner of the nick we're looking up online? -TheShadow */
- User *u2 = User::Find(na->nick);
- if (u2 && u2->Account() == na->nc)
- {
- nick_online = true;
- na->last_seen = Anope::CurTime;
- }
+ bool nick_online = false, show_hidden = false;
- if (has_auspex || na->nc == source.GetAccount())
- show_hidden = true;
+ /* Is the real owner of the nick we're looking up online? -TheShadow */
+ User *u2 = User::Find(na->nick);
+ if (u2 && u2->Account() == na->nc)
+ {
+ nick_online = true;
+ na->last_seen = Anope::CurTime;
+ }
+
+ if (has_auspex || na->nc == source.GetAccount())
+ show_hidden = true;
- source.Reply(_("\002{0}\002 is \002{1}\002"), na->nick, na->last_realname);
+ source.Reply(_("\002{0}\002 is \002{1}\002"), na->nick, na->last_realname);
- if (na->nc->HasExt("UNCONFIRMED"))
- source.Reply(_("\002{0}\002 has not confirmed their account."), na->nick);
+ if (na->nc->HasExt("UNCONFIRMED"))
+ source.Reply(_("\002{0}\002 has not confirmed their account."), na->nick);
- if (na->nc->IsServicesOper() && (show_hidden || !na->nc->HasExt("HIDE_STATUS")))
- source.Reply(_("\002{0}\002 is a Services Operator of type \002{0}\002."), na->nick, na->nc->o->ot->GetName());
+ if (na->nc->IsServicesOper() && (show_hidden || !na->nc->HasExt("HIDE_STATUS")))
+ source.Reply(_("\002{0}\002 is a Services Operator of type \002{0}\002."), na->nick, na->nc->o->ot->GetName());
- InfoFormatter info(source.nc);
+ InfoFormatter info(source.nc);
- if (nick_online)
+ if (nick_online)
+ {
+ bool shown = false;
+ if (show_hidden && !na->last_realhost.empty())
{
- bool shown = false;
- if (show_hidden && !na->last_realhost.empty())
- {
- info[_("Online from")] = na->last_realhost;
- shown = true;
- }
- if ((show_hidden || !na->nc->HasExt("HIDE_MASK")) && (!shown || na->last_usermask != na->last_realhost))
- info[_("Online from")] = na->last_usermask;
- else
- source.Reply(_("\002{0}\002 is currently online."), na->nick);
+ info[_("Online from")] = na->last_realhost;
+ shown = true;
}
+ if ((show_hidden || !na->nc->HasExt("HIDE_MASK")) && (!shown || na->last_usermask != na->last_realhost))
+ info[_("Online from")] = na->last_usermask;
else
+ source.Reply(_("\002{0}\002 is currently online."), na->nick);
+ }
+ else
+ {
+ Anope::string shown;
+ if (show_hidden || !na->nc->HasExt("HIDE_MASK"))
{
- Anope::string shown;
- if (show_hidden || !na->nc->HasExt("HIDE_MASK"))
- {
- info[_("Last seen address")] = na->last_usermask;
- shown = na->last_usermask;
- }
-
- if (show_hidden && !na->last_realhost.empty() && na->last_realhost != shown)
- info[_("Last seen address")] = na->last_realhost;
+ info[_("Last seen address")] = na->last_usermask;
+ shown = na->last_usermask;
}
- info[_("Registered")] = Anope::strftime(na->time_registered, source.GetAccount());
+ if (show_hidden && !na->last_realhost.empty() && na->last_realhost != shown)
+ info[_("Last seen address")] = na->last_realhost;
+ }
+
+ info[_("Registered")] = Anope::strftime(na->time_registered, source.GetAccount());
- if (!nick_online)
- info[_("Last seen")] = Anope::strftime(na->last_seen, source.GetAccount());
+ if (!nick_online)
+ info[_("Last seen")] = Anope::strftime(na->last_seen, source.GetAccount());
- if (!na->last_quit.empty() && (show_hidden || !na->nc->HasExt("HIDE_QUIT")))
- info[_("Last quit message")] = na->last_quit;
+ if (!na->last_quit.empty() && (show_hidden || !na->nc->HasExt("HIDE_QUIT")))
+ info[_("Last quit message")] = na->last_quit;
- if (!na->nc->email.empty() && (show_hidden || !na->nc->HasExt("HIDE_EMAIL")))
- info[_("Email address")] = na->nc->email;
+ if (!na->nc->email.empty() && (show_hidden || !na->nc->HasExt("HIDE_EMAIL")))
+ info[_("Email address")] = na->nc->email;
- if (show_hidden)
+ if (show_hidden)
+ {
+ if (na->HasVhost())
{
- if (na->HasVhost())
- {
- if (IRCD->CanSetVIdent && !na->GetVhostIdent().empty())
- info[_("VHost")] = na->GetVhostIdent() + "@" + na->GetVhostHost();
- else
- info[_("VHost")] = na->GetVhostHost();
- }
+ if (IRCD->CanSetVIdent && !na->GetVhostIdent().empty())
+ info[_("VHost")] = na->GetVhostIdent() + "@" + na->GetVhostHost();
+ else
+ info[_("VHost")] = na->GetVhostHost();
}
+ }
- this->onnickinfo(&Event::NickInfo::OnNickInfo, source, na, info, show_hidden);
+ this->onnickinfo(&Event::NickInfo::OnNickInfo, source, na, info, show_hidden);
- std::vector<Anope::string> replies;
- info.Process(replies);
+ std::vector<Anope::string> replies;
+ info.Process(replies);
- for (unsigned i = 0; i < replies.size(); ++i)
- source.Reply(replies[i]);
- }
+ for (unsigned i = 0; i < replies.size(); ++i)
+ source.Reply(replies[i]);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/ns_logout.cpp b/modules/commands/ns_logout.cpp
index 70f2171af..f63086789 100644
--- a/modules/commands/ns_logout.cpp
+++ b/modules/commands/ns_logout.cpp
@@ -27,33 +27,42 @@ class CommandNSLogout : public Command
const Anope::string &nick = !params.empty() ? params[0] : "";
const Anope::string &param = params.size() > 1 ? params[1] : "";
- User *u2;
if (!source.IsServicesOper() && !nick.empty())
+ {
this->OnSyntaxError(source, "");
- else if (!(u2 = (!nick.empty() ? User::Find(nick, true) : source.GetUser())))
+ return;
+ }
+
+ User *u2 = !nick.empty() ? User::Find(nick, true) : source.GetUser();
+ if (!u2)
+ {
source.Reply(_("\002{0}\002 isn't currently online."), !nick.empty() ? nick : source.GetNick());
- else if (!nick.empty() && u2->IsServicesOper())
- source.Reply(_("You can't logout \002{0}\002, they are a Services Operator."), nick);
- else
+ return;
+ }
+
+ if (!nick.empty() && u2->IsServicesOper())
{
- if (!nick.empty() && !param.empty() && param.equals_ci("REVALIDATE") && NickServ::service)
- NickServ::service->Validate(u2);
+ source.Reply(_("You can't logout \002{0}\002, they are a Services Operator."), nick);
+ return;
+ }
- u2->super_admin = false; /* Dont let people logout and remain a SuperAdmin */
- Log(LOG_COMMAND, source, this) << "to logout " << u2->nick;
+ if (!nick.empty() && !param.empty() && param.equals_ci("REVALIDATE") && NickServ::service)
+ NickServ::service->Validate(u2);
- if (!nick.empty())
- source.Reply(_("\002{0}\002 has been logged out."), nick);
- else
- source.Reply(_("You have been logged out."));
+ u2->super_admin = false; /* Dont let people logout and remain a SuperAdmin */
+ Log(LOG_COMMAND, source, this) << "to logout " << u2->nick;
- IRCD->SendLogout(u2);
- u2->RemoveMode(source.service, "REGISTERED");
- u2->Logout();
+ if (!nick.empty())
+ source.Reply(_("\002{0}\002 has been logged out."), nick);
+ else
+ source.Reply(_("You have been logged out."));
- /* Send out an event */
- Event::OnNickLogout(&Event::NickLogout::OnNickLogout, u2);
- }
+ IRCD->SendLogout(u2);
+ u2->RemoveMode(source.service, "REGISTERED");
+ u2->Logout();
+
+ /* Send out an event */
+ Event::OnNickLogout(&Event::NickLogout::OnNickLogout, u2);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp
index c54ea3764..c464bc2f6 100644
--- a/modules/commands/ns_register.cpp
+++ b/modules/commands/ns_register.cpp
@@ -32,45 +32,49 @@ class CommandNSConfirm : public Command
{
NickServ::Nick *na = NickServ::FindNick(passcode);
if (na == NULL)
+ {
source.Reply(_("\002{0}\002 isn't registered."), passcode);
- else if (na->nc->HasExt("UNCONFIRMED") == false)
- source.Reply(_("\002{0}\002 is already confirmed."), na->nick);
- else
+ return;
+ }
+
+ if (na->nc->HasExt("UNCONFIRMED") == false)
{
- na->nc->Shrink<bool>("UNCONFIRMED");
- Log(LOG_ADMIN, source, this) << "to confirm nick " << na->nick << " (" << na->nc->display << ")";
- source.Reply(_("\002{0}\002 has been confirmed."), na->nick);
+ source.Reply(_("\002{0}\002 is already confirmed."), na->nick);
+ return;
}
+
+ na->nc->Shrink<bool>("UNCONFIRMED");
+ Log(LOG_ADMIN, source, this) << "to confirm nick " << na->nick << " (" << na->nc->display << ")";
+ source.Reply(_("\002{0}\002 has been confirmed."), na->nick);
}
else if (source.nc)
{
Anope::string *code = source.nc->GetExt<Anope::string>("passcode");
- if (code != NULL && *code == passcode)
+ if (code == nullptr || *code != passcode)
{
- NickServ::Account *nc = source.nc;
- nc->Shrink<Anope::string>("passcode");
- Log(LOG_COMMAND, source, this) << "to confirm their email";
- source.Reply(_("Your email address of \002{0}\002 has been confirmed."), source.nc->email);
- nc->Shrink<bool>("UNCONFIRMED");
+ source.Reply(_("Invalid passcode."));
+ return;
+ }
+
+ NickServ::Account *nc = source.nc;
+ nc->Shrink<Anope::string>("passcode");
+ Log(LOG_COMMAND, source, this) << "to confirm their email";
+ source.Reply(_("Your email address of \002{0}\002 has been confirmed."), source.nc->email);
+ nc->Shrink<bool>("UNCONFIRMED");
- if (source.GetUser())
+ if (source.GetUser())
+ {
+ NickServ::Nick *na = NickServ::FindNick(source.GetNick());
+ if (na)
{
- NickServ::Nick *na = NickServ::FindNick(source.GetNick());
- if (na)
- {
- IRCD->SendLogin(source.GetUser(), na);
- if (!Config->GetModule("nickserv")->Get<bool>("nonicknameownership") && na->nc == source.GetAccount() && !na->nc->HasExt("UNCONFIRMED"))
- source.GetUser()->SetMode(source.service, "REGISTERED");
- }
+ IRCD->SendLogin(source.GetUser(), na);
+ if (!Config->GetModule("nickserv")->Get<bool>("nonicknameownership") && na->nc == source.GetAccount() && !na->nc->HasExt("UNCONFIRMED"))
+ source.GetUser()->SetMode(source.service, "REGISTERED");
}
}
- else
- source.Reply(_("Invalid passcode."));
}
else
source.Reply(_("Invalid passcode."));
-
- return;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
@@ -125,7 +129,7 @@ class CommandNSRegister : public Command
time_t reg_delay = Config->GetModule("nickserv")->Get<time_t>("regdelay");
if (u && !u->HasMode("OPER") && nickregdelay && Anope::CurTime - u->timestamp < nickregdelay)
{
- source.Reply(_("You must have been using this nick for at least %d seconds to register."), nickregdelay);
+ source.Reply(_("You must have been using this nickname for at least {0} seconds to register."), nickregdelay);
return;
}
@@ -160,67 +164,88 @@ class CommandNSRegister : public Command
}
if (Config->GetModule("nickserv")->Get<bool>("forceemail", "yes") && email.empty())
+ {
this->OnSyntaxError(source, "");
- else if (u && Anope::CurTime < u->lastnickreg + reg_delay)
+ return;
+ }
+
+ if (u && Anope::CurTime < u->lastnickreg + reg_delay)
+ {
source.Reply(_("Please wait \002{0}\002 seconds before using the {1} command again."), (u->lastnickreg + reg_delay) - Anope::CurTime, source.command);
- else if (NickServ::FindNick(u_nick) != NULL)
+ return;
+ }
+
+ if (NickServ::FindNick(u_nick) != NULL)
+ {
source.Reply(_("\002{0}\002 is already registered."), u_nick);
- else if (pass.equals_ci(u_nick) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && pass.length() < 5))
+ return;
+ }
+
+ if (pass.equals_ci(u_nick) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && pass.length() < 5))
+ {
source.Reply(_("Please try again with a more obscure password. Passwords should be at least five characters long, should not be something easily guessed"
" (e.g. your real name or your nickname), and cannot contain the space or tab characters."));
- else if (pass.length() > Config->GetModule("nickserv")->Get<unsigned>("passlen", "32"))
+ return;
+ }
+
+ if (pass.length() > Config->GetModule("nickserv")->Get<unsigned>("passlen", "32"))
+ {
source.Reply(_("Your password is too long, it can not contain more than \002{0}\002 characters."), Config->GetModule("nickserv")->Get<unsigned>("passlen", "32"));
- else if (!email.empty() && !Mail::Validate(email))
- source.Reply(_("\002{0}\002 is not a valid e-mail address."), email);
- else
+ return;
+ }
+
+ if (!email.empty() && !Mail::Validate(email))
{
- NickServ::Account *nc = NickServ::service->CreateAccount(u_nick);
- NickServ::Nick *na = NickServ::service->CreateNick(u_nick, nc);
- Anope::Encrypt(pass, nc->pass);
- if (!email.empty())
- nc->email = email;
+ source.Reply(_("\002{0}\002 is not a valid e-mail address."), email);
+ return;
+ }
- if (u)
- {
- na->last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost();
- na->last_realname = u->realname;
- }
- else
- na->last_realname = source.GetNick();
+ NickServ::Account *nc = NickServ::service->CreateAccount(u_nick);
+ NickServ::Nick *na = NickServ::service->CreateNick(u_nick, nc);
+ Anope::Encrypt(pass, nc->pass);
+ if (!email.empty())
+ nc->email = email;
+
+ if (u)
+ {
+ na->last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost();
+ na->last_realname = u->realname;
+ }
+ else
+ na->last_realname = source.GetNick();
- Log(LOG_COMMAND, source, this) << "to register " << na->nick << " (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")";
+ Log(LOG_COMMAND, source, this) << "to register " << na->nick << " (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")";
- if (NickServ::Event::OnNickRegister)
- NickServ::Event::OnNickRegister(&NickServ::Event::NickRegister::OnNickRegister, source.GetUser(), na, pass);
+ if (NickServ::Event::OnNickRegister)
+ NickServ::Event::OnNickRegister(&NickServ::Event::NickRegister::OnNickRegister, source.GetUser(), na, pass);
- if (na->nc->GetAccessCount())
- source.Reply(_("\002{0}\002 has been registered under your hostmask: \002{1}\002"), u_nick, na->nc->GetAccess(0));
- else
- source.Reply(_("\002{0}\002 has been registered."), u_nick);
+ if (na->nc->GetAccessCount())
+ source.Reply(_("\002{0}\002 has been registered under your hostmask: \002{1}\002"), u_nick, na->nc->GetAccess(0));
+ else
+ source.Reply(_("\002{0}\002 has been registered."), u_nick);
- Anope::string tmp_pass;
- if (Anope::Decrypt(na->nc->pass, tmp_pass) == 1)
- source.Reply(_("Your password is \002{0}\002 - remember this for later use."), tmp_pass);
+ Anope::string tmp_pass;
+ if (Anope::Decrypt(na->nc->pass, tmp_pass) == 1)
+ source.Reply(_("Your password is \002{0}\002 - remember this for later use."), tmp_pass);
- if (nsregister.equals_ci("admin"))
+ if (nsregister.equals_ci("admin"))
+ {
+ nc->Extend<bool>("UNCONFIRMED");
+ // User::Identify() called below will notify the user that their registration is pending
+ }
+ else if (nsregister.equals_ci("mail"))
+ {
+ if (!email.empty())
{
nc->Extend<bool>("UNCONFIRMED");
- // User::Identify() called below will notify the user that their registration is pending
- }
- else if (nsregister.equals_ci("mail"))
- {
- if (!email.empty())
- {
- nc->Extend<bool>("UNCONFIRMED");
- SendRegmail(NULL, na, source.service);
- }
+ SendRegmail(NULL, na, source.service);
}
+ }
- if (u)
- {
- u->Identify(na);
- u->lastnickreg = Anope::CurTime;
- }
+ if (u)
+ {
+ u->Identify(na);
+ u->lastnickreg = Anope::CurTime;
}
}
@@ -267,22 +292,32 @@ class CommandNSResend : public Command
const NickServ::Nick *na = NickServ::FindNick(source.GetNick());
if (na == NULL)
+ {
source.Reply(_("Your nickname isn't registered."));
- else if (na->nc != source.GetAccount() || !source.nc->HasExt("UNCONFIRMED"))
+ return;
+ }
+
+ if (na->nc != source.GetAccount() || !source.nc->HasExt("UNCONFIRMED"))
+ {
source.Reply(_("Your account is already confirmed."));
- else
+ return;
+ }
+
+ if (Anope::CurTime < source.nc->lastmail + Config->GetModule(this->owner)->Get<time_t>("resenddelay"))
{
- if (Anope::CurTime < source.nc->lastmail + Config->GetModule(this->owner)->Get<time_t>("resenddelay"))
- source.Reply(_("Cannot send mail now; please retry a little later."));
- else if (SendRegmail(source.GetUser(), na, source.service))
- {
- na->nc->lastmail = Anope::CurTime;
- source.Reply(_("Your passcode has been re-sent to \002{0}\002."), na->nc->email);
- Log(LOG_COMMAND, source, this) << "to resend registration verification code";
- }
- else
- Log(this->owner) << "Unable to resend registration verification code for " << source.GetNick();
+ source.Reply(_("Cannot send mail now; please retry a little later."));
+ return;
}
+
+ if (!SendRegmail(source.GetUser(), na, source.service))
+ {
+ Log(this->owner) << "Unable to resend registration verification code for " << source.GetNick();
+ return;
+ }
+
+ na->nc->lastmail = Anope::CurTime;
+ source.Reply(_("Your passcode has been re-sent to \002{0}\002."), na->nc->email);
+ Log(LOG_COMMAND, source, this) << "to resend registration verification code";
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp
index 848fcc337..d89d16f3d 100644
--- a/modules/commands/ns_resetpass.cpp
+++ b/modules/commands/ns_resetpass.cpp
@@ -25,19 +25,24 @@ class CommandNSResetPass : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
- const NickServ::Nick *na;
+ const NickServ::Nick *na = NickServ::FindNick(params[0]);
- if (!(na = NickServ::FindNick(params[0])))
+ if (!na)
+ {
source.Reply(_("\002{0}\002 isn't registered."), params[0]);
- else if (!na->nc->email.equals_ci(params[1]))
+ return;
+ }
+
+ if (!na->nc->email.equals_ci(params[1]))
+ {
source.Reply(_("Incorrect email address."));
- else
+ return;
+ }
+
+ if (SendResetEmail(source.GetUser(), na, source.service))
{
- if (SendResetEmail(source.GetUser(), na, source.service))
- {
- Log(LOG_COMMAND, source, this) << "for " << na->nick << " (group: " << na->nc->display << ")";
- source.Reply(_("Password reset email for \002{0}\002 has been sent."), na->nick);
- }
+ Log(LOG_COMMAND, source, this) << "for " << na->nick << " (group: " << na->nc->display << ")";
+ source.Reply(_("Password reset email for \002{0}\002 has been sent."), na->nick);
}
}
diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp
index cec5e10b0..6178ae258 100644
--- a/modules/commands/ns_set.cpp
+++ b/modules/commands/ns_set.cpp
@@ -26,13 +26,10 @@ class CommandNSSet : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
this->OnSyntaxError(source, "");
- return;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
- this->SendSyntax(source);
- source.Reply(" ");
source.Reply(_("Sets various options on your account\n"
"\n"
"Available options:"));
@@ -87,8 +84,6 @@ class CommandNSSASet : public Command
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
{
- this->SendSyntax(source);
- source.Reply(" ");
source.Reply(_("Sets various options on other users accounts\n"
"\n"
"Available options:"));
@@ -305,14 +300,8 @@ class CommandNSSASetAutoOp : public CommandNSSetAutoOp
bool OnHelp(CommandSource &source, const Anope::string &) override
{
- BotInfo *bi = Config->GetClient("ChanServ");
- this->SendSyntax(source);
- source.Reply(" ");
- source.Reply(_("Sets whether the given nickname will be given its status modes\n"
- "in channels automatically. Set to \002ON\002 to allow %s\n"
- "to set status modes on the given nickname automatically when it\n"
- "is entering channels. Note that depending on channel settings\n"
- "some modes may not get set automatically."), bi ? bi->nick.c_str() : "ChanServ");
+ source.Reply(_("Sets whether the given nickname will be given their status modes automatically when they join a channel."
+ " Note that depending on channel settings some modes may not get set automatically."));
return true;
}
};
@@ -480,25 +469,22 @@ class CommandNSSetEmail : public Command
if (MOD_RESULT == EVENT_STOP)
return;
- if (!param.empty() && Config->GetModule("nickserv")->Get<bool>("confirmemailchanges") && !source.IsServicesOper())
+ if (param.empty())
+ {
+ Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to unset the email of " << nc->display;
+ nc->email.clear();
+ source.Reply(_("E-mail address for \002{0}\002 unset."), nc->display);
+ }
+ else if (Config->GetModule("nickserv")->Get<bool>("confirmemailchanges") && !source.IsServicesOper())
{
if (SendConfirmMail(source.GetUser(), source.service, param))
source.Reply(_("A confirmation e-mail has been sent to \002{0}\002. Follow the instructions in it to change your e-mail address."), param);
}
else
{
- if (!param.empty())
- {
- Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the email of " << nc->display << " to " << param;
- nc->email = param;
- source.Reply(_("E-mail address for \002{0}\002 changed to \002{1}\002."), nc->display, param);
- }
- else
- {
- Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to unset the email of " << nc->display;
- nc->email.clear();
- source.Reply(_("E-mail address for \002{0}\002 unset."), nc->display);
- }
+ Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the email of " << nc->display << " to " << param;
+ nc->email = param;
+ source.Reply(_("E-mail address for \002{0}\002 changed to \002{1}\002."), nc->display, param);
}
}
diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp
index d5b9b6e70..5dad0ece9 100644
--- a/modules/commands/os_akill.cpp
+++ b/modules/commands/os_akill.cpp
@@ -146,12 +146,14 @@ class CommandOSAKill : public Command
if (!akills->CanAdd(source, mask, expires, reason))
return;
- else if (mask.find_first_not_of("/~@.*?") == Anope::string::npos)
+
+ if (mask.find_first_not_of("/~@.*?") == Anope::string::npos)
{
source.Reply(_("\002{0}\002 coverage is too wide; Please use a more specific mask."), mask);
return;
}
- else if (mask.find('@') == Anope::string::npos)
+
+ if (mask.find('@') == Anope::string::npos)
{
source.Reply(_("Mask must be in the form \037user\037@\037host\037."));
return;
diff --git a/modules/commands/os_chankill.cpp b/modules/commands/os_chankill.cpp
index 0143c64af..8d3773e9d 100644
--- a/modules/commands/os_chankill.cpp
+++ b/modules/commands/os_chankill.cpp
@@ -29,7 +29,6 @@ class CommandOSChanKill : public Command
Anope::string expiry, channel;
unsigned last_param = 1;
- Channel *c;
channel = params[0];
if (!channel.empty() && channel[0] == '+')
@@ -42,13 +41,17 @@ class CommandOSChanKill : public Command
time_t expires = !expiry.empty() ? Anope::DoTime(expiry) : Config->GetModule("operserv")->Get<time_t>("autokillexpiry", "30d");
if (!expiry.empty() && isdigit(expiry[expiry.length() - 1]))
expires *= 86400;
- if (expires && expires < 60)
+
+ if (expires)
{
- source.Reply(_("Invalid expiry time \002{0}\002."), expiry);
- return;
- }
- else if (expires > 0)
+ if (expires < 60)
+ {
+ source.Reply(_("Invalid expiry time \002{0}\002."), expiry);
+ return;
+ }
+
expires += Anope::CurTime;
+ }
if (params.size() <= last_param)
{
@@ -59,33 +62,33 @@ class CommandOSChanKill : public Command
Anope::string reason = params[last_param];
if (params.size() > last_param + 1)
reason += params[last_param + 1];
- if (!reason.empty())
- {
- Anope::string realreason;
- if (Config->GetModule("operserv")->Get<bool>("addakiller") && !source.GetNick().empty())
- realreason = "[" + source.GetNick() + "] " + reason;
- else
- realreason = reason;
- if ((c = Channel::Find(channel)))
- {
- for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
- {
- ChanUserContainer *uc = it->second;
+ Anope::string realreason;
+ if (Config->GetModule("operserv")->Get<bool>("addakiller") && !source.GetNick().empty())
+ realreason = "[" + source.GetNick() + "] " + reason;
+ else
+ realreason = reason;
+
+ Channel *c = Channel::Find(channel);
+ if (!c)
+ {
+ source.Reply(_("Channel \002{0}\002 doesn't exist."), channel);
+ return;
+ }
- if (uc->user->server == Me || uc->user->HasMode("OPER"))
- continue;
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
+ {
+ ChanUserContainer *uc = it->second;
- XLine *x = new XLine("*@" + uc->user->host, source.GetNick(), expires, realreason, XLineManager::GenerateUID());
- akills->AddXLine(x);
- akills->OnMatch(uc->user, x);
- }
+ if (uc->user->server == Me || uc->user->HasMode("OPER"))
+ continue;
- Log(LOG_ADMIN, source, this) << "on " << c->name << " (" << realreason << ")";
- }
- else
- source.Reply(_("Channel \002%s\002 doesn't exist."), channel);
+ XLine *x = new XLine("*@" + uc->user->host, source.GetNick(), expires, realreason, XLineManager::GenerateUID());
+ akills->AddXLine(x);
+ akills->OnMatch(uc->user, x);
}
+
+ Log(LOG_ADMIN, source, this) << "on " << c->name << " (" << realreason << ")";
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp
index 20b687b4f..6509fd053 100644
--- a/modules/commands/os_defcon.cpp
+++ b/modules/commands/os_defcon.cpp
@@ -233,7 +233,6 @@ class CommandOSDefcon : public Command
/* Run any defcon functions, e.g. FORCE CHAN MODE */
runDefCon();
- return;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override