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 if (!ServerInstance->AddMode(nc, 'C'))
64 throw ModuleException("Could not add new modes!");
67 void Implements(char* List)
69 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
72 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
74 return OnUserPreNotice(user,dest,target_type,text,status,exempt_list);
77 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
79 if (target_type == TYPE_CHANNEL)
81 chanrec* c = (chanrec*)dest;
82 if (c->IsModeSet('C'))
84 if ((text.length()) && (text[0] == '\1'))
86 if (strncmp(text.c_str(),"\1ACTION ",8))
88 user->WriteServ("492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
97 virtual ~ModuleNoCTCP()
99 ServerInstance->Modes->DelMode(nc);
103 virtual Version GetVersion()
105 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
110 class ModuleNoCTCPFactory : public ModuleFactory
113 ModuleNoCTCPFactory()
117 ~ModuleNoCTCPFactory()
121 virtual Module * CreateModule(InspIRCd* Me)
123 return new ModuleNoCTCP(Me);
129 extern "C" void * init_module( void )
131 return new ModuleNoCTCPFactory;