summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2017-07-24 10:04:07 -0400
committerAdam <Adam@anope.org>2017-07-24 10:04:07 -0400
commit0b7b6d9d6d55fc0398fb330e95c43e1c34c6ae2d (patch)
tree3867d65a0ced8744192c011a878507d8fbe4bd82
parent56e6efbe8f3b641389cad3ac00d09d1652c4eea5 (diff)
ns_group: don't require a user to group
-rw-r--r--modules/commands/ns_group.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp
index acd85996c..abe0303cb 100644
--- a/modules/commands/ns_group.cpp
+++ b/modules/commands/ns_group.cpp
@@ -24,45 +24,58 @@ class NSGroupRequest : public IdentifyRequest
void OnSuccess() anope_override
{
- if (!source.GetUser() || source.GetUser()->nick != nick || !target || !target->nc)
+ User *u = source.GetUser();
+
+ /* user changed nick? */
+ if (u != NULL && u->nick != nick)
+ return;
+
+ if (!target || !target->nc)
return;
- User *u = source.GetUser();
NickAlias *na = NickAlias::Find(nick);
/* If the nick is already registered, drop it. */
if (na)
{
- FOREACH_MOD(OnChangeCoreDisplay, (na->nc, u->nick));
delete na;
}
na = new NickAlias(nick, target->nc);
-
- Anope::string last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost();
- na->last_usermask = last_usermask;
- na->last_realname = u->realname;
na->time_registered = na->last_seen = Anope::CurTime;
- u->Login(target->nc);
- FOREACH_MOD(OnNickGroup, (u, target));
+ if (u != NULL)
+ {
+ na->last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost();
+ na->last_realname = u->realname;
+ }
+ else
+ {
+ na->last_realname = source.GetNick();
+ }
+
+ if (u != NULL)
+ {
+ u->Login(target->nc);
+ FOREACH_MOD(OnNickGroup, (u, target));
+ }
Log(LOG_COMMAND, source, cmd) << "to make " << nick << " join group of " << target->nick << " (" << target->nc->display << ") (email: " << (!target->nc->email.empty() ? target->nc->email : "none") << ")";
source.Reply(_("You are now in the group of \002%s\002."), target->nick.c_str());
- u->lastnickreg = Anope::CurTime;
-
+ if (u)
+ u->lastnickreg = Anope::CurTime;
}
void OnFail() anope_override
{
- if (!source.GetUser())
- return;
+ User *u = source.GetUser();
Log(LOG_COMMAND, source, cmd) << "and failed to group to " << target->nick;
if (NickAlias::Find(GetAccount()) != NULL)
{
source.Reply(PASSWORD_INCORRECT);
- source.GetUser()->BadPassword();
+ if (u)
+ u->BadPassword();
}
else
source.Reply(NICK_X_NOT_REGISTERED, GetAccount().c_str());