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>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
26 /* $ModDesc: Provides support for unreal-style channel mode +c */
30 class BlockColor : public ModeHandler
33 BlockColor(InspIRCd* Instance) : ModeHandler(Instance, 'c', 0, 0, false, MODETYPE_CHANNEL, false) { }
35 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
39 if (!channel->IsModeSet('c'))
41 channel->SetMode('c',true);
42 return MODEACTION_ALLOW;
47 if (channel->IsModeSet('c'))
49 channel->SetMode('c',false);
50 return MODEACTION_ALLOW;
54 return MODEACTION_DENY;
58 class ModuleBlockColour : public Module
64 ModuleBlockColour(InspIRCd* Me) : Module::Module(Me)
67 bc = new BlockColor(ServerInstance);
68 ServerInstance->AddMode(bc, 'c');
71 void Implements(char* List)
73 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
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;
84 /* Replace a strlcpy(), which ran even when +c wasn't set, with this (no copies at all) -- Om */
85 for (std::string::iterator i = text.begin(); i != text.end(); i++)
95 user->WriteServ("404 %s %s :Can't send colours to channel (+c set)",user->nick, c->name);
105 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
107 return OnUserPreMessage(user,dest,target_type,text,status);
110 virtual ~ModuleBlockColour()
112 ServerInstance->Modes->DelMode(bc);
116 virtual Version GetVersion()
118 return Version(1,0,0,0,VF_COMMON|VF_VENDOR);
123 class ModuleBlockColourFactory : public ModuleFactory
126 ModuleBlockColourFactory()
130 ~ModuleBlockColourFactory()
134 virtual Module * CreateModule(InspIRCd* Me)
136 return new ModuleBlockColour(Me);
142 extern "C" void * init_module( void )
144 return new ModuleBlockColourFactory;