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 NoCTCP : public ModeHandler
30 NoCTCP() : ModeHandler('C', 0, 0, false, MODETYPE_CHANNEL, false) { }
32 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
36 if (!channel->IsModeSet('C'))
38 channel->SetMode('C',true);
39 return MODEACTION_ALLOW;
44 if (channel->IsModeSet('C'))
46 channel->SetMode('C',false);
47 return MODEACTION_ALLOW;
51 return MODEACTION_DENY;
55 class ModuleNoCTCP : public Module
62 ModuleNoCTCP(Server* Me)
67 Srv->AddMode(nc, 'C');
70 void Implements(char* List)
72 List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
75 virtual void On005Numeric(std::string &output)
77 InsertMode(output,"C",4);
80 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
82 return OnUserPreNotice(user,dest,target_type,text,status);
85 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
87 if (target_type == TYPE_CHANNEL)
89 chanrec* c = (chanrec*)dest;
90 if (c->IsModeSet('C'))
92 if ((text.length()) && (text[0] == '\1'))
94 if (strncmp(text.c_str(),"\1ACTION ",8))
96 WriteServ(user->fd,"492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
105 virtual ~ModuleNoCTCP()
110 virtual Version GetVersion()
112 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
117 class ModuleNoCTCPFactory : public ModuleFactory
120 ModuleNoCTCPFactory()
124 ~ModuleNoCTCPFactory()
128 virtual Module * CreateModule(Server* Me)
130 return new ModuleNoCTCP(Me);
136 extern "C" void * init_module( void )
138 return new ModuleNoCTCPFactory;