summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <adam@sigterm.info>2014-03-10 07:32:24 -0400
committerAdam <adam@sigterm.info>2014-03-10 07:32:24 -0400
commitca6b3723a93c60ad2f0ec50074189d4bedcf32bc (patch)
treec0c136324a6548c5be01d6ffa8fbabe9a922412e
parent23b10860725db1e3116ada6475e3884a1017205c (diff)
parent98cfdd26c48880cfaa973670be72fe99e9462ef5 (diff)
Merge pull request #64 from ShutterQuick/2.0+hsgroupsync
2.0+hsgroupsync
-rw-r--r--data/hostserv.example.conf15
-rw-r--r--modules/commands/hs_group.cpp40
-rw-r--r--modules/commands/ns_group.cpp22
3 files changed, 70 insertions, 7 deletions
diff --git a/data/hostserv.example.conf b/data/hostserv.example.conf
index f5109db4c..e13e8fdd1 100644
--- a/data/hostserv.example.conf
+++ b/data/hostserv.example.conf
@@ -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"; }
/*
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");
}
};
diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp
index 78c4e164a..04842b3e3 100644
--- a/modules/commands/ns_group.cpp
+++ b/modules/commands/ns_group.cpp
@@ -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)