2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2017 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
6 * Copyright (C) 2012, 2014-2015 Attila Molnar <attilamolnar@hush.com>
7 * Copyright (C) 2012 William Pitcock <nenolod@dereferenced.org>
9 * This file is part of InspIRCd. InspIRCd is free software: you can
10 * redistribute it and/or modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation, version 2.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 ERR_MLOCKRESTRICTED = 742
31 class ModuleMLock : public Module
37 : mlock("mlock", ExtensionItem::EXT_CHANNEL, this)
41 Version GetVersion() CXX11_OVERRIDE
43 return Version("Allows services to lock channel modes so that they can not be changed.", VF_VENDOR);
46 ModResult OnRawMode(User* source, Channel* channel, ModeHandler* mh, const std::string& parameter, bool adding) CXX11_OVERRIDE
49 return MOD_RES_PASSTHRU;
51 if (!IS_LOCAL(source))
52 return MOD_RES_PASSTHRU;
54 std::string *mlock_str = mlock.get(channel);
56 return MOD_RES_PASSTHRU;
58 const char mode = mh->GetModeChar();
59 std::string::size_type p = mlock_str->find(mode);
60 if (p != std::string::npos)
62 source->WriteNumeric(ERR_MLOCKRESTRICTED, channel->name, mode, *mlock_str, "MODE cannot be set due to the channel having an active MLOCK restriction policy");
66 return MOD_RES_PASSTHRU;
70 MODULE_INIT(ModuleMLock)