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 * ---------------------------------------------------
27 /* $ModDesc: Provides support for unreal-style channel mode +c */
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(InspIRCd* Me) : Module::Module(Me)
68 bc = new BlockColor(ServerInstance);
69 ServerInstance->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)
81 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
83 if (target_type == TYPE_CHANNEL)
85 chanrec* c = (chanrec*)dest;
89 /* Replace a strlcpy(), which ran even when +c wasn't set, with this (no copies at all) -- Om */
90 for (std::string::iterator i = text.begin(); i != text.end(); i++)
100 user->WriteServ("404 %s %s :Can't send colours to channel (+c set)",user->nick, c->name);
110 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
112 return OnUserPreMessage(user,dest,target_type,text,status);
115 virtual ~ModuleBlockColour()
120 virtual Version GetVersion()
122 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
127 class ModuleBlockColourFactory : public ModuleFactory
130 ModuleBlockColourFactory()
134 ~ModuleBlockColourFactory()
138 virtual Module * CreateModule(InspIRCd* Me)
140 return new ModuleBlockColour(Me);
146 extern "C" void * init_module( void )
148 return new ModuleBlockColourFactory;