mirror of
https://github.com/anope/anope.git
synced 2026-06-12 17:24:49 +02:00
Move setting the display nickname to ns_group.
This commit is contained in:
@@ -399,7 +399,12 @@ command { service = "NickServ"; name = "SASET EMAIL"; command = "nickserv/saset/
|
||||
/*
|
||||
* ns_group
|
||||
*
|
||||
* Provides the commands nickserv/group, nickserv/glist, and nickserv/ungroup.
|
||||
* Provides the commands:
|
||||
* nickserv/group
|
||||
* nickserv/ungroup
|
||||
* nickserv/glist
|
||||
* nickserv/saset/display
|
||||
* nickserv/set/display
|
||||
*
|
||||
* Used for controlling grouped nicknames.
|
||||
*/
|
||||
@@ -426,6 +431,12 @@ module
|
||||
command { service = "NickServ"; name = "GLIST"; command = "nickserv/glist"; }
|
||||
command { service = "NickServ"; name = "GROUP"; command = "nickserv/group"; }
|
||||
command { service = "NickServ"; name = "UNGROUP"; command = "nickserv/ungroup"; }
|
||||
command { service = "NickServ"; name = "SET DISPLAY"; command = "nickserv/set/display"; }
|
||||
command { service = "NickServ"; name = "SASET DISPLAY"; command = "nickserv/saset/display"; permission = "nickserv/saset/display"; }
|
||||
|
||||
# For compatibility with Atheme.
|
||||
command { service = "NickServ"; name = "SET ACCOUNTNAME"; command = "nickserv/set/display"; hide = yes; }
|
||||
command { service = "NickServ"; name = "SASET ACCOUNTNAME"; command = "nickserv/saset/display"; permission = "nickserv/saset/display"; hide = yes; }
|
||||
|
||||
/*
|
||||
* ns_identify
|
||||
@@ -645,8 +656,6 @@ module { name = "ns_sasl_plain" }
|
||||
*
|
||||
* Provides the commands:
|
||||
* nickserv/set, nickserv/saset - Dummy help wrappers for the SET and SASET commands.
|
||||
* nickserv/set/display, nickserv/saset/display - Used for setting a users display name.
|
||||
* nickserv/set/keepmodes, nickserv/saset/keepmodes - Configure whether or not services should retain a user's modes across sessions.
|
||||
* nickserv/saset/noexpire - Used for configuring noexpire, which prevents nicks from expiring.
|
||||
* nickserv/set/password, nickserv/saset/password - Used for changing a users password.
|
||||
*/
|
||||
@@ -655,9 +664,6 @@ module { name = "ns_set" }
|
||||
command { service = "NickServ"; name = "SET"; command = "nickserv/set"; }
|
||||
command { service = "NickServ"; name = "SASET"; command = "nickserv/saset"; permission = "nickserv/saset/"; group = "nickserv/admin"; }
|
||||
|
||||
command { service = "NickServ"; name = "SET DISPLAY"; command = "nickserv/set/display"; }
|
||||
command { service = "NickServ"; name = "SASET DISPLAY"; command = "nickserv/saset/display"; permission = "nickserv/saset/display"; }
|
||||
|
||||
command { service = "NickServ"; name = "SET PASSWORD"; command = "nickserv/set/password"; }
|
||||
command { service = "NickServ"; name = "SASET PASSWORD"; command = "nickserv/saset/password"; permission = "nickserv/saset/password"; }
|
||||
|
||||
|
||||
@@ -388,16 +388,118 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class CommandNSSetDisplay
|
||||
: public Command
|
||||
{
|
||||
public:
|
||||
CommandNSSetDisplay(Module *creator, const Anope::string &sname = "nickserv/set/display", size_t min = 1)
|
||||
: Command(creator, sname, min, min + 1)
|
||||
{
|
||||
this->SetDesc(_("Set the display nickname for your account"));
|
||||
this->SetSyntax(_("\037new-display\037"));
|
||||
}
|
||||
|
||||
void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
|
||||
{
|
||||
if (Anope::ReadOnly)
|
||||
{
|
||||
source.Reply(READ_ONLY_MODE);
|
||||
return;
|
||||
}
|
||||
|
||||
auto *user_na = NickAlias::Find(user);
|
||||
if (!user_na)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
auto *na = NickAlias::Find(param);
|
||||
if (!na || *na->nc != *user_na->nc)
|
||||
{
|
||||
source.Reply(_("The new display nickname must belong to the %s account."), user_na->nc->display.c_str());
|
||||
return;
|
||||
}
|
||||
NickCore *user_nc = user_na->nc;
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, user_nc, param));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
Log(user_nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the display of " << user_nc->display << " to " << na->nick;
|
||||
user_nc->SetDisplay(na);
|
||||
|
||||
// Send updated account name to the IRCd.
|
||||
for (auto *u : user_nc->users)
|
||||
IRCD->SendLogin(u, user_na);
|
||||
|
||||
source.Reply(NICK_SET_DISPLAY_CHANGED, user_nc->display.c_str());
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
|
||||
{
|
||||
this->Run(source, source.nc->display, params[0]);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_(
|
||||
"Changes the display nickname used to refer to your account. The new display "
|
||||
"nickname must already be associated with your account."
|
||||
));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class CommandNSSASetDisplay final
|
||||
: public CommandNSSetDisplay
|
||||
{
|
||||
public:
|
||||
CommandNSSASetDisplay(Module *creator)
|
||||
: CommandNSSetDisplay(creator, "nickserv/saset/display", 2)
|
||||
{
|
||||
this->ClearSyntax();
|
||||
this->SetSyntax(_("\037nickname\037 \037new-display\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
|
||||
{
|
||||
this->Run(source, params[0], params[1]);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_(
|
||||
"Changes the display nickname used to refer to the account. The new display"
|
||||
"nickname must already be associated with the account."
|
||||
));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class NSGroup final
|
||||
: public Module
|
||||
{
|
||||
private:
|
||||
CommandNSGroup commandnsgroup;
|
||||
CommandNSUngroup commandnsungroup;
|
||||
CommandNSGList commandnsglist;
|
||||
CommandNSSetDisplay commandnssetdisplay;
|
||||
CommandNSSASetDisplay commandnssasetdisplay;
|
||||
|
||||
public:
|
||||
NSGroup(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandnsgroup(this), commandnsungroup(this), commandnsglist(this)
|
||||
NSGroup(const Anope::string &modname, const Anope::string &creator)
|
||||
: Module(modname, creator, VENDOR)
|
||||
, commandnsgroup(this)
|
||||
, commandnsungroup(this)
|
||||
, commandnsglist(this)
|
||||
, commandnssetdisplay(this)
|
||||
, commandnssasetdisplay(this)
|
||||
{
|
||||
if (Config->GetModule("nickserv").Get<bool>("nonicknameownership"))
|
||||
throw ModuleException(modname + " can not be used with options:nonicknameownership enabled");
|
||||
|
||||
@@ -248,105 +248,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class CommandNSSetDisplay
|
||||
: public Command
|
||||
{
|
||||
public:
|
||||
CommandNSSetDisplay(Module *creator, const Anope::string &sname = "nickserv/set/display", size_t min = 1) : Command(creator, sname, min, min + 1)
|
||||
{
|
||||
this->SetDesc(_("Set the display nickname for your account"));
|
||||
this->SetSyntax(_("\037new-display\037"));
|
||||
}
|
||||
|
||||
void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
|
||||
{
|
||||
if (Anope::ReadOnly)
|
||||
{
|
||||
source.Reply(READ_ONLY_MODE);
|
||||
return;
|
||||
}
|
||||
|
||||
NickAlias *user_na = NickAlias::Find(user), *na = NickAlias::Find(param);
|
||||
|
||||
if (Config->GetModule("nickserv").Get<bool>("nonicknameownership"))
|
||||
{
|
||||
source.Reply(_("This command may not be used on this network because nickname ownership is disabled."));
|
||||
return;
|
||||
}
|
||||
if (user_na == NULL)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
|
||||
return;
|
||||
}
|
||||
else if (!na || *na->nc != *user_na->nc)
|
||||
{
|
||||
source.Reply(_("The new display nickname must belong to the %s account."), user_na->nc->display.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, user_na->nc, param));
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
Log(user_na->nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the display of " << user_na->nc->display << " to " << na->nick;
|
||||
|
||||
user_na->nc->SetDisplay(na);
|
||||
|
||||
/* Send updated account name */
|
||||
for (std::list<User *>::iterator it = user_na->nc->users.begin(); it != user_na->nc->users.end(); ++it)
|
||||
{
|
||||
User *u = *it;
|
||||
IRCD->SendLogin(u, user_na);
|
||||
}
|
||||
|
||||
source.Reply(NICK_SET_DISPLAY_CHANGED, user_na->nc->display.c_str());
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
|
||||
{
|
||||
this->Run(source, source.nc->display, params[0]);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_(
|
||||
"Changes the display nickname used to refer to your account. The new display "
|
||||
"nickname must already be associated with your account."
|
||||
));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class CommandNSSASetDisplay final
|
||||
: public CommandNSSetDisplay
|
||||
{
|
||||
public:
|
||||
CommandNSSASetDisplay(Module *creator) : CommandNSSetDisplay(creator, "nickserv/saset/display", 2)
|
||||
{
|
||||
this->ClearSyntax();
|
||||
this->SetSyntax(_("\037nickname\037 \037new-display\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override
|
||||
{
|
||||
this->Run(source, params[0], params[1]);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_(
|
||||
"Changes the display nickname used to refer to the account. The new display"
|
||||
"nickname must already be associated with the account."
|
||||
));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class CommandNSSASetNoexpire final
|
||||
: public Command
|
||||
{
|
||||
@@ -408,9 +309,6 @@ class NSSet final
|
||||
CommandNSSet commandnsset;
|
||||
CommandNSSASet commandnssaset;
|
||||
|
||||
CommandNSSetDisplay commandnssetdisplay;
|
||||
CommandNSSASetDisplay commandnssasetdisplay;
|
||||
|
||||
CommandNSSetPassword commandnssetpassword;
|
||||
CommandNSSASetPassword commandnssasetpassword;
|
||||
|
||||
@@ -421,7 +319,6 @@ class NSSet final
|
||||
public:
|
||||
NSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandnsset(this), commandnssaset(this),
|
||||
commandnssetdisplay(this), commandnssasetdisplay(this),
|
||||
commandnssetpassword(this), commandnssasetpassword(this),
|
||||
commandnssasetnoexpire(this),
|
||||
noexpire(this, "NS_NO_EXPIRE")
|
||||
|
||||
Reference in New Issue
Block a user