summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-05-08 10:40:46 -0400
committerAdam <Adam@anope.org>2013-05-08 10:40:46 -0400
commitd7e2ab688b73a9316a75fd8cd39dc676a6e39a7f (patch)
treea655ccc76b7b57c2b7ba71226543775d35d6e4dd
parent5e7085130eb245e6ab9d44c04816ad62a324cd43 (diff)
Add activate_on_set option for hostserv
-rw-r--r--data/hostserv.example.conf5
-rw-r--r--modules/pseudoclients/hostserv.cpp41
2 files changed, 45 insertions, 1 deletions
diff --git a/data/hostserv.example.conf b/data/hostserv.example.conf
index 10063ae7d..95957b7c1 100644
--- a/data/hostserv.example.conf
+++ b/data/hostserv.example.conf
@@ -64,6 +64,11 @@ module
* The name of the client that should be HostServ.
*/
client = "HostServ"
+
+ /*
+ * If enabled, vhosts are activated on users immediately when they are set.
+ */
+ activate_on_set = false
}
/*
diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp
index cd3c84d55..e3afa37d3 100644
--- a/modules/pseudoclients/hostserv.cpp
+++ b/modules/pseudoclients/hostserv.cpp
@@ -22,7 +22,8 @@ class HostServCore : public Module
if (!IRCD || !IRCD->CanSetVHost)
throw ModuleException("Your IRCd does not support vhosts");
- Implementation i[] = { I_OnReload, I_OnBotDelete, I_OnNickIdentify, I_OnNickUpdate, I_OnPreHelp };
+ Implementation i[] = { I_OnReload, I_OnBotDelete, I_OnNickIdentify, I_OnNickUpdate, I_OnPreHelp,
+ I_OnSetVhost, I_OnDeleteVhost };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
}
@@ -91,6 +92,44 @@ class HostServCore : public Module
source.Reply(_("%s commands:"), HostServ->nick.c_str());
return EVENT_CONTINUE;
}
+
+ void OnSetVhost(NickAlias *na) anope_override
+ {
+ if (Config->GetModule(this)->Get<bool>("activate_on_set"))
+ {
+ User *u = User::Find(na->nick);
+
+ if (u && u->Account() == na->nc)
+ {
+ IRCD->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost());
+
+ u->vhost = na->GetVhostHost();
+ u->UpdateHost();
+
+ if (IRCD->CanSetVIdent && !na->GetVhostIdent().empty())
+ u->SetVIdent(na->GetVhostIdent());
+
+ if (HostServ)
+ {
+ if (!na->GetVhostIdent().empty())
+ u->SendMessage(HostServ, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str());
+ else
+ u->SendMessage(HostServ, _("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str());
+ }
+ }
+ }
+ }
+
+ void OnDeleteVhost(NickAlias *na) anope_override
+ {
+ if (Config->GetModule(this)->Get<bool>("activate_on_set"))
+ {
+ User *u = User::Find(na->nick);
+
+ if (u && u->Account() == na->nc)
+ IRCD->SendVhostDel(u);
+ }
+ }
};
MODULE_INIT(HostServCore)