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 * ---------------------------------------------------
26 /* $ModDesc: Provides support for unreal-style channel mode +c */
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(InspIRCd* Me)
69 nc = new NoCTCP(ServerInstance);
70 ServerInstance->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)
82 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
84 return OnUserPreNotice(user,dest,target_type,text,status);
87 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
89 if (target_type == TYPE_CHANNEL)
91 chanrec* c = (chanrec*)dest;
92 if (c->IsModeSet('C'))
94 if ((text.length()) && (text[0] == '\1'))
96 if (strncmp(text.c_str(),"\1ACTION ",8))
98 user->WriteServ("492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
107 virtual ~ModuleNoCTCP()
112 virtual Version GetVersion()
114 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
119 class ModuleNoCTCPFactory : public ModuleFactory
122 ModuleNoCTCPFactory()
126 ~ModuleNoCTCPFactory()
130 virtual Module * CreateModule(InspIRCd* Me)
132 return new ModuleNoCTCP(Me);
138 extern "C" void * init_module( void )
140 return new ModuleNoCTCPFactory;