1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
24 #include "helperfuncs.h"
26 /* $ModDesc: Provides support for unreal-style channel mode +c */
28 class BlockColor : public ModeHandler
31 BlockColor() : ModeHandler('c', 0, 0, false, MODETYPE_CHANNEL, false) { }
33 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
37 if (!channel->IsModeSet('c'))
39 channel->SetMode('c',true);
40 return MODEACTION_ALLOW;
45 if (channel->IsModeSet('c'))
47 channel->SetMode('c',false);
48 return MODEACTION_ALLOW;
52 return MODEACTION_DENY;
56 class ModuleBlockColour : public Module
62 ModuleBlockColour(Server* Me) : Module::Module(Me)
65 bc = new BlockColor();
66 Srv->AddMode(bc, 'c');
69 void Implements(char* List)
71 List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
74 virtual void On005Numeric(std::string &output)
76 InsertMode(output,"c",4);
79 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
81 if (target_type == TYPE_CHANNEL)
83 chanrec* c = (chanrec*)dest;
87 /* Replace a strlcpy(), which ran even when +c wasn't set, with this (no copies at all) -- Om */
88 for (std::string::iterator i = text.begin(); i != text.end(); i++)
98 WriteServ(user->fd,"404 %s %s :Can't send colours to channel (+c set)",user->nick, c->name);
108 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
110 return OnUserPreMessage(user,dest,target_type,text,status);
113 virtual ~ModuleBlockColour()
118 virtual Version GetVersion()
120 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
125 class ModuleBlockColourFactory : public ModuleFactory
128 ModuleBlockColourFactory()
132 ~ModuleBlockColourFactory()
136 virtual Module * CreateModule(Server* Me)
138 return new ModuleBlockColour(Me);
144 extern "C" void * init_module( void )
146 return new ModuleBlockColourFactory;