summaryrefslogtreecommitdiff
path: root/modules/commands/ns_group.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/commands/ns_group.cpp')
-rw-r--r--modules/commands/ns_group.cpp53
1 files changed, 25 insertions, 28 deletions
diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp
index 63d0dff10..acd85996c 100644
--- a/modules/commands/ns_group.cpp
+++ b/modules/commands/ns_group.cpp
@@ -1,6 +1,6 @@
/* NickServ core functions
*
- * (C) 2003-2016 Anope Team
+ * (C) 2003-2017 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
@@ -18,7 +18,7 @@ class NSGroupRequest : public IdentifyRequest
Command *cmd;
Anope::string nick;
Reference<NickAlias> target;
-
+
public:
NSGroupRequest(Module *o, CommandSource &src, Command *c, const Anope::string &n, NickAlias *targ, const Anope::string &pass) : IdentifyRequest(o, targ->nc->display, pass), source(src), cmd(c), nick(n), target(targ) { }
@@ -77,17 +77,16 @@ class CommandNSGroup : public Command
this->SetDesc(_("Join a group"));
this->SetSyntax(_("\037[target]\037 \037[password]\037"));
this->AllowUnregistered(true);
- this->RequireUser(true);
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- User *u = source.GetUser();
+ User *user = source.GetUser();
Anope::string nick;
if (params.empty())
{
- NickCore* core = u->Account();
+ NickCore* core = source.GetAccount();
if (core)
nick = core->display;
}
@@ -108,9 +107,9 @@ class CommandNSGroup : public Command
return;
}
- if (!IRCD->IsNickValid(u->nick))
+ if (!IRCD->IsNickValid(source.GetNick()))
{
- source.Reply(NICK_CANNOT_BE_REGISTERED, u->nick.c_str());
+ source.Reply(NICK_CANNOT_BE_REGISTERED, source.GetNick().c_str());
return;
}
@@ -119,21 +118,21 @@ class CommandNSGroup : public Command
{
Oper *o = Oper::opers[i];
- if (!u->HasMode("OPER") && u->nick.find_ci(o->name) != Anope::string::npos)
+ if (user != NULL && !user->HasMode("OPER") && user->nick.find_ci(o->name) != Anope::string::npos)
{
- source.Reply(NICK_CANNOT_BE_REGISTERED, u->nick.c_str());
+ source.Reply(NICK_CANNOT_BE_REGISTERED, user->nick.c_str());
return;
}
}
- NickAlias *target, *na = NickAlias::Find(u->nick);
+ NickAlias *target, *na = NickAlias::Find(source.GetNick());
const Anope::string &guestnick = Config->GetModule("nickserv")->Get<const Anope::string>("guestnickprefix", "Guest");
time_t reg_delay = Config->GetModule("nickserv")->Get<time_t>("regdelay");
unsigned maxaliases = Config->GetModule(this->owner)->Get<unsigned>("maxaliases");
if (!(target = NickAlias::Find(nick)))
source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
- else if (Anope::CurTime < u->lastnickreg + reg_delay)
- source.Reply(_("Please wait %d seconds before using the GROUP command again."), (reg_delay + u->lastnickreg) - Anope::CurTime);
+ else if (user && Anope::CurTime < user->lastnickreg + reg_delay)
+ source.Reply(_("Please wait %d seconds before using the GROUP command again."), (reg_delay + user->lastnickreg) - Anope::CurTime);
else if (target->nc->HasExt("NS_SUSPENDED"))
{
Log(LOG_COMMAND, source, this) << "and tried to group to SUSPENDED nick " << target->nick;
@@ -143,35 +142,35 @@ class CommandNSGroup : public Command
source.Reply(_("Your nick is already registered."));
else if (na && *target->nc == *na->nc)
source.Reply(_("You are already a member of the group of \002%s\002."), target->nick.c_str());
- else if (na && na->nc != u->Account())
+ else if (na && na->nc != source.GetAccount())
source.Reply(NICK_IDENTIFY_REQUIRED);
else if (maxaliases && target->nc->aliases->size() >= maxaliases && !target->nc->IsServicesOper())
source.Reply(_("There are too many nicks in your group."));
- else 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"))
+ else if (source.GetNick().length() <= guestnick.length() + 7 &&
+ source.GetNick().length() >= guestnick.length() + 1 &&
+ !source.GetNick().find_ci(guestnick) && !source.GetNick().substr(guestnick.length()).find_first_not_of("1234567890"))
{
- source.Reply(NICK_CANNOT_BE_REGISTERED, u->nick.c_str());
+ source.Reply(NICK_CANNOT_BE_REGISTERED, source.GetNick().c_str());
}
else
{
bool ok = false;
- if (!na && u->Account() == target->nc)
+ if (!na && source.GetAccount() == target->nc)
ok = true;
NSCertList *cl = target->nc->GetExt<NSCertList>("certificates");
- if (!u->fingerprint.empty() && cl && cl->FindCert(u->fingerprint))
+ if (user != NULL && !user->fingerprint.empty() && cl && cl->FindCert(user->fingerprint))
ok = true;
if (ok == false && !pass.empty())
{
- NSGroupRequest *req = new NSGroupRequest(owner, source, this, u->nick, target, pass);
+ NSGroupRequest *req = new NSGroupRequest(owner, source, this, source.GetNick(), target, pass);
FOREACH_MOD(OnCheckAuthentication, (source.GetUser(), req));
req->Dispatch();
}
else
{
- NSGroupRequest req(owner, source, this, u->nick, target, pass);
+ NSGroupRequest req(owner, source, this, source.GetNick(), target, pass);
if (ok)
req.OnSuccess();
@@ -222,20 +221,18 @@ class CommandNSUngroup : public Command
{
this->SetDesc(_("Remove a nick from a group"));
this->SetSyntax(_("[\037nick\037]"));
- this->RequireUser(true);
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- User *u = source.GetUser();
Anope::string nick = !params.empty() ? params[0] : "";
- NickAlias *na = NickAlias::Find(!nick.empty() ? nick : u->nick);
+ NickAlias *na = NickAlias::Find(!nick.empty() ? nick : source.GetNick());
- if (u->Account()->aliases->size() == 1)
+ if (source.GetAccount()->aliases->size() == 1)
source.Reply(_("Your nick is not grouped to anything, you can't ungroup it."));
else if (!na)
- source.Reply(NICK_X_NOT_REGISTERED, !nick.empty() ? nick.c_str() : u->nick.c_str());
- else if (na->nc != u->Account())
+ source.Reply(NICK_X_NOT_REGISTERED, !nick.empty() ? nick.c_str() : source.GetNick().c_str());
+ else if (na->nc != source.GetAccount())
source.Reply(_("Nick %s is not in your group."), na->nick.c_str());
else
{
@@ -338,7 +335,7 @@ class CommandNSGList : public Command
source.Reply(!nick.empty() ? _("List of nicknames in the group of \002%s\002:") : _("List of nicknames in your group:"), nc->display.c_str());
std::vector<Anope::string> replies;
list.Process(replies);
-
+
for (unsigned i = 0; i < replies.size(); ++i)
source.Reply(replies[i]);