* ---------------------------------------------------
*/
-#include <stdio.h>
-#include <sstream>
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
#include "inspircd.h"
/* $ModDesc: Provides support for unreal-style channel mode +c */
class ModuleBlockColour : public Module
{
-
+ bool AllowChanOps;
BlockColor *bc;
public:
- ModuleBlockColour(InspIRCd* Me) : Module::Module(Me)
+ ModuleBlockColour(InspIRCd* Me) : Module(Me)
{
-
bc = new BlockColor(ServerInstance);
if (!ServerInstance->AddMode(bc, 'c'))
throw ModuleException("Could not add new modes!");
List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
}
+
virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
if(c->IsModeSet('c'))
{
- /* Replace a strlcpy(), which ran even when +c wasn't set, with this (no copies at all) -- Om */
- for (std::string::iterator i = text.begin(); i != text.end(); i++)
+ if (!CHANOPS_EXEMPT(ServerInstance, 'c') || CHANOPS_EXEMPT(ServerInstance, 'c') && c->GetStatus(user) != STATUS_OP)
{
- switch (*i)
+ for (std::string::iterator i = text.begin(); i != text.end(); i++)
{
- case 2:
- case 3:
- case 15:
- case 21:
- case 22:
- case 31:
- user->WriteServ("404 %s %s :Can't send colours to channel (+c set)",user->nick, c->name);
- return 1;
- break;
+ switch (*i)
+ {
+ case 2:
+ case 3:
+ case 15:
+ case 21:
+ case 22:
+ case 31:
+ user->WriteServ("404 %s %s :Can't send colours to channel (+c set)",user->nick, c->name);
+ return 1;
+ break;
+ }
}
}
}
}
};
-
-class ModuleBlockColourFactory : public ModuleFactory
-{
- public:
- ModuleBlockColourFactory()
- {
- }
-
- ~ModuleBlockColourFactory()
- {
- }
-
- virtual Module * CreateModule(InspIRCd* Me)
- {
- return new ModuleBlockColour(Me);
- }
-
-};
-
-
-extern "C" void * init_module( void )
-{
- return new ModuleBlockColourFactory;
-}
+MODULE_INIT(ModuleBlockColour)