X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_stripcolor.cpp;h=5b02309dc6bb6a323f37d5116e1cb30fdd896b4e;hb=b43fc66c17c2bef6dca66a966676b8128d5774ee;hp=19f658ee0f628bf05b0880c44c9267cf73089756;hpb=b6dbd6caab62bc2c0d11ce5a45d511611eb9c2ef;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp index 19f658ee0..5b02309dc 100644 --- a/src/modules/m_stripcolor.cpp +++ b/src/modules/m_stripcolor.cpp @@ -20,7 +20,7 @@ class ChannelStripColor : public SimpleChannelModeHandler { public: - ChannelStripColor(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'S') { } + ChannelStripColor(Module* Creator) : SimpleChannelModeHandler(Creator, "stripcolor", 'S') { } }; /** Handles user mode +S @@ -28,23 +28,20 @@ class ChannelStripColor : public SimpleChannelModeHandler class UserStripColor : public SimpleUserModeHandler { public: - UserStripColor(InspIRCd* Instance) : SimpleUserModeHandler(Instance, 'S') { } + UserStripColor(Module* Creator) : SimpleUserModeHandler(Creator, "stripcolor", 'S') { } }; class ModuleStripColor : public Module { bool AllowChanOps; - ChannelStripColor *csc; - UserStripColor *usc; + ChannelStripColor csc; + UserStripColor usc; public: - ModuleStripColor(InspIRCd* Me) : Module(Me) + ModuleStripColor() : csc(this), usc(this) { - usc = new UserStripColor(ServerInstance); - csc = new ChannelStripColor(ServerInstance); - - if (!ServerInstance->Modes->AddMode(usc) || !ServerInstance->Modes->AddMode(csc)) + if (!ServerInstance->Modes->AddMode(&usc) || !ServerInstance->Modes->AddMode(&csc)) throw ModuleException("Could not add new modes!"); Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_On005Numeric }; ServerInstance->Modules->Attach(eventlist, this, 3); @@ -52,10 +49,6 @@ class ModuleStripColor : public Module virtual ~ModuleStripColor() { - ServerInstance->Modes->DelMode(usc); - ServerInstance->Modes->DelMode(csc); - delete usc; - delete csc; } virtual void On005Numeric(std::string &output) @@ -103,10 +96,10 @@ class ModuleStripColor : public Module } } - virtual int OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) + virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) { if (!IS_LOCAL(user)) - return 0; + return MOD_RES_PASSTHRU; bool active = false; if (target_type == TYPE_USER) @@ -117,15 +110,13 @@ class ModuleStripColor : public Module else if (target_type == TYPE_CHANNEL) { Channel* t = (Channel*)dest; + ModResult res; + FIRST_MOD_RESULT(OnChannelRestrictionApply, res, (user,t,"stripcolor")); - // check if we allow ops to bypass filtering, if we do, check if they're opped accordingly. - // note: short circut logic here, don't wreck it. -- w00t - if (CHANOPS_EXEMPT(ServerInstance, 'S') && t->GetStatus(user) == STATUS_OP) - { - return 0; - } + if (res == MOD_RES_ALLOW) + return MOD_RES_PASSTHRU; - active = t->IsModeSet('S') || t->GetExtBanStatus(user, 'S') < 0; + active = !t->GetExtBanStatus(user, 'S').check(!t->IsModeSet('S')); } if (active) @@ -133,17 +124,17 @@ class ModuleStripColor : public Module this->ReplaceLine(text); } - return 0; + return MOD_RES_PASSTHRU; } - virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) + virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) { return OnUserPreMessage(user,dest,target_type,text,status,exempt_list); } virtual Version GetVersion() { - return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION); + return Version("Provides channel +S mode (strip ansi colour)", VF_COMMON | VF_VENDOR); } };