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 ModuleBlockColor : public Module
33 ModuleBlockColor(Server* Me)
37 Srv->AddExtendedMode('c',MT_CHANNEL,false,0,0);
40 void Implements(char* List)
42 List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnExtendedMode] = 1;
45 virtual void On005Numeric(std::string &output)
47 InsertMode(output,"c",4);
50 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
52 if (target_type == TYPE_CHANNEL)
54 chanrec* c = (chanrec*)dest;
57 strlcpy(ctext,text.c_str(),MAXBUF);
60 if (c->IsCustomModeSet('c'))
62 /* Instead of using strchr() here, do our own loop. Hopefully faster. --w00t */
63 while (ctptr && *ctptr)
73 WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
83 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
85 return OnUserPreMessage(user,dest,target_type,text,status);
88 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
90 // check if this is our mode character...
91 if ((modechar == 'c') && (type == MT_CHANNEL))
93 log(DEBUG,"Allowing c change");
102 virtual ~ModuleBlockColor()
106 virtual Version GetVersion()
108 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
113 class ModuleBlockColorFactory : public ModuleFactory
116 ModuleBlockColorFactory()
120 ~ModuleBlockColorFactory()
124 virtual Module * CreateModule(Server* Me)
126 return new ModuleBlockColor(Me);
132 extern "C" void * init_module( void )
134 return new ModuleBlockColorFactory;