1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Provides support for unreal-style channel mode +C */
18 class NoCTCP : public ModeHandler
21 NoCTCP(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'C', 0, 0, false, MODETYPE_CHANNEL, false) { }
23 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding)
27 if (!channel->IsModeSet('C'))
29 channel->SetMode('C',true);
30 return MODEACTION_ALLOW;
35 if (channel->IsModeSet('C'))
37 channel->SetMode('C',false);
38 return MODEACTION_ALLOW;
42 return MODEACTION_DENY;
46 class ModuleNoCTCP : public Module
53 ModuleNoCTCP(InspIRCd* Me)
54 : Module(Me), nc(Me, this)
56 if (!ServerInstance->Modes->AddMode(&nc))
57 throw ModuleException("Could not add new modes!");
58 Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_On005Numeric };
59 ServerInstance->Modules->Attach(eventlist, this, 3);
62 virtual ~ModuleNoCTCP()
64 ServerInstance->Modes->DelMode(&nc);
67 virtual Version GetVersion()
69 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
72 virtual ModResult OnUserPreMessage(User* 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 ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
79 if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
81 Channel* c = (Channel*)dest;
83 if (CHANOPS_EXEMPT(ServerInstance, 'C') && c->GetPrefixValue(user) == OP_VALUE)
85 return MOD_RES_PASSTHRU;
88 if (!c->GetExtBanStatus(user, 'C').check(!c->IsModeSet('C')))
90 if ((text.length()) && (text[0] == '\1'))
92 if (strncmp(text.c_str(),"\1ACTION ",8))
94 user->WriteNumeric(ERR_NOCTCPALLOWED, "%s %s :Can't send CTCP to channel (+C set)",user->nick.c_str(), c->name.c_str());
100 return MOD_RES_PASSTHRU;
103 virtual void On005Numeric(std::string &output)
105 ServerInstance->AddExtBanChar('C');
109 MODULE_INIT(ModuleNoCTCP)