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 * ---------------------------------------------------
23 #include "helperfuncs.h"
25 /* $ModDesc: Provides support for unreal-style channel mode +c */
27 class ModuleNoCTCP : public Module
33 ModuleNoCTCP(Server* Me)
37 Srv->AddExtendedMode('C',MT_CHANNEL,false,0,0);
40 void Implements(char* List)
42 List[I_OnExtendedMode] = List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 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)
52 if (target_type == TYPE_CHANNEL)
54 chanrec* c = (chanrec*)dest;
55 if (c->IsCustomModeSet('C'))
57 if ((text.length()) && (text[0] == '\1'))
59 if (strncmp(text.c_str(),"\1ACTION ",8))
61 WriteServ(user->fd,"492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
70 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
72 if (target_type == TYPE_CHANNEL)
74 chanrec* c = (chanrec*)dest;
75 if (c->IsCustomModeSet('C'))
77 if ((text.length()) && (text[0] == '\1'))
79 if (strncmp(text.c_str(),"\1ACTION ",8))
81 WriteServ(user->fd,"492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
90 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
92 // check if this is our mode character...
93 if ((modechar == 'C') && (type == MT_CHANNEL))
95 log(DEBUG,"Allowing C change");
104 virtual ~ModuleNoCTCP()
108 virtual Version GetVersion()
110 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
115 class ModuleNoCTCPFactory : public ModuleFactory
118 ModuleNoCTCPFactory()
122 ~ModuleNoCTCPFactory()
126 virtual Module * CreateModule(Server* Me)
128 return new ModuleNoCTCP(Me);
134 extern "C" void * init_module( void )
136 return new ModuleNoCTCPFactory;