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 * ---------------------------------------------------
19 /* $ModDesc: Provides support for unreal-style channel mode +c */
21 /** Handles the +c channel mode
23 class BlockColor : public ModeHandler
26 BlockColor(InspIRCd* Instance) : ModeHandler(Instance, 'c', 0, 0, false, MODETYPE_CHANNEL, false) { }
28 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
32 if (!channel->IsModeSet('c'))
34 channel->SetMode('c',true);
35 return MODEACTION_ALLOW;
40 if (channel->IsModeSet('c'))
42 channel->SetMode('c',false);
43 return MODEACTION_ALLOW;
47 return MODEACTION_DENY;
51 class ModuleBlockColour : public Module
57 ModuleBlockColour(InspIRCd* Me) : Module(Me)
59 bc = new BlockColor(ServerInstance);
60 if (!ServerInstance->AddMode(bc, 'c'))
61 throw ModuleException("Could not add new modes!");
64 void Implements(char* List)
66 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
70 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
72 if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
74 chanrec* c = (chanrec*)dest;
78 if (!CHANOPS_EXEMPT(ServerInstance, 'c') || CHANOPS_EXEMPT(ServerInstance, 'c') && c->GetStatus(user) != STATUS_OP)
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);
101 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
103 return OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
106 virtual ~ModuleBlockColour()
108 ServerInstance->Modes->DelMode(bc);
112 virtual Version GetVersion()
114 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
119 class ModuleBlockColourFactory : public ModuleFactory
122 ModuleBlockColourFactory()
126 ~ModuleBlockColourFactory()
130 virtual Module * CreateModule(InspIRCd* Me)
132 return new ModuleBlockColour(Me);
138 extern "C" DllExport void * init_module( void )
140 return new ModuleBlockColourFactory;