void SetOperPrefix(User* user, bool add) { Modes::ChangeList changelist; changelist.push(&opm, add, user->nick); for (User::ChanList::iterator v = user->chans.begin(); v != user->chans.end(); v++) ServerInstance->Modes->Process(ServerInstance->FakeClient, (*v)->chan, NULL, changelist); }
void ModeParser::ModeParamsToChangeList(User* user, ModeType type, const std::vector<std::string>& parameters, Modes::ChangeList& changelist, unsigned int beginindex, unsigned int endindex) { if (endindex > parameters.size()) endindex = parameters.size(); const std::string& mode_sequence = parameters[beginindex]; bool adding = true; unsigned int param_at = beginindex+1; for (std::string::const_iterator letter = mode_sequence.begin(); letter != mode_sequence.end(); letter++) { unsigned char modechar = *letter; if (modechar == '+' || modechar == '-') { adding = (modechar == '+'); continue; } ModeHandler *mh = this->FindMode(modechar, type); if (!mh) { /* No mode handler? Unknown mode character then. */ user->WriteNumeric(type == MODETYPE_CHANNEL ? ERR_UNKNOWNMODE : ERR_UNKNOWNSNOMASK, "%c :is unknown mode char to me", modechar); continue; } std::string parameter; if (mh->GetNumParams(adding) && param_at < endindex) parameter = parameters[param_at++]; changelist.push(mh, adding, parameter); } }
CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* src) { Channel* const chan = ServerInstance->FindChan(parameters[0]); if (!chan) { src->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } if (parameters.size() == 1) { DisplayList(src, chan); return CMD_SUCCESS; } unsigned int i = 1; Modes::ChangeList modes; while (i < parameters.size()) { std::string prop = parameters[i++]; if (prop.empty()) continue; bool plus = prop[0] != '-'; if (prop[0] == '+' || prop[0] == '-') prop.erase(prop.begin()); ModeHandler* mh = ServerInstance->Modes->FindMode(prop, MODETYPE_CHANNEL); if (mh) { if (mh->NeedsParam(plus)) { if (i != parameters.size()) modes.push(mh, plus, parameters[i++]); } else modes.push(mh, plus); } } ServerInstance->Modes->ProcessSingle(src, chan, NULL, modes, ModeParser::MODE_CHECKACCESS); return CMD_SUCCESS; }