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 * ---------------------------------------------------
22 #include "helperfuncs.h"
24 /* $ModDesc: Provides support for unreal-style channel mode +c */
26 class ModuleBlockColor : public Module
34 Srv->AddExtendedMode('c',MT_CHANNEL,false,0,0);
37 virtual void On005Numeric(std::string &output)
39 // we don't really have a limit...
40 std::stringstream line(output);
41 std::string temp1, temp2;
45 if (temp1.substr(0,10) == "CHANMODES=")
47 // append the chanmode to the end
48 temp1 = temp1.substr(10,temp1.length());
49 temp1 = "CHANMODES=" + temp1 + "c";
51 temp2 = temp2 + temp1 + " ";
54 output = temp2.substr(0,temp2.length()-1);
57 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
59 if (target_type == TYPE_CHANNEL)
61 chanrec* c = (chanrec*)dest;
63 snprintf(ctext,MAXBUF,"%s",text.c_str());
64 if (c->IsCustomModeSet('c'))
66 if ((strchr(ctext,'\2')) || (strchr(ctext,'\3')) || (strchr(ctext,31)))
68 WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
76 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
78 if (target_type == TYPE_CHANNEL)
80 chanrec* c = (chanrec*)dest;
82 snprintf(ctext,MAXBUF,"%s",text.c_str());
83 if (c->IsCustomModeSet('c'))
85 if ((strchr(ctext,'\2')) || (strchr(ctext,'\3')) || (strchr(ctext,31)))
87 WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
95 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
97 // check if this is our mode character...
98 if ((modechar == 'c') && (type == MT_CHANNEL))
100 log(DEBUG,"Allowing c change");
109 virtual ~ModuleBlockColor()
114 virtual Version GetVersion()
116 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
121 class ModuleBlockColorFactory : public ModuleFactory
124 ModuleBlockColorFactory()
128 ~ModuleBlockColorFactory()
132 virtual Module * CreateModule()
134 return new ModuleBlockColor;
140 extern "C" void * init_module( void )
142 return new ModuleBlockColorFactory;