2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2015 Renegade334 <contact.caaeed4f@renegade334.me.uk>
5 * Copyright (C) 2013, 2018 Sadie Powell <sadie@witchery.services>
6 * Copyright (C) 2012 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2010 Craig Edwards <brain@inspircd.org>
8 * Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
9 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
10 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
12 * This file is part of InspIRCd. InspIRCd is free software: you can
13 * redistribute it and/or modify it under the terms of the GNU General Public
14 * License as published by the Free Software Foundation, version 2.
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 class ModuleGecosBan : public Module
31 Version GetVersion() CXX11_OVERRIDE
33 return Version("Adds the r extended ban which checks whether users have a real name (gecos) matching the specified glob pattern.", VF_OPTCOMMON|VF_VENDOR);
36 ModResult OnCheckBan(User *user, Channel *c, const std::string& mask) CXX11_OVERRIDE
38 if ((mask.length() > 2) && (mask[1] == ':'))
42 if (InspIRCd::Match(user->GetRealName(), mask.substr(2)))
45 else if (mask[0] == 'a')
47 // Check that the user actually specified a real name.
48 const size_t divider = mask.find('+', 1);
49 if (divider == std::string::npos)
50 return MOD_RES_PASSTHRU;
52 // Check whether the user's mask matches.
53 if (!c->CheckBan(user, mask.substr(2, divider - 2)))
54 return MOD_RES_PASSTHRU;
56 // Check whether the user's real name matches.
57 if (InspIRCd::Match(user->GetRealName(), mask.substr(divider + 1)))
61 return MOD_RES_PASSTHRU;
64 void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
66 tokens["EXTBAN"].push_back('a');
67 tokens["EXTBAN"].push_back('r');
71 MODULE_INIT(ModuleGecosBan)