2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2017-2019 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2015, 2017-2018 Attila Molnar <attilamolnar@hush.com>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "modules/cap.h"
23 #include "modules/ircv3.h"
25 class ModuleIRCv3ChgHost : public Module
28 ClientProtocol::EventProvider protoevprov;
30 void DoChgHost(User* user, const std::string& ident, const std::string& host)
32 if (!(user->registered & REG_NICKUSER))
35 ClientProtocol::Message msg("CHGHOST", user);
36 msg.PushParamRef(ident);
37 msg.PushParamRef(host);
38 ClientProtocol::Event protoev(protoevprov, msg);
39 IRCv3::WriteNeighborsWithCap(user, protoev, cap, true);
44 : cap(this, "chghost")
45 , protoevprov(this, "CHGHOST")
49 void OnChangeIdent(User* user, const std::string& newident) CXX11_OVERRIDE
51 DoChgHost(user, newident, user->GetDisplayedHost());
54 void OnChangeHost(User* user, const std::string& newhost) CXX11_OVERRIDE
56 DoChgHost(user, user->ident, newhost);
59 Version GetVersion() CXX11_OVERRIDE
61 return Version("Provides the IRCv3 chghost client capability.", VF_VENDOR);
65 MODULE_INIT(ModuleIRCv3ChgHost)