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 */
28 class BlockCaps : public ModeHandler
31 BlockCaps(InspIRCd* Instance) : ModeHandler(Instance, 'P', 0, 0, false, MODETYPE_CHANNEL, false) { }
33 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
37 if (!channel->IsModeSet('P'))
39 channel->SetMode('P',true);
40 return MODEACTION_ALLOW;
45 if (channel->IsModeSet('P'))
47 channel->SetMode('P',false);
48 return MODEACTION_ALLOW;
52 return MODEACTION_DENY;
56 class ModuleBlockCAPS : public Module
62 ModuleBlockCAPS(InspIRCd* Me) : Module::Module(Me)
65 bc = new BlockCaps(ServerInstance);
66 ServerInstance->AddMode(bc, 'P');
69 void Implements(char* List)
71 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
74 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
76 if (target_type == TYPE_CHANNEL)
78 chanrec* c = (chanrec*)dest;
80 if (c->IsModeSet('P'))
82 const char* i = text.c_str();
85 if (((*i != ' ') && (*i != '\t')) && ((*i < 'A') || (*i > 'Z')))
91 user->WriteServ( "404 %s %s :Can't send all-CAPS to channel (+P set)", user->nick, c->name);
98 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
100 return OnUserPreMessage(user,dest,target_type,text,status);
103 virtual ~ModuleBlockCAPS()
105 ServerInstance->Modes->DelMode(bc);
109 virtual Version GetVersion()
111 return Version(1,0,0,0,VF_COMMON|VF_VENDOR);
116 class ModuleBlockCAPSFactory : public ModuleFactory
119 ModuleBlockCAPSFactory()
123 ~ModuleBlockCAPSFactory()
127 virtual Module * CreateModule(InspIRCd* Me)
129 return new ModuleBlockCAPS(Me);
135 extern "C" void * init_module( void )
137 return new ModuleBlockCAPSFactory;