diff options
author | Adam <Adam@anope.org> | 2013-05-08 10:40:46 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-05-08 10:40:46 -0400 |
commit | d7e2ab688b73a9316a75fd8cd39dc676a6e39a7f (patch) | |
tree | a655ccc76b7b57c2b7ba71226543775d35d6e4dd /modules/pseudoclients/hostserv.cpp | |
parent | 5e7085130eb245e6ab9d44c04816ad62a324cd43 (diff) |
Add activate_on_set option for hostserv
Diffstat (limited to 'modules/pseudoclients/hostserv.cpp')
-rw-r--r-- | modules/pseudoclients/hostserv.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
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) |