2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 /* $ModDesc: Provides support for channel mode +A, allowing /invite freely on a channel (and extban A to allow specific users it) */
24 class AllowInvite : public SimpleChannelModeHandler
27 AllowInvite(Module* Creator) : SimpleChannelModeHandler(Creator, "allowinvite", 'A') { }
30 class ModuleAllowInvite : public Module
35 ModuleAllowInvite() : ni(this)
37 if (!ServerInstance->Modes->AddMode(&ni))
38 throw ModuleException("Could not add new modes!");
39 Implementation eventlist[] = { I_OnUserPreInvite, I_On005Numeric };
40 ServerInstance->Modules->Attach(eventlist, this, 2);
43 virtual void On005Numeric(std::string &output)
45 ServerInstance->AddExtBanChar('A');
48 virtual ModResult OnUserPreInvite(User* user,User* dest,Channel* channel, time_t timeout)
52 ModResult res = channel->GetExtBanStatus(user, 'A');
53 if (res == MOD_RES_DENY)
55 // Matching extban, explicitly deny /invite
56 user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You are banned from using INVITE", user->nick.c_str(), channel->name.c_str());
59 if (channel->IsModeSet('A') || res == MOD_RES_ALLOW)
61 // Explicitly allow /invite
66 return MOD_RES_PASSTHRU;
69 virtual ~ModuleAllowInvite()
73 virtual Version GetVersion()
75 return Version("Provides support for channel mode +A, allowing /invite freely on a channel (and extban A to allow specific users it)",VF_VENDOR);
79 MODULE_INIT(ModuleAllowInvite)