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"
26 /* $ModDesc: Provides support for unreal-style channel mode +c */
28 class NoCTCP : public ModeHandler
31 NoCTCP() : ModeHandler('C', 0, 0, false, MODETYPE_CHANNEL, false) { }
33 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
37 if (!channel->IsModeSet('C'))
39 channel->SetMode('C',true);
40 return MODEACTION_ALLOW;
45 if (channel->IsModeSet('C'))
47 channel->SetMode('C',false);
48 return MODEACTION_ALLOW;
52 return MODEACTION_DENY;
56 class ModuleNoCTCP : public Module
63 ModuleNoCTCP(Server* Me)
68 Srv->AddMode(nc, 'C');
71 void Implements(char* List)
73 List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
76 virtual void On005Numeric(std::string &output)
78 InsertMode(output,"C",4);
81 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
83 return OnUserPreNotice(user,dest,target_type,text,status);
86 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
88 if (target_type == TYPE_CHANNEL)
90 chanrec* c = (chanrec*)dest;
91 if (c->IsModeSet('C'))
93 if ((text.length()) && (text[0] == '\1'))
95 if (strncmp(text.c_str(),"\1ACTION ",8))
97 user->WriteServ("492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
106 virtual ~ModuleNoCTCP()
111 virtual Version GetVersion()
113 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
118 class ModuleNoCTCPFactory : public ModuleFactory
121 ModuleNoCTCPFactory()
125 ~ModuleNoCTCPFactory()
129 virtual Module * CreateModule(Server* Me)
131 return new ModuleNoCTCP(Me);
137 extern "C" void * init_module( void )
139 return new ModuleNoCTCPFactory;