targetuser = ServerInstance->FindNick(target);
}
- if ((!targetchannel) && ((!targetuser) || (IS_SERVER(targetuser))))
+ if ((!targetchannel) && (!targetuser))
{
- user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", target.c_str());
+ user->WriteNumeric(Numerics::NoSuchNick(target));
return CMD_FAILURE;
}
if (parameters.size() == 1)
if ((targetuser) && (user != targetuser))
{
// Local users may only change the modes of other users if a module explicitly allows it
- user->WriteNumeric(ERR_USERSDONTMATCH, ":Can't change mode for other users");
+ user->WriteNumeric(ERR_USERSDONTMATCH, "Can't change mode for other users");
return CMD_FAILURE;
}
else
flags |= ModeParser::MODE_LOCALONLY;
- ServerInstance->Modes->ProcessSingle(user, targetchannel, targetuser, changelist, flags);
+ if (IS_LOCAL(user))
+ ServerInstance->Modes->ProcessSingle(user, targetchannel, targetuser, changelist, flags);
+ else
+ ServerInstance->Modes->Process(user, targetchannel, targetuser, changelist, flags);
if ((ServerInstance->Modes.GetLastParse().empty()) && (targetchannel) && (parameters.size() == 2))
{
if (targetchannel)
{
// Display channel's current mode string
- user->WriteNumeric(RPL_CHANNELMODEIS, "%s +%s", targetchannel->name.c_str(), targetchannel->ChanModes(targetchannel->HasUser(user)));
- user->WriteNumeric(RPL_CHANNELCREATED, "%s %lu", targetchannel->name.c_str(), (unsigned long)targetchannel->age);
+ user->WriteNumeric(RPL_CHANNELMODEIS, targetchannel->name, (std::string("+") + targetchannel->ChanModes(targetchannel->HasUser(user))));
+ user->WriteNumeric(RPL_CHANNELCREATED, targetchannel->name, (unsigned long)targetchannel->age);
}
else
{
if (targetuser == user || user->HasPrivPermission("users/auspex"))
{
// Display user's current mode string
- user->WriteNumeric(RPL_UMODEIS, ":+%s", targetuser->FormatModes());
+ // XXX: Use WriteServ() because WriteNumeric() assumes the target (i.e. next word after the number)
+ // is 'user' and puts his nick there which is not what we want
+ user->WriteServ("%03d %s :+%s", RPL_UMODEIS, targetuser->nick.c_str(), targetuser->FormatModes());
if (targetuser->IsOper())
{
ModeHandler* snomask = ServerInstance->Modes->FindMode('s', MODETYPE_USER);
- user->WriteNumeric(RPL_SNOMASKIS, "%s :Server notice mask", snomask->GetUserParameter(user).c_str());
+ std::string snomaskstr = snomask->GetUserParameter(user);
+ // snomaskstr is empty if the snomask mode isn't set, otherwise it begins with a '+'.
+ // In the former case output a "+", not an empty string.
+ user->WriteServ("%03d %s %s%s :Server notice mask", RPL_SNOMASKIS, targetuser->nick.c_str(), (snomaskstr.empty() ? "+" : ""), snomaskstr.c_str());
}
}
else
{
- user->WriteNumeric(ERR_USERSDONTMATCH, ":Can't view modes for other users");
+ user->WriteNumeric(ERR_USERSDONTMATCH, "Can't view modes for other users");
}
}
}