X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_blockcolor.cpp;h=3e97f82877b6c7b85d4e65f69ef18a37a3c96acb;hb=bc344671460c1675fbc31504fd1ffc03ff58a135;hp=53297483ed9e1c93733612a2bad1e89faa352d81;hpb=e4acbc95b8b6cd5b28d38a2242c02e8ff4991e4a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp index 53297483e..3e97f8287 100644 --- a/src/modules/m_blockcolor.cpp +++ b/src/modules/m_blockcolor.cpp @@ -17,32 +17,10 @@ /** Handles the +c channel mode */ -class BlockColor : public ModeHandler +class BlockColor : public SimpleChannelModeHandler { public: - BlockColor(InspIRCd* Instance) : ModeHandler(Instance, 'c', 0, 0, false, MODETYPE_CHANNEL, false) { } - - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) - { - if (adding) - { - if (!channel->IsModeSet('c')) - { - channel->SetMode('c',true); - return MODEACTION_ALLOW; - } - } - else - { - if (channel->IsModeSet('c')) - { - channel->SetMode('c',false); - return MODEACTION_ALLOW; - } - } - - return MODEACTION_DENY; - } + BlockColor(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'c') { } }; class ModuleBlockColour : public Module @@ -54,7 +32,7 @@ class ModuleBlockColour : public Module ModuleBlockColour(InspIRCd* Me) : Module(Me) { bc = new BlockColor(ServerInstance); - if (!ServerInstance->AddMode(bc)) + if (!ServerInstance->Modes->AddMode(bc)) throw ModuleException("Could not add new modes!"); Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice }; ServerInstance->Modules->Attach(eventlist, this, 2); @@ -67,25 +45,27 @@ class ModuleBlockColour : public Module if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user))) { Channel* c = (Channel*)dest; + + if (CHANOPS_EXEMPT(ServerInstance, 'c') && c->GetStatus(user) == STATUS_OP) + { + return 0; + } if(c->IsModeSet('c')) { - if (!CHANOPS_EXEMPT(ServerInstance, 'c') || CHANOPS_EXEMPT(ServerInstance, 'c') && c->GetStatus(user) != STATUS_OP) + for (std::string::iterator i = text.begin(); i != text.end(); i++) { - for (std::string::iterator i = text.begin(); i != text.end(); i++) + switch (*i) { - switch (*i) - { - case 2: - case 3: - case 15: - case 21: - case 22: - case 31: - user->WriteServ("404 %s %s :Can't send colours to channel (+c set)",user->nick, c->name); - return 1; - break; - } + case 2: + case 3: + case 15: + case 21: + case 22: + case 31: + user->WriteNumeric(404, "%s %s :Can't send colours to channel (+c set)",user->nick, c->name); + return 1; + break; } } } @@ -106,7 +86,7 @@ class ModuleBlockColour : public Module virtual Version GetVersion() { - return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION); + return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION); } };