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 extern InspIRCd* ServerInstance;
30 class NoCTCP : public ModeHandler
33 NoCTCP(InspIRCd* Instance) : ModeHandler(Instance, 'C', 0, 0, false, MODETYPE_CHANNEL, false) { }
35 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
39 if (!channel->IsModeSet('C'))
41 channel->SetMode('C',true);
42 return MODEACTION_ALLOW;
47 if (channel->IsModeSet('C'))
49 channel->SetMode('C',false);
50 return MODEACTION_ALLOW;
54 return MODEACTION_DENY;
58 class ModuleNoCTCP : public Module
65 ModuleNoCTCP(Server* Me)
69 nc = new NoCTCP(ServerInstance);
70 Srv->AddMode(nc, 'C');
73 void Implements(char* List)
75 List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
78 virtual void On005Numeric(std::string &output)
80 ServerInstance->ModeGrok->InsertMode(output,"C",4);
83 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
85 return OnUserPreNotice(user,dest,target_type,text,status);
88 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
90 if (target_type == TYPE_CHANNEL)
92 chanrec* c = (chanrec*)dest;
93 if (c->IsModeSet('C'))
95 if ((text.length()) && (text[0] == '\1'))
97 if (strncmp(text.c_str(),"\1ACTION ",8))
99 user->WriteServ("492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
108 virtual ~ModuleNoCTCP()
113 virtual Version GetVersion()
115 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
120 class ModuleNoCTCPFactory : public ModuleFactory
123 ModuleNoCTCPFactory()
127 ~ModuleNoCTCPFactory()
131 virtual Module * CreateModule(Server* Me)
133 return new ModuleNoCTCP(Me);
139 extern "C" void * init_module( void )
141 return new ModuleNoCTCPFactory;