]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_allowinvite.cpp
330feccb7bfa44f4cca292534bb5168559daa1f0
[user/henk/code/inspircd.git] / src / modules / m_allowinvite.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
5  *
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.
9  *
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
13  * details.
14  *
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/>.
17  */
18
19
20 #include "inspircd.h"
21
22 class ModuleAllowInvite : public Module
23 {
24         SimpleChannelModeHandler ni;
25  public:
26
27         ModuleAllowInvite()
28                 : ni(this, "allowinvite", 'A')
29         {
30         }
31
32         void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
33         {
34                 tokens["EXTBAN"].push_back('A');
35         }
36
37         ModResult OnUserPreInvite(User* user,User* dest,Channel* channel, time_t timeout) CXX11_OVERRIDE
38         {
39                 if (IS_LOCAL(user))
40                 {
41                         ModResult res = channel->GetExtBanStatus(user, 'A');
42                         if (res == MOD_RES_DENY)
43                         {
44                                 // Matching extban, explicitly deny /invite
45                                 user->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, "You are banned from using INVITE");
46                                 return res;
47                         }
48                         if (channel->IsModeSet(ni) || res == MOD_RES_ALLOW)
49                         {
50                                 // Explicitly allow /invite
51                                 return MOD_RES_ALLOW;
52                         }
53                 }
54
55                 return MOD_RES_PASSTHRU;
56         }
57
58         Version GetVersion() CXX11_OVERRIDE
59         {
60                 return Version("Provides support for channel mode +A, allowing /INVITE freely on a channel, and extban A to deny specific users it", VF_VENDOR);
61         }
62 };
63
64 MODULE_INIT(ModuleAllowInvite)