2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2004, 2008 Craig Edwards <craigedwards@brainbox.cc>
5 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
6 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
8 * This file is part of InspIRCd. InspIRCd is free software: you can
9 * redistribute it and/or modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation, version 2.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 /** Handles channel mode +S
26 class ChannelStripColor : public SimpleChannelModeHandler
29 ChannelStripColor(Module* Creator) : SimpleChannelModeHandler(Creator, "stripcolor", 'S') { }
32 /** Handles user mode +S
34 class UserStripColor : public SimpleUserModeHandler
37 UserStripColor(Module* Creator) : SimpleUserModeHandler(Creator, "u_stripcolor", 'S') { }
41 class ModuleStripColor : public Module
43 ChannelStripColor csc;
47 ModuleStripColor() : csc(this), usc(this)
51 void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
53 tokens["EXTBAN"].push_back('S');
56 ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
59 return MOD_RES_PASSTHRU;
62 if (target_type == TYPE_USER)
64 User* t = (User*)dest;
65 active = t->IsModeSet(usc);
67 else if (target_type == TYPE_CHANNEL)
69 Channel* t = (Channel*)dest;
70 ModResult res = ServerInstance->OnCheckExemption(user,t,"stripcolor");
72 if (res == MOD_RES_ALLOW)
73 return MOD_RES_PASSTHRU;
75 active = !t->GetExtBanStatus(user, 'S').check(!t->IsModeSet(csc));
80 InspIRCd::StripColor(text);
83 return MOD_RES_PASSTHRU;
86 void OnUserPart(Membership* memb, std::string& partmessage, CUList& except_list) CXX11_OVERRIDE
88 User* user = memb->user;
89 Channel* channel = memb->chan;
94 bool active = channel->GetExtBanStatus(user, 'S').check(!user->IsModeSet(csc))
95 && ServerInstance->OnCheckExemption(user, channel, "stripcolor") != MOD_RES_ALLOW;
99 InspIRCd::StripColor(partmessage);
103 Version GetVersion() CXX11_OVERRIDE
105 return Version("Provides channel +S mode (strip ansi color)", VF_VENDOR);
110 MODULE_INIT(ModuleStripColor)