X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_user%2Fcmd_mode.cpp;h=b1790bb89eb77d133b5cce795bf1c233fbcdfa5d;hb=da29af8cba49d51e53d6e68237ccbf6370b6dd1f;hp=99b9ab20d56f05dc0fcdd3e93ac5cee0c0b96d9e;hpb=3eda212c2ad561fae6a7d8cf20280da9d37a90f4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_user/cmd_mode.cpp b/src/coremods/core_user/cmd_mode.cpp index 99b9ab20d..b1790bb89 100644 --- a/src/coremods/core_user/cmd_mode.cpp +++ b/src/coremods/core_user/cmd_mode.cpp @@ -43,9 +43,9 @@ CmdResult CommandMode::Handle(const std::vector& parameters, User* 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) @@ -70,7 +70,7 @@ CmdResult CommandMode::Handle(const std::vector& parameters, User* 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; } @@ -84,7 +84,10 @@ CmdResult CommandMode::Handle(const std::vector& parameters, User* 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)) { @@ -132,24 +135,29 @@ void CommandMode::DisplayCurrentModes(User* user, User* targetuser, Channel* tar 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"); } } }