2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2019 linuxdaemon <linuxdaemon.irc@gmail.com>
5 * Copyright (C) 2016 0x277F <0x277F@gmail.com>
6 * Copyright (C) 2013, 2017 Sadie Powell <sadie@witchery.services>
7 * Copyright (C) 2013 Attila Molnar <attilamolnar@hush.com>
8 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
9 * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
10 * Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
11 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
12 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
13 * Copyright (C) 2006, 2010 Craig Edwards <brain@inspircd.org>
15 * This file is part of InspIRCd. InspIRCd is free software: you can
16 * redistribute it and/or modify it under the terms of the GNU General Public
17 * License as published by the Free Software Foundation, version 2.
19 * This program is distributed in the hope that it will be useful, but WITHOUT
20 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 #include "modules/exemption.h"
32 class ModuleStripColor : public Module
34 CheckExemption::EventProvider exemptionprov;
35 SimpleChannelModeHandler csc;
36 SimpleUserModeHandler usc;
41 , csc(this, "stripcolor", 'S')
42 , usc(this, "u_stripcolor", 'S')
46 void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
48 tokens["EXTBAN"].push_back('S');
51 ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
54 return MOD_RES_PASSTHRU;
59 case MessageTarget::TYPE_USER:
61 User* t = target.Get<User>();
62 active = t->IsModeSet(usc);
65 case MessageTarget::TYPE_CHANNEL:
67 Channel* t = target.Get<Channel>();
68 ModResult res = CheckExemption::Call(exemptionprov, user, t, "stripcolor");
70 if (res == MOD_RES_ALLOW)
71 return MOD_RES_PASSTHRU;
73 active = !t->GetExtBanStatus(user, 'S').check(!t->IsModeSet(csc));
76 case MessageTarget::TYPE_SERVER:
82 InspIRCd::StripColor(details.text);
85 return MOD_RES_PASSTHRU;
88 void OnUserPart(Membership* memb, std::string& partmessage, CUList& except_list) CXX11_OVERRIDE
90 User* user = memb->user;
91 Channel* channel = memb->chan;
96 if (channel->GetExtBanStatus(user, 'S').check(!user->IsModeSet(csc)))
98 ModResult res = CheckExemption::Call(exemptionprov, user, channel, "stripcolor");
100 if (res != MOD_RES_ALLOW)
101 InspIRCd::StripColor(partmessage);
105 Version GetVersion() CXX11_OVERRIDE
107 return Version("Adds channel mode S (stripcolor) which allows channels to strip IRC formatting codes from messages.", VF_VENDOR);
112 MODULE_INIT(ModuleStripColor)