1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
19 /* $ModDesc: Provides support for unreal-style channel mode +c */
23 class NoCTCP : public ModeHandler
26 NoCTCP(InspIRCd* Instance) : ModeHandler(Instance, 'C', 0, 0, false, MODETYPE_CHANNEL, false) { }
28 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
32 if (!channel->IsModeSet('C'))
34 channel->SetMode('C',true);
35 return MODEACTION_ALLOW;
40 if (channel->IsModeSet('C'))
42 channel->SetMode('C',false);
43 return MODEACTION_ALLOW;
47 return MODEACTION_DENY;
51 class ModuleNoCTCP : public Module
58 ModuleNoCTCP(InspIRCd* Me)
62 nc = new NoCTCP(ServerInstance);
63 ServerInstance->AddMode(nc, 'C');
66 void Implements(char* List)
68 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
71 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
73 return OnUserPreNotice(user,dest,target_type,text,status,exempt_list);
76 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
78 if (target_type == TYPE_CHANNEL)
80 chanrec* c = (chanrec*)dest;
81 if (c->IsModeSet('C'))
83 if ((text.length()) && (text[0] == '\1'))
85 if (strncmp(text.c_str(),"\1ACTION ",8))
87 user->WriteServ("492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
96 virtual ~ModuleNoCTCP()
98 ServerInstance->Modes->DelMode(nc);
102 virtual Version GetVersion()
104 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
109 class ModuleNoCTCPFactory : public ModuleFactory
112 ModuleNoCTCPFactory()
116 ~ModuleNoCTCPFactory()
120 virtual Module * CreateModule(InspIRCd* Me)
122 return new ModuleNoCTCP(Me);
128 extern "C" void * init_module( void )
130 return new ModuleNoCTCPFactory;