From f535b1ef72eb4c298ce999bac791acb48665dc66 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 4 Sep 2014 13:04:01 +0200 Subject: m_namedmodes Build and process a Modes::ChangeList when handling PROP --- src/modules/m_namedmodes.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/modules/m_namedmodes.cpp b/src/modules/m_namedmodes.cpp index 4004db00e..19dff1a8b 100644 --- a/src/modules/m_namedmodes.cpp +++ b/src/modules/m_namedmodes.cpp @@ -47,17 +47,20 @@ class CommandProp : public Command CmdResult Handle(const std::vector ¶meters, User *src) { + Channel* const chan = ServerInstance->FindChan(parameters[0]); + if (!chan) + { + src->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + return CMD_FAILURE; + } + if (parameters.size() == 1) { - Channel* chan = ServerInstance->FindChan(parameters[0]); - if (chan) - DisplayList(src, chan); + DisplayList(src, chan); return CMD_SUCCESS; } unsigned int i = 1; - std::vector modes; - modes.push_back(parameters[0]); - modes.push_back(""); + Modes::ChangeList modes; while (i < parameters.size()) { std::string prop = parameters[i++]; @@ -68,16 +71,16 @@ class CommandProp : public Command ModeHandler* mh = ServerInstance->Modes->FindMode(prop, MODETYPE_CHANNEL); if (mh) { - modes[1].push_back(plus ? '+' : '-'); - modes[1].push_back(mh->GetModeChar()); if (mh->GetNumParams(plus)) { if (i != parameters.size()) - modes.push_back(parameters[i++]); + modes.push(mh, plus, parameters[i++]); } + else + modes.push(mh, plus); } } - ServerInstance->Modes->Process(modes, src); + ServerInstance->Modes->ProcessSingle(src, chan, NULL, modes, ModeParser::MODE_CHECKACCESS); return CMD_SUCCESS; } }; -- cgit v1.2.3