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 std::string msg = "INVITE ";
36 msg.append(dest->nick).append(1, ' ').append(chan->name);
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 // Send and add the user to the exceptions so they won't get the NOTICE invite announcement message
51 user->WriteFrom(source, msg);
52 notifyexcepts.insert(user);
56 void Prioritize() CXX11_OVERRIDE
58 // Prioritize after all modules to see all excepted users
59 ServerInstance->Modules.SetPriority(this, I_OnUserInvite, PRIORITY_LAST);
62 Version GetVersion() CXX11_OVERRIDE
64 return Version("Provides the invite-notify IRCv3.2 extension", VF_VENDOR);
68 MODULE_INIT(ModuleIRCv3InviteNotify)