1
0
mirror of https://github.com/anope/anope.git synced 2026-07-03 15:13:14 +02:00

Merge pull request #64 from ShutterQuick/2.0+hsgroupsync

2.0+hsgroupsync
This commit is contained in:
Adam
2014-03-10 07:32:24 -04:00
3 changed files with 70 additions and 7 deletions
+14 -1
View File
@@ -103,7 +103,20 @@ command { service = "HostServ"; name = "DELALL"; command = "hostserv/delall"; pe
*
* Used for grouping one vHost to many nicks.
*/
module { name = "hs_group" }
module
{
name = "hs_group"
/*
* Upon nickserv/group, this option syncs the nick's main vHost to the grouped nick.
*/
syncongroup = false
/*
* This makes vhosts act as if they are per account.
*/
synconset = false
}
command { service = "HostServ"; name = "GROUP"; command = "hostserv/group"; }
/*
+37 -3
View File
@@ -13,21 +13,31 @@
class CommandHSGroup : public Command
{
bool setting;
public:
void Sync(const NickAlias *na)
{
if (setting)
return;
if (!na || !na->HasVhost())
return;
setting = true;
for (unsigned i = 0; i < na->nc->aliases->size(); ++i)
{
NickAlias *nick = na->nc->aliases->at(i);
if (nick)
{
nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
FOREACH_MOD(OnSetVhost, (nick));
}
}
setting = false;
}
public:
CommandHSGroup(Module *creator) : Command(creator, "hostserv/group", 0, 0)
CommandHSGroup(Module *creator) : Command(creator, "hostserv/group", 0, 0), setting(false)
{
this->SetDesc(_("Syncs the vhost for all nicks in a group"));
}
@@ -69,12 +79,36 @@ class CommandHSGroup : public Command
class HSGroup : public Module
{
CommandHSGroup commandhsgroup;
bool syncongroup;
bool synconset;
public:
HSGroup(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
commandhsgroup(this)
{
}
void OnSetVhost(NickAlias *na) anope_override
{
if (!synconset)
return;
commandhsgroup.Sync(na);
}
void OnNickGroup(User *u, NickAlias *na) anope_override
{
if (!syncongroup)
return;
commandhsgroup.Sync(na);
}
void OnReload(Configuration::Conf *conf) anope_override
{
Configuration::Block *block = conf->GetModule(this);
syncongroup = block->Get<bool>("syncongroup");
synconset = block->Get<bool>("synconset");
}
};
+19 -3
View File
@@ -72,10 +72,10 @@ class NSGroupRequest : public IdentifyRequest
class CommandNSGroup : public Command
{
public:
CommandNSGroup(Module *creator) : Command(creator, "nickserv/group", 1, 2)
CommandNSGroup(Module *creator) : Command(creator, "nickserv/group", 0, 2)
{
this->SetDesc(_("Join a group"));
this->SetSyntax(_("\037target\037 \037password\037"));
this->SetSyntax(_("\037[target]\037 \037[password]\037"));
this->AllowUnregistered(true);
this->RequireUser(true);
}
@@ -83,7 +83,23 @@ class CommandNSGroup : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
User *u = source.GetUser();
const Anope::string &nick = params[0];
Anope::string nick;
if (params.empty())
{
NickCore* core = u->Account();
if (core)
nick = core->display;
}
else
nick = params[0];
if (nick.empty())
{
this->SendSyntax(source);
return;
}
const Anope::string &pass = params.size() > 1 ? params[1] : "";
if (Anope::ReadOnly)