summaryrefslogtreecommitdiff
path: root/modules/commands/hs_group.cpp
diff options
context:
space:
mode:
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");
}
};