]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_channelban.cpp
Remove $Core and $Mod* comments apart from $ModDep.
[user/henk/code/inspircd.git] / src / modules / m_channelban.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5  *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
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
23 class ModuleBadChannelExtban : public Module
24 {
25  public:
26         void init() CXX11_OVERRIDE
27         {
28                 Implementation eventlist[] = { I_OnCheckBan, I_On005Numeric };
29                 ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
30         }
31
32         Version GetVersion() CXX11_OVERRIDE
33         {
34                 return Version("Extban 'j' - channel status/join ban", VF_OPTCOMMON|VF_VENDOR);
35         }
36
37         ModResult OnCheckBan(User *user, Channel *c, const std::string& mask) CXX11_OVERRIDE
38         {
39                 if ((mask.length() > 2) && (mask[0] == 'j') && (mask[1] == ':'))
40                 {
41                         std::string rm = mask.substr(2);
42                         char status = 0;
43                         ModeHandler* mh = ServerInstance->Modes->FindPrefix(rm[0]);
44                         if (mh)
45                         {
46                                 rm = mask.substr(3);
47                                 status = mh->GetModeChar();
48                         }
49                         for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
50                         {
51                                 if (InspIRCd::Match((**i).name, rm))
52                                 {
53                                         if (status)
54                                         {
55                                                 Membership* memb = (**i).GetUser(user);
56                                                 if (memb && memb->hasMode(status))
57                                                         return MOD_RES_DENY;
58                                         }
59                                         else
60                                                 return MOD_RES_DENY;
61                                 }
62                         }
63                 }
64                 return MOD_RES_PASSTHRU;
65         }
66
67         void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
68         {
69                 tokens["EXTBAN"].push_back('j');
70         }
71 };
72
73 MODULE_INIT(ModuleBadChannelExtban)