2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2017-2020 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2012-2013 Attila Molnar <attilamolnar@hush.com>
6 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
8 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
9 * Copyright (C) 2007-2008 Dennis Friis <peavey@inspircd.org>
10 * Copyright (C) 2006-2007 Craig Edwards <brain@inspircd.org>
11 * Copyright (C) 2006 Oliver Lupton <om@inspircd.org>
13 * This file is part of InspIRCd. InspIRCd is free software: you can
14 * redistribute it and/or modify it under the terms of the GNU General Public
15 * License as published by the Free Software Foundation, version 2.
17 * This program is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 RPL_ENDOFEXCEPTLIST = 349
37 class BanException : public ListModeBase
40 BanException(Module* Creator)
41 : ListModeBase(Creator, "banexception", 'e', "End of Channel Exception List", RPL_EXCEPTLIST, RPL_ENDOFEXCEPTLIST, true)
47 class ModuleBanException : public Module
52 ModuleBanException() : be(this)
56 void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
58 tokens["EXCEPTS"] = ConvToStr(be.GetModeChar());
61 ModResult OnExtBanCheck(User *user, Channel *chan, char type) CXX11_OVERRIDE
63 ListModeBase::ModeList* list = be.GetList(chan);
65 return MOD_RES_PASSTHRU;
67 for (ListModeBase::ModeList::iterator it = list->begin(); it != list->end(); it++)
69 if (it->mask.length() <= 2 || it->mask[0] != type || it->mask[1] != ':')
72 if (chan->CheckBan(user, it->mask.substr(2)))
74 // They match an entry on the list, so let them pass this.
79 return MOD_RES_PASSTHRU;
82 ModResult OnCheckChannelBan(User* user, Channel* chan) CXX11_OVERRIDE
84 ListModeBase::ModeList* list = be.GetList(chan);
87 // No list, proceed normally
88 return MOD_RES_PASSTHRU;
91 for (ListModeBase::ModeList::iterator it = list->begin(); it != list->end(); it++)
93 if (chan->CheckBan(user, it->mask))
95 // They match an entry on the list, so let them in.
99 return MOD_RES_PASSTHRU;
102 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
107 Version GetVersion() CXX11_OVERRIDE
109 return Version("Adds channel mode e (banexception) which allows channel operators to exempt user masks from the b (ban) channel mode.", VF_VENDOR);
113 MODULE_INIT(ModuleBanException)