1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 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 virtual void On005Numeric(std::string &output)
42 // we don't really have a limit...
43 std::stringstream line(output);
44 std::string temp1, temp2;
48 if (temp1.substr(0,10) == "CHANMODES=")
50 // append the chanmode to the end
51 temp1 = temp1.substr(10,temp1.length());
52 temp1 = "CHANMODES=" + temp1 + "c";
54 temp2 = temp2 + temp1 + " ";
57 output = temp2.substr(0,temp2.length()-1);
60 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
62 if (target_type == TYPE_CHANNEL)
64 chanrec* c = (chanrec*)dest;
66 snprintf(ctext,MAXBUF,"%s",text.c_str());
67 if (c->IsCustomModeSet('c'))
69 if ((strchr(ctext,'\2')) || (strchr(ctext,'\3')) || (strchr(ctext,31)))
71 WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
79 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
81 if (target_type == TYPE_CHANNEL)
83 chanrec* c = (chanrec*)dest;
85 snprintf(ctext,MAXBUF,"%s",text.c_str());
86 if (c->IsCustomModeSet('c'))
88 if ((strchr(ctext,'\2')) || (strchr(ctext,'\3')) || (strchr(ctext,31)))
90 WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
98 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
100 // check if this is our mode character...
101 if ((modechar == 'c') && (type == MT_CHANNEL))
103 log(DEBUG,"Allowing c change");
112 virtual ~ModuleBlockColor()
116 virtual Version GetVersion()
118 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
123 class ModuleBlockColorFactory : public ModuleFactory
126 ModuleBlockColorFactory()
130 ~ModuleBlockColorFactory()
134 virtual Module * CreateModule(Server* Me)
136 return new ModuleBlockColor(Me);
142 extern "C" void * init_module( void )
144 return new ModuleBlockColorFactory;