summaryrefslogtreecommitdiff
path: root/modules/commands/hs_group.cpp
diff options
context:
space:
mode:
authorDaniel Vassdal <shutter@canternet.org>2014-03-05 15:58:55 -0800
committerDaniel Vassdal <shutter@canternet.org>2014-03-06 04:55:30 -0800
commit051a42b547ee5ec40be09f5dc9fce2f202792ada (patch)
treef9e08f2ecfc9beb5a4a070e7ad0b721b2b73228d /modules/commands/hs_group.cpp
parent220e2782136f47edd3504b196659ade936b6846b (diff)
hs_group: Allow automatic HS GROUP-ing on NS GROUP, and allow vhosts to be per account rather than nick.
Diffstat (limited to 'modules/commands/hs_group.cpp')
-rw-r--r--modules/commands/hs_group.cpp40
1 files changed, 37 insertions, 3 deletions
diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp
index 568749080..a238c3f99 100644
--- a/modules/commands/hs_group.cpp
+++ b/modules/commands/hs_group.cpp
@@ -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");
}
};