]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_classban.cpp
Use !empty instead of size when checking if containers are empty.
[user/henk/code/inspircd.git] / src / modules / m_classban.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2020 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2016 Johanna A <johanna-a@users.noreply.github.com>
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 ModuleClassBan : public Module
24 {
25  public:
26         ModResult OnCheckBan(User* user, Channel* c, const std::string& mask) CXX11_OVERRIDE
27         {
28                 LocalUser* localUser = IS_LOCAL(user);
29                 if ((localUser) && (mask.length() > 2) && (mask[0] == 'n') && (mask[1] == ':'))
30                 {
31                         if (InspIRCd::Match(localUser->GetClass()->name, mask.substr(2)))
32                                 return MOD_RES_DENY;
33                 }
34                 return MOD_RES_PASSTHRU;
35         }
36
37         void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
38         {
39                 tokens["EXTBAN"].push_back('n');
40         }
41
42         Version GetVersion() CXX11_OVERRIDE
43         {
44                 return Version("Adds the n: extended ban which check whether users are in a connect class matching the specified glob pattern.", VF_VENDOR | VF_OPTCOMMON);
45         }
46 };
47
48 MODULE_INIT(ModuleClassBan)