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 // we don't really have a limit...
48 std::stringstream line(output);
49 std::string temp1, temp2;
53 if (temp1.substr(0,10) == "CHANMODES=")
55 // append the chanmode to the end
56 temp1 = temp1.substr(10,temp1.length());
57 temp1 = "CHANMODES=" + temp1 + "c";
59 temp2 = temp2 + temp1 + " ";
62 output = temp2.substr(0,temp2.length()-1);
65 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
67 if (target_type == TYPE_CHANNEL)
69 chanrec* c = (chanrec*)dest;
72 strlcpy(ctext,text.c_str(),MAXBUF);
75 if (c->IsCustomModeSet('c'))
77 /* Instead of using strchr() here, do our own loop. Hopefully faster. --w00t */
78 while (ctptr && *ctptr)
88 WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
98 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
100 if (target_type == TYPE_CHANNEL)
102 chanrec* c = (chanrec*)dest;
105 strlcpy(ctext,text.c_str(),MAXBUF);
108 if (c->IsCustomModeSet('c'))
110 /* Instead of using strchr() here, do our own loop. Hopefully faster. --w00t */
111 while (ctptr && *ctptr)
121 WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
131 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
133 // check if this is our mode character...
134 if ((modechar == 'c') && (type == MT_CHANNEL))
136 log(DEBUG,"Allowing c change");
145 virtual ~ModuleBlockColor()
149 virtual Version GetVersion()
151 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
156 class ModuleBlockColorFactory : public ModuleFactory
159 ModuleBlockColorFactory()
163 ~ModuleBlockColorFactory()
167 virtual Module * CreateModule(Server* Me)
169 return new ModuleBlockColor(Me);
175 extern "C" void * init_module( void )
177 return new ModuleBlockColorFactory;