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 * ---------------------------------------------------
24 #include "helperfuncs.h"
27 /* $ModDesc: Provides support for unreal-style channel mode +c */
29 extern InspIRCd* ServerInstance;
31 class BlockColor : public ModeHandler
34 BlockColor(InspIRCd* Instance) : ModeHandler(Instance, 'c', 0, 0, false, MODETYPE_CHANNEL, false) { }
36 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
40 if (!channel->IsModeSet('c'))
42 channel->SetMode('c',true);
43 return MODEACTION_ALLOW;
48 if (channel->IsModeSet('c'))
50 channel->SetMode('c',false);
51 return MODEACTION_ALLOW;
55 return MODEACTION_DENY;
59 class ModuleBlockColour : public Module
65 ModuleBlockColour(Server* Me) : Module::Module(Me)
68 bc = new BlockColor(ServerInstance);
69 Srv->AddMode(bc, 'c');
72 void Implements(char* List)
74 List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
77 virtual void On005Numeric(std::string &output)
79 ServerInstance->ModeGrok->InsertMode(output,"c",4);
82 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
84 if (target_type == TYPE_CHANNEL)
86 chanrec* c = (chanrec*)dest;
90 /* Replace a strlcpy(), which ran even when +c wasn't set, with this (no copies at all) -- Om */
91 for (std::string::iterator i = text.begin(); i != text.end(); i++)
101 user->WriteServ("404 %s %s :Can't send colours to channel (+c set)",user->nick, c->name);
111 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
113 return OnUserPreMessage(user,dest,target_type,text,status);
116 virtual ~ModuleBlockColour()
121 virtual Version GetVersion()
123 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
128 class ModuleBlockColourFactory : public ModuleFactory
131 ModuleBlockColourFactory()
135 ~ModuleBlockColourFactory()
139 virtual Module * CreateModule(Server* Me)
141 return new ModuleBlockColour(Me);
147 extern "C" void * init_module( void )
149 return new ModuleBlockColourFactory;