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 * ---------------------------------------------------
21 /* $ModDesc: Provides support for unreal-style channel mode +c */
23 /** Handles the +c channel mode
25 class BlockColor : public ModeHandler
28 BlockColor(InspIRCd* Instance) : ModeHandler(Instance, 'c', 0, 0, false, MODETYPE_CHANNEL, false) { }
30 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
34 if (!channel->IsModeSet('c'))
36 channel->SetMode('c',true);
37 return MODEACTION_ALLOW;
42 if (channel->IsModeSet('c'))
44 channel->SetMode('c',false);
45 return MODEACTION_ALLOW;
49 return MODEACTION_DENY;
53 class ModuleBlockColour : public Module
59 ModuleBlockColour(InspIRCd* Me) : Module::Module(Me)
62 bc = new BlockColor(ServerInstance);
63 ServerInstance->AddMode(bc, 'c');
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;
79 /* Replace a strlcpy(), which ran even when +c wasn't set, with this (no copies at all) -- Om */
80 for (std::string::iterator i = text.begin(); i != text.end(); i++)
90 user->WriteServ("404 %s %s :Can't send colours to channel (+c set)",user->nick, c->name);
100 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
102 return OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
105 virtual ~ModuleBlockColour()
107 ServerInstance->Modes->DelMode(bc);
111 virtual Version GetVersion()
113 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
118 class ModuleBlockColourFactory : public ModuleFactory
121 ModuleBlockColourFactory()
125 ~ModuleBlockColourFactory()
129 virtual Module * CreateModule(InspIRCd* Me)
131 return new ModuleBlockColour(Me);
137 extern "C" void * init_module( void )
139 return new ModuleBlockColourFactory;