1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
11 * Written by Craig Edwards, Craig McLure, and others.
12 * This program is free but copyrighted software; see
13 * the file COPYING for details.
15 * ---------------------------------------------------
21 #include "helperfuncs.h"
23 /* $ModDesc: Provides support for channel mode +P to block all-CAPS channel messages and notices */
25 class ModuleBlockCAPS : public Module
30 ModuleBlockCAPS(Server* Me) : Module::Module(Me)
33 Srv->AddExtendedMode('P', MT_CHANNEL, false, 0, 0);
36 void Implements(char* List)
38 List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnExtendedMode] = 1;
41 virtual void On005Numeric(std::string &output)
43 InsertMode(output, "P", 4);
46 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
48 if (target_type == TYPE_CHANNEL)
50 chanrec* c = (chanrec*)dest;
52 if (c->IsCustomModeSet('P'))
54 char* i = (char*)text.c_str();
57 if (((*i != ' ') && (*i != '\t')) && ((*i < 'A') || (*i > 'Z')))
63 WriteServ(user->fd, "404 %s %s :Can't send all-CAPS to channel (+P set)", user->nick, c->name);
70 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
72 return OnUserPreMessage(user,dest,target_type,text,status);
75 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
77 // check if this is our mode character...
78 if ((modechar == 'P') && (type == MT_CHANNEL))
80 log(DEBUG,"Allowing P change");
89 virtual ~ModuleBlockCAPS()
93 virtual Version GetVersion()
95 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
100 class ModuleBlockCAPSFactory : public ModuleFactory
103 ModuleBlockCAPSFactory()
107 ~ModuleBlockCAPSFactory()
111 virtual Module * CreateModule(Server* Me)
113 return new ModuleBlockCAPS(Me);
119 extern "C" void * init_module( void )
121 return new ModuleBlockCAPSFactory;