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 * ---------------------------------------------------
24 /* $ModDesc: Provides support for channel mode +P to block all-CAPS channel messages and notices */
27 /** Handles the +P channel mode
29 class BlockCaps : public ModeHandler
32 BlockCaps(InspIRCd* Instance) : ModeHandler(Instance, 'P', 0, 0, false, MODETYPE_CHANNEL, false) { }
34 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
38 if (!channel->IsModeSet('P'))
40 channel->SetMode('P',true);
41 return MODEACTION_ALLOW;
46 if (channel->IsModeSet('P'))
48 channel->SetMode('P',false);
49 return MODEACTION_ALLOW;
53 return MODEACTION_DENY;
57 class ModuleBlockCAPS : public Module
63 ModuleBlockCAPS(InspIRCd* Me) : Module::Module(Me)
66 bc = new BlockCaps(ServerInstance);
67 ServerInstance->AddMode(bc, 'P');
70 void Implements(char* List)
72 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
75 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
77 if (target_type == TYPE_CHANNEL)
79 chanrec* c = (chanrec*)dest;
81 if (c->IsModeSet('P'))
83 const char* i = text.c_str();
86 if (((*i != ' ') && (*i != '\t')) && ((*i < 'A') || (*i > 'Z')))
92 user->WriteServ( "404 %s %s :Can't send all-CAPS to channel (+P set)", user->nick, c->name);
99 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
101 return OnUserPreMessage(user,dest,target_type,text,status);
104 virtual ~ModuleBlockCAPS()
106 ServerInstance->Modes->DelMode(bc);
110 virtual Version GetVersion()
112 return Version(1,0,0,0,VF_COMMON|VF_VENDOR);
117 class ModuleBlockCAPSFactory : public ModuleFactory
120 ModuleBlockCAPSFactory()
124 ~ModuleBlockCAPSFactory()
128 virtual Module * CreateModule(InspIRCd* Me)
130 return new ModuleBlockCAPS(Me);
136 extern "C" void * init_module( void )
138 return new ModuleBlockCAPSFactory;