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 ModuleBlockColour : public Module
33 ModuleBlockColour(Server* Me) : Module::Module(Me)
36 Srv->AddExtendedMode('c',MT_CHANNEL,false,0,0);
39 void Implements(char* List)
41 List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnExtendedMode] = 1;
44 virtual void On005Numeric(std::string &output)
46 InsertMode(output,"c",4);
49 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
51 if (target_type == TYPE_CHANNEL)
53 chanrec* c = (chanrec*)dest;
57 /* Replace a strlcpy(), which ran even when +c wasn't set, with this (no copies at all) -- Om */
58 for(unsigned int i = 0; i < text.length(); i++)
68 WriteServ(user->fd,"404 %s %s :Can't send colours to channel (+c set)",user->nick, c->name);
78 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
80 return OnUserPreMessage(user,dest,target_type,text,status);
83 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
85 // check if this is our mode character...
86 if ((modechar == 'c') && (type == MT_CHANNEL))
88 log(DEBUG,"Allowing c change");
97 virtual ~ModuleBlockColour()
101 virtual Version GetVersion()
103 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
108 class ModuleBlockColourFactory : public ModuleFactory
111 ModuleBlockColourFactory()
115 ~ModuleBlockColourFactory()
119 virtual Module * CreateModule(Server* Me)
121 return new ModuleBlockColour(Me);
127 extern "C" void * init_module( void )
129 return new ModuleBlockColourFactory;