From 6302f980fe6dad83aab7d2dc1046dadea5ffd939 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 14 Dec 2015 16:52:24 -0500 Subject: New source tree structure for modules. From commands/cs_access => chanserv/access etc. --- modules/pseudoclients/hostserv.cpp | 135 ------------------------------------- 1 file changed, 135 deletions(-) delete mode 100644 modules/pseudoclients/hostserv.cpp (limited to 'modules/pseudoclients/hostserv.cpp') diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp deleted file mode 100644 index 285ea893b..000000000 --- a/modules/pseudoclients/hostserv.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* HostServ core functions - * - * (C) 2003-2014 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - -#include "module.h" -#include "modules/ns_update.h" -#include "modules/hs_del.h" -#include "modules/help.h" - -class HostServCore : public Module - , public EventHook - , public EventHook - , public EventHook - , public EventHook - , public EventHook -{ - Reference HostServ; - - public: - HostServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) - { - if (!IRCD || !IRCD->CanSetVHost) - throw ModuleException("Your IRCd does not support vhosts"); - } - - void OnReload(Configuration::Conf *conf) override - { - const Anope::string &hsnick = conf->GetModule(this)->Get("client"); - - if (hsnick.empty()) - throw ConfigException(Module::name + ": must be defined"); - - ServiceBot *bi = ServiceBot::Find(hsnick, true); - if (!bi) - throw ConfigException(Module::name + ": no bot named " + hsnick); - - HostServ = bi; - } - - void OnUserLogin(User *u) override - { - if (!IRCD->CanSetVHost) - return; - - NickServ::Nick *na = NickServ::FindNick(u->nick); - if (!na || na->GetAccount() != u->Account() || !na->HasVhost()) - na = NickServ::FindNick(u->Account()->GetDisplay()); - if (!na || !na->HasVhost()) - return; - - if (u->vhost.empty() || !u->vhost.equals_cs(na->GetVhostHost()) || (!na->GetVhostIdent().empty() && !u->GetVIdent().equals_cs(na->GetVhostIdent()))) - { - 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 OnNickUpdate(User *u) override - { - this->OnUserLogin(u); - } - - EventReturn OnPreHelp(CommandSource &source, const std::vector ¶ms) override - { - if (!params.empty() || source.c || source.service != *HostServ) - return EVENT_CONTINUE; - source.Reply(_("%s commands:"), HostServ->nick.c_str()); - return EVENT_CONTINUE; - } - - void OnPostHelp(CommandSource &source, const std::vector ¶ms) override - { - } - - void OnSetVhost(NickServ::Nick *na) override - { - if (Config->GetModule(this)->Get("activate_on_set")) - { - User *u = User::Find(na->GetNick()); - - if (u && u->Account() == na->GetAccount()) - { - 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(NickServ::Nick *na) override - { - if (Config->GetModule(this)->Get("activate_on_set")) - { - User *u = User::Find(na->GetNick()); - - if (u && u->Account() == na->GetAccount()) - IRCD->SendVhostDel(u); - } - } -}; - -MODULE_INIT(HostServCore) - -- cgit