2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2015 Attila Molnar <attilamolnar@hush.com>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "modules/cap.h"
23 class ModuleIRCv3InviteNotify : public Module
28 ModuleIRCv3InviteNotify()
29 : cap(this, "invite-notify")
33 void OnUserInvite(User* source, User* dest, Channel* chan, time_t expiry, unsigned int notifyrank, CUList& notifyexcepts) CXX11_OVERRIDE
35 ClientProtocol::Messages::Invite invitemsg(source, dest, chan);
36 ClientProtocol::Event inviteevent(ServerInstance->GetRFCEvents().invite, invitemsg);
37 const Channel::MemberMap& users = chan->GetUsers();
38 for (Channel::MemberMap::const_iterator i = users.begin(); i != users.end(); ++i)
40 User* user = i->first;
41 // Skip members who don't use this extension or were excluded by other modules
42 if ((!cap.get(user)) || (notifyexcepts.count(user)))
45 Membership* memb = i->second;
46 // Check whether the member has a high enough rank to see the notification
47 if (memb->getRank() < notifyrank)
50 // Caps are only set on local users
51 LocalUser* const localuser = static_cast<LocalUser*>(user);
52 // Send and add the user to the exceptions so they won't get the NOTICE invite announcement message
53 localuser->Send(inviteevent);
54 notifyexcepts.insert(user);
58 void Prioritize() CXX11_OVERRIDE
60 // Prioritize after all modules to see all excepted users
61 ServerInstance->Modules.SetPriority(this, I_OnUserInvite, PRIORITY_LAST);
64 Version GetVersion() CXX11_OVERRIDE
66 return Version("Provides the invite-notify IRCv3 extension", VF_VENDOR);
70 MODULE_INIT(ModuleIRCv3InviteNotify)