1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Provides support for unreal-style channel mode +c */
18 /** Handles the +c channel mode
20 class BlockColor : public SimpleChannelModeHandler
23 BlockColor(Module* Creator) : SimpleChannelModeHandler(Creator, "blockcolor", 'c') { }
26 class ModuleBlockColour : public Module
32 ModuleBlockColour() : bc(this)
34 if (!ServerInstance->Modes->AddMode(&bc))
35 throw ModuleException("Could not add new modes!");
36 Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_On005Numeric };
37 ServerInstance->Modules->Attach(eventlist, this, 3);
40 virtual void On005Numeric(std::string &output)
42 ServerInstance->AddExtBanChar('c');
45 virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
47 if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
49 Channel* c = (Channel*)dest;
51 FIRST_MOD_RESULT(OnChannelRestrictionApply, res, (user,c,"blockcolor"));
53 if (res == MOD_RES_ALLOW)
54 return MOD_RES_PASSTHRU;
56 if (!c->GetExtBanStatus(user, 'c').check(!c->IsModeSet('c')))
58 for (std::string::iterator i = text.begin(); i != text.end(); i++)
68 user->WriteNumeric(404, "%s %s :Can't send colours to channel (+c set)",user->nick.c_str(), c->name.c_str());
75 return MOD_RES_PASSTHRU;
78 virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
80 return OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
83 virtual ~ModuleBlockColour()
87 virtual Version GetVersion()
89 return Version("Provides support for unreal-style channel mode +c",VF_VENDOR);
93 MODULE_INIT(ModuleBlockColour)