X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_stripcolor.cpp;h=420e2e6e293c1ad0413b86142b6dd2c7f1f82425;hb=8e89fe75f9467969bce1dc6930befc6ef273edf6;hp=17c0a2f300dd41caff7314b55761e54283f5672a;hpb=2574b4118d6acd11feb2682ec8d9cd51f35e14e2;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp index 17c0a2f30..420e2e6e2 100644 --- a/src/modules/m_stripcolor.cpp +++ b/src/modules/m_stripcolor.cpp @@ -17,66 +17,18 @@ /** Handles channel mode +S */ -class ChannelStripColor : public ModeHandler +class ChannelStripColor : public SimpleChannelModeHandler { public: - ChannelStripColor(InspIRCd* Instance) : ModeHandler(Instance, 'S', 0, 0, false, MODETYPE_CHANNEL, false) { } - - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool servermode) - { - if (adding) - { - if (!channel->IsModeSet('S')) - { - channel->SetMode('S',true); - return MODEACTION_ALLOW; - } - } - else - { - if (channel->IsModeSet('S')) - { - channel->SetMode('S',false); - return MODEACTION_ALLOW; - } - } - - return MODEACTION_DENY; - } + ChannelStripColor(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'S') { } }; /** Handles user mode +S */ -class UserStripColor : public ModeHandler +class UserStripColor : public SimpleUserModeHandler { public: - UserStripColor(InspIRCd* Instance) : ModeHandler(Instance, 'S', 0, 0, false, MODETYPE_USER, false) { } - - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool servermode) - { - /* Only opers can change other users modes */ - if (source != dest) - return MODEACTION_DENY; - - if (adding) - { - if (!dest->IsModeSet('S')) - { - dest->SetMode('S',true); - return MODEACTION_ALLOW; - } - } - else - { - if (dest->IsModeSet('S')) - { - dest->SetMode('S',false); - return MODEACTION_ALLOW; - } - } - - return MODEACTION_DENY; - } + UserStripColor(InspIRCd* Instance) : SimpleUserModeHandler(Instance, 'S') { } }; @@ -112,7 +64,7 @@ class ModuleStripColor : public Module /* refactor this completely due to SQUIT bug since the old code would strip last char and replace with \0 --peavey */ int seq = 0; std::string::iterator i,safei; - for (i = sentence.begin(); i != sentence.end(); ++i) + for (i = sentence.begin(); i != sentence.end();) { if ((*i == 3)) seq = 1; @@ -129,10 +81,21 @@ class ModuleStripColor : public Module if (seq || ((*i == 2) || (*i == 15) || (*i == 22) || (*i == 21) || (*i == 31))) { - safei = i; - --i; - sentence.erase(safei); + if (i != sentence.begin()) + { + safei = i; + --i; + sentence.erase(safei); + ++i; + } + else + { + sentence.erase(i); + i = sentence.begin(); + } } + else + ++i; } } @@ -153,8 +116,12 @@ class ModuleStripColor : public Module // 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') || CHANOPS_EXEMPT(ServerInstance, 'S') && t->GetStatus(user) != STATUS_OP) - active = t->IsModeSet('S'); + if (CHANOPS_EXEMPT(ServerInstance, 'S') && t->GetStatus(user) == STATUS_OP) + { + return 0; + } + + active = t->IsModeSet('S'); } if (active) @@ -172,7 +139,7 @@ class ModuleStripColor : 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); } };