2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2015, 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"
24 class ModuleIRCv3InviteNotify : public Module
29 ModuleIRCv3InviteNotify()
30 : cap(this, "invite-notify")
34 void OnUserInvite(User* source, User* dest, Channel* chan, time_t expiry, unsigned int notifyrank, CUList& notifyexcepts) CXX11_OVERRIDE
36 ClientProtocol::Messages::Invite invitemsg(source, dest, chan);
37 ClientProtocol::Event inviteevent(ServerInstance->GetRFCEvents().invite, invitemsg);
38 const Channel::MemberMap& users = chan->GetUsers();
39 for (Channel::MemberMap::const_iterator i = users.begin(); i != users.end(); ++i)
41 User* user = i->first;
42 // Skip members who don't use this extension or were excluded by other modules
43 if ((!cap.get(user)) || (notifyexcepts.count(user)))
46 Membership* memb = i->second;
47 // Check whether the member has a high enough rank to see the notification
48 if (memb->getRank() < notifyrank)
51 // Caps are only set on local users
52 LocalUser* const localuser = static_cast<LocalUser*>(user);
53 // Send and add the user to the exceptions so they won't get the NOTICE invite announcement message
54 localuser->Send(inviteevent);
55 notifyexcepts.insert(user);
59 void Prioritize() CXX11_OVERRIDE
61 // Prioritize after all modules to see all excepted users
62 ServerInstance->Modules.SetPriority(this, I_OnUserInvite, PRIORITY_LAST);
65 Version GetVersion() CXX11_OVERRIDE
67 return Version("Provides the invite-notify IRCv3 extension", VF_VENDOR);
71 MODULE_INIT(ModuleIRCv3InviteNotify)