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 * ---------------------------------------------------
24 /* $ModDesc: Provides support for unreal-style channel mode +c */
28 class NoCTCP : public ModeHandler
31 NoCTCP(InspIRCd* Instance) : ModeHandler(Instance, '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(InspIRCd* Me)
67 nc = new NoCTCP(ServerInstance);
68 ServerInstance->AddMode(nc, 'C');
71 void Implements(char* List)
73 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
76 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
78 return OnUserPreNotice(user,dest,target_type,text,status,exempt_list);
81 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
83 if (target_type == TYPE_CHANNEL)
85 chanrec* c = (chanrec*)dest;
86 if (c->IsModeSet('C'))
88 if ((text.length()) && (text[0] == '\1'))
90 if (strncmp(text.c_str(),"\1ACTION ",8))
92 user->WriteServ("492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
101 virtual ~ModuleNoCTCP()
103 ServerInstance->Modes->DelMode(nc);
107 virtual Version GetVersion()
109 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
114 class ModuleNoCTCPFactory : public ModuleFactory
117 ModuleNoCTCPFactory()
121 ~ModuleNoCTCPFactory()
125 virtual Module * CreateModule(InspIRCd* Me)
127 return new ModuleNoCTCP(Me);
133 extern "C" void * init_module( void )
135 return new ModuleNoCTCPFactory;