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)
61 bc = new BlockColor(ServerInstance);
62 if (!ServerInstance->AddMode(bc, 'c'))
63 throw ModuleException("Could not add new modes!");
68 void Implements(char* List)
70 List[I_OnRehash] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
74 virtual void OnRehash(userrec* user, const std::string ¶meter)
76 ConfigReader Conf(ServerInstance);
78 AllowChanOps = Conf.ReadFlag("blockcolor", "allowchanops", 0);
81 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
83 if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
85 chanrec* c = (chanrec*)dest;
89 if (!AllowChanOps || AllowChanOps && c->GetStatus(user) != STATUS_OP)
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);
112 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
114 return OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
117 virtual ~ModuleBlockColour()
119 ServerInstance->Modes->DelMode(bc);
123 virtual Version GetVersion()
125 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
130 class ModuleBlockColourFactory : public ModuleFactory
133 ModuleBlockColourFactory()
137 ~ModuleBlockColourFactory()
141 virtual Module * CreateModule(InspIRCd* Me)
143 return new ModuleBlockColour(Me);
149 extern "C" void * init_module( void )
151 return new ModuleBlockColourFactory;