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 * ---------------------------------------------------
23 /* $ModDesc: Provides support for unreal-style channel mode +c */
25 class ModuleBlockColor : public Module
33 Srv->AddExtendedMode('c',MT_CHANNEL,false,0,0);
36 virtual void On005Numeric(std::string &output)
38 // we don't really have a limit...
39 std::stringstream line(output);
40 std::string temp1, temp2;
44 if (temp1.substr(0,10) == "CHANMODES=")
46 // append the chanmode to the end
47 temp1 = temp1.substr(10,temp1.length());
48 temp1 = "CHANMODES=" + temp1 + "c";
50 temp2 = temp2 + temp1 + " ";
52 output = temp2.substr(0,temp2.length()-1);
55 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
57 if (target_type == TYPE_CHANNEL)
59 chanrec* c = (chanrec*)dest;
61 snprintf(ctext,MAXBUF,"%s",text.c_str());
62 if (c->IsCustomModeSet('c'))
64 if ((strchr(ctext,'\2')) || (strchr(ctext,'\3')) || (strchr(ctext,31)))
66 WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
74 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
76 if (target_type == TYPE_CHANNEL)
78 chanrec* c = (chanrec*)dest;
80 snprintf(ctext,MAXBUF,"%s",text.c_str());
81 if (c->IsCustomModeSet('c'))
83 if ((strchr(ctext,'\2')) || (strchr(ctext,'\3')) || (strchr(ctext,31)))
85 WriteServ(user->fd,"404 %s %s :Can't send colors to channel (+c set)",user->nick, c->name);
93 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
95 // check if this is our mode character...
96 if ((modechar == 'c') && (type == MT_CHANNEL))
98 log(DEBUG,"Allowing c change");
107 virtual ~ModuleBlockColor()
112 virtual Version GetVersion()
114 return Version(1,0,0,0);
119 class ModuleBlockColorFactory : public ModuleFactory
122 ModuleBlockColorFactory()
126 ~ModuleBlockColorFactory()
130 virtual Module * CreateModule()
132 return new ModuleBlockColor;
138 extern "C" void * init_module( void )
140 return new ModuleBlockColorFactory;