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 BlockCaps : public ModeHandler
28 BlockCaps() : ModeHandler('P', 0, 0, false, MODETYPE_CHANNEL, false) { }
30 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
34 if (!channel->IsModeSet('P'))
36 channel->SetMode('P',true);
37 return MODEACTION_ALLOW;
42 if (channel->IsModeSet('P'))
44 channel->SetMode('P',false);
45 return MODEACTION_ALLOW;
49 return MODEACTION_DENY;
53 class ModuleBlockCAPS : public Module
59 ModuleBlockCAPS(Server* Me) : Module::Module(Me)
63 Srv->AddMode(bc, 'P');
66 void Implements(char* List)
68 List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
71 virtual void On005Numeric(std::string &output)
73 InsertMode(output, "P", 4);
76 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
78 if (target_type == TYPE_CHANNEL)
80 chanrec* c = (chanrec*)dest;
82 if (c->IsModeSet('P'))
84 const char* i = text.c_str();
87 if (((*i != ' ') && (*i != '\t')) && ((*i < 'A') || (*i > 'Z')))
93 WriteServ(user->fd, "404 %s %s :Can't send all-CAPS to channel (+P set)", user->nick, c->name);
100 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
102 return OnUserPreMessage(user,dest,target_type,text,status);
105 virtual ~ModuleBlockCAPS()
109 virtual Version GetVersion()
111 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
116 class ModuleBlockCAPSFactory : public ModuleFactory
119 ModuleBlockCAPSFactory()
123 ~ModuleBlockCAPSFactory()
127 virtual Module * CreateModule(Server* Me)
129 return new ModuleBlockCAPS(Me);
135 extern "C" void * init_module( void )
137 return new ModuleBlockCAPSFactory;