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 */
21 class NoCTCP : public ModeHandler
24 NoCTCP(InspIRCd* Instance) : ModeHandler(Instance, 'C', 0, 0, false, MODETYPE_CHANNEL, false) { }
26 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
30 if (!channel->IsModeSet('C'))
32 channel->SetMode('C',true);
33 return MODEACTION_ALLOW;
38 if (channel->IsModeSet('C'))
40 channel->SetMode('C',false);
41 return MODEACTION_ALLOW;
45 return MODEACTION_DENY;
49 class ModuleNoCTCP : public Module
56 ModuleNoCTCP(InspIRCd* Me)
60 nc = new NoCTCP(ServerInstance);
61 if (!ServerInstance->AddMode(nc, 'C'))
62 throw ModuleException("Could not add new modes!");
65 void Implements(char* List)
67 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
70 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
72 return OnUserPreNotice(user,dest,target_type,text,status,exempt_list);
75 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
77 if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
79 chanrec* c = (chanrec*)dest;
80 if (c->IsModeSet('C'))
82 if ((text.length()) && (text[0] == '\1'))
84 if (strncmp(text.c_str(),"\1ACTION ",8))
86 user->WriteServ("492 %s %s :Can't send CTCP to channel (+C set)",user->nick, c->name);
95 virtual ~ModuleNoCTCP()
97 ServerInstance->Modes->DelMode(nc);
101 virtual Version GetVersion()
103 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
108 class ModuleNoCTCPFactory : public ModuleFactory
111 ModuleNoCTCPFactory()
115 ~ModuleNoCTCPFactory()
119 virtual Module * CreateModule(InspIRCd* Me)
121 return new ModuleNoCTCP(Me);
127 extern "C" DllExport void * init_module( void )
129 return new ModuleNoCTCPFactory;