1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 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 * ---------------------------------------------------
20 /* $ModDesc: Provides support for channel mode +P to block all-CAPS channel messages and notices */
23 /** Handles the +P channel mode
25 class BlockCaps : public ModeHandler
28 BlockCaps(InspIRCd* Instance) : ModeHandler(Instance, '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(InspIRCd* Me) : Module::Module(Me)
62 bc = new BlockCaps(ServerInstance);
63 ServerInstance->AddMode(bc, 'P');
66 void Implements(char* List)
68 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
71 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
73 if (target_type == TYPE_CHANNEL)
75 chanrec* c = (chanrec*)dest;
77 if (c->IsModeSet('P'))
79 const char* i = text.c_str();
82 if (((*i != ' ') && (*i != '\t')) && ((*i < 'A') || (*i > 'Z')))
88 user->WriteServ( "404 %s %s :Can't send all-CAPS to channel (+P set)", user->nick, c->name);
95 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
97 return OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
100 virtual ~ModuleBlockCAPS()
102 ServerInstance->Modes->DelMode(bc);
106 virtual Version GetVersion()
108 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
113 class ModuleBlockCAPSFactory : public ModuleFactory
116 ModuleBlockCAPSFactory()
120 ~ModuleBlockCAPSFactory()
124 virtual Module * CreateModule(InspIRCd* Me)
126 return new ModuleBlockCAPS(Me);
132 extern "C" void * init_module( void )
134 return new ModuleBlockCAPSFactory;