summaryrefslogtreecommitdiff
path: root/src/mode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mode.cpp')
-rw-r--r--src/mode.cpp44
1 files changed, 26 insertions, 18 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index ad46e602d..eeab0de3a 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -127,21 +127,6 @@ ModeAction SimpleChannelModeHandler::OnModeChange(User* source, User* dest, Chan
return MODEACTION_ALLOW;
}
-ModeAction ParamChannelModeHandler::OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
-{
- if (adding && !ParamValidate(parameter))
- return MODEACTION_DENY;
- std::string now = channel->GetModeParameter(this);
- if (parameter == now)
- return MODEACTION_DENY;
- return MODEACTION_ALLOW;
-}
-
-bool ParamChannelModeHandler::ParamValidate(std::string& parameter)
-{
- return true;
-}
-
ModeWatcher::ModeWatcher(Module* Creator, const std::string& modename, ModeType type)
: mode(modename), m_type(type), creator(Creator)
{
@@ -227,6 +212,32 @@ ModeAction PrefixMode::OnModeChange(User* source, User*, Channel* chan, std::str
return (memb->SetPrefix(this, adding) ? MODEACTION_ALLOW : MODEACTION_DENY);
}
+ModeAction ParamModeBase::OnModeChange(User* source, User*, Channel* chan, std::string& parameter, bool adding)
+{
+ if (adding)
+ {
+ if (chan->GetModeParameter(this) == parameter)
+ return MODEACTION_DENY;
+
+ if (OnSet(source, chan, parameter) != MODEACTION_ALLOW)
+ return MODEACTION_DENY;
+
+ chan->SetMode(this, true);
+
+ // Handler might have changed the parameter internally
+ parameter.clear();
+ this->GetParameter(chan, parameter);
+ }
+ else
+ {
+ if (!chan->IsModeSet(this))
+ return MODEACTION_DENY;
+ this->OnUnsetInternal(source, chan);
+ chan->SetMode(this, false);
+ }
+ return MODEACTION_ALLOW;
+}
+
ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool adding, const unsigned char modechar,
std::string &parameter, bool SkipACL)
{
@@ -336,9 +347,6 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool
if (ma != MODEACTION_ALLOW)
return ma;
- if ((!mh->IsListMode()) && (mh->GetNumParams(true)) && (chan))
- chan->SetModeParam(mh, (adding ? parameter : ""));
-
itpair = modewatchermap.equal_range(mh->name);
for (ModeWatchIter i = itpair.first; i != itpair.second; ++i)
{