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 /* $ModDesc: Provides channel +S mode (strip ansi color) */
26 /** Handles channel mode +S
28 class ChannelStripColor : public SimpleChannelModeHandler
31 ChannelStripColor(Module* Creator) : SimpleChannelModeHandler(Creator, "stripcolor", 'S') { }
34 /** Handles user mode +S
36 class UserStripColor : public SimpleUserModeHandler
39 UserStripColor(Module* Creator) : SimpleUserModeHandler(Creator, "u_stripcolor", 'S') { }
43 class ModuleStripColor : public Module
46 ChannelStripColor csc;
50 ModuleStripColor() : csc(this), usc(this)
56 ServerInstance->Modules->AddService(usc);
57 ServerInstance->Modules->AddService(csc);
58 Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_On005Numeric };
59 ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
62 virtual ~ModuleStripColor()
66 virtual void On005Numeric(std::string &output)
68 ServerInstance->AddExtBanChar('S');
71 virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
74 return MOD_RES_PASSTHRU;
77 if (target_type == TYPE_USER)
79 User* t = (User*)dest;
80 active = t->IsModeSet('S');
82 else if (target_type == TYPE_CHANNEL)
84 Channel* t = (Channel*)dest;
85 ModResult res = ServerInstance->OnCheckExemption(user,t,"stripcolor");
87 if (res == MOD_RES_ALLOW)
88 return MOD_RES_PASSTHRU;
90 active = !t->GetExtBanStatus(user, 'S').check(!t->IsModeSet('S'));
95 InspIRCd::StripColor(text);
98 return MOD_RES_PASSTHRU;
101 virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
103 return OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
106 virtual Version GetVersion()
108 return Version("Provides channel +S mode (strip ansi color)", VF_VENDOR);
113 MODULE_INIT(ModuleStripColor)