ModeHandler::ModeHandler(Module* Creator, const std::string& Name, char modeletter, ParamSpec Params, ModeType type)
: ServiceProvider(Creator, Name, SERVICE_MODE), m_paramtype(TR_TEXT),
parameters_taken(Params), mode(modeletter), prefix(0), oper(false),
- list(false), m_type(type), levelrequired(HALFOP_VALUE)
+ list(false), m_type(type), levelrequired(HALFOP_VALUE), prefixrank(0)
{
}
{
}
-bool ModeHandler::IsListMode()
-{
- return list;
-}
-
-unsigned int ModeHandler::GetPrefixRank()
-{
- return 0;
-}
-
int ModeHandler::GetNumParams(bool adding)
{
switch (parameters_taken)
/* Display user's current mode string */
user->WriteNumeric(RPL_UMODEIS, "%s :+%s",targetuser->nick.c_str(),targetuser->FormatModes());
if ((targetuser->IsOper()))
- user->WriteNumeric(RPL_SNOMASKIS, "%s +%s :Server notice mask", targetuser->nick.c_str(), targetuser->FormatNoticeMasks());
+ user->WriteNumeric(RPL_SNOMASKIS, "%s +%s :Server notice mask", targetuser->nick.c_str(), targetuser->FormatNoticeMasks().c_str());
return;
}
else
return MODEACTION_ALLOW;
}
-void ModeParser::Process(const std::vector<std::string>& parameters, User *user, bool merge)
+void ModeParser::Process(const std::vector<std::string>& parameters, User* user, ModeProcessFlag flags)
{
std::string target = parameters[0];
Channel* targetchannel = ServerInstance->FindChan(target);
/* Make sure the user isn't trying to slip in an invalid parameter */
if ((parameter.find(':') == 0) || (parameter.rfind(' ') != std::string::npos))
continue;
- if (merge && targetchannel && targetchannel->IsModeSet(modechar) && !mh->IsListMode())
+ if ((flags & MODE_MERGE) && targetchannel && targetchannel->IsModeSet(modechar) && !mh->IsListMode())
{
std::string ours = targetchannel->GetModeParameter(modechar);
if (!mh->ResolveModeConflict(parameter, ours, targetchannel))
LastParse.append(output_mode);
LastParse.append(output_parameters.str());
+ if (!(flags & MODE_LOCALONLY))
+ ServerInstance->PI->SendMode(user, targetuser, targetchannel, LastParseParams, LastParseTranslate);
+
if (targetchannel)
{
targetchannel->WriteChannel(user, "MODE %s", LastParse.c_str());
}
}
-const std::string& ModeParser::GetLastParse()
-{
- return LastParse;
-}
-
void ModeParser::CleanMask(std::string &mask)
{
std::string::size_type pos_of_pling = mask.find_first_of('!');
stackresult.push_back(chan->name);
while (stack.GetStackedLine(stackresult))
{
- ServerInstance->SendMode(stackresult, ServerInstance->FakeClient);
+ this->Process(stackresult, ServerInstance->FakeClient, MODE_LOCALONLY);
stackresult.erase(stackresult.begin() + 1, stackresult.end());
}
}