1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 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(Module* Creator) : ModeHandler(Creator, "noctcp", 'C', PARAM_NONE, MODETYPE_CHANNEL) { }
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
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()
66 virtual Version GetVersion()
68 return Version("Provides support for unreal-style channel mode +C", VF_VENDOR);
71 virtual ModResult OnUserPreMessage(User* 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 ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
78 if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
80 Channel* c = (Channel*)dest;
82 FIRST_MOD_RESULT(OnChannelRestrictionApply, res, (user,c,"noctcp"));
84 if (res == MOD_RES_ALLOW)
85 return MOD_RES_PASSTHRU;
87 if (!c->GetExtBanStatus(user, 'C').check(!c->IsModeSet('C')))
89 if ((text.length()) && (text[0] == '\1'))
91 if (strncmp(text.c_str(),"\1ACTION ",8))
93 user->WriteNumeric(ERR_NOCTCPALLOWED, "%s %s :Can't send CTCP to channel (+C set)",user->nick.c_str(), c->name.c_str());
99 return MOD_RES_PASSTHRU;
102 virtual void On005Numeric(std::string &output)
104 ServerInstance->AddExtBanChar('C');
108 MODULE_INIT(ModuleNoCTCP)