]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_ircv3_chghost.cpp
Fix the cloaking module on C++98 compilers.
[user/henk/code/inspircd.git] / src / modules / m_ircv3_chghost.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2017-2019 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2015, 2018 Attila Molnar <attilamolnar@hush.com>
6  *
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.
10  *
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
14  * details.
15  *
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/>.
18  */
19
20
21 #include "inspircd.h"
22 #include "modules/cap.h"
23 #include "modules/ircv3.h"
24
25 class ModuleIRCv3ChgHost : public Module
26 {
27         Cap::Capability cap;
28         ClientProtocol::EventProvider protoevprov;
29
30         void DoChgHost(User* user, const std::string& ident, const std::string& host)
31         {
32                 if (!(user->registered & REG_NICKUSER))
33                         return;
34
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);
40         }
41
42  public:
43         ModuleIRCv3ChgHost()
44                 : cap(this, "chghost")
45                 , protoevprov(this, "CHGHOST")
46         {
47         }
48
49         void OnChangeIdent(User* user, const std::string& newident) CXX11_OVERRIDE
50         {
51                 DoChgHost(user, newident, user->GetDisplayedHost());
52         }
53
54         void OnChangeHost(User* user, const std::string& newhost) CXX11_OVERRIDE
55         {
56                 DoChgHost(user, user->ident, newhost);
57         }
58
59         Version GetVersion() CXX11_OVERRIDE
60         {
61                 return Version("Provides the IRCv3 chghost client capability.", VF_VENDOR);
62         }
63 };
64
65 MODULE_INIT(ModuleIRCv3ChgHost)