1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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 * ---------------------------------------------------
16 /* $ModDesc: Provides support for unreal-style channel mode +C */
18 class NoCTCP : public ModeHandler
21 NoCTCP(InspIRCd* Instance) : ModeHandler(Instance, 'C', 0, 0, false, MODETYPE_CHANNEL, false) { }
23 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool)
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)
57 nc = new NoCTCP(ServerInstance);
58 if (!ServerInstance->Modes->AddMode(nc))
59 throw ModuleException("Could not add new modes!");
60 Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_On005Numeric };
61 ServerInstance->Modules->Attach(eventlist, this, 2);
64 virtual ~ModuleNoCTCP()
66 ServerInstance->Modes->DelMode(nc);
70 virtual Version GetVersion()
72 return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
75 virtual int OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
77 return OnUserPreNotice(user,dest,target_type,text,status,exempt_list);
80 virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
82 if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
84 Channel* c = (Channel*)dest;
86 if (CHANOPS_EXEMPT(ServerInstance, 'C') && c->GetStatus(user) == STATUS_OP)
91 if (c->IsModeSet('C') || c->IsExtBanned(user, 'C'))
93 if ((text.length()) && (text[0] == '\1'))
95 if (strncmp(text.c_str(),"\1ACTION ",8))
97 user->WriteNumeric(ERR_NOCTCPALLOWED, "%s %s :Can't send CTCP to channel (+C set)",user->nick.c_str(), c->name.c_str());
106 virtual void On005Numeric(std::string &output)
108 ServerInstance->AddExtBanChar('C');
112 MODULE_INIT(ModuleNoCTCP)