summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2016-12-30 19:05:00 +0100
committerAttila Molnar <attilamolnar@hush.com>2016-12-30 19:05:00 +0100
commit2b9f083cb18e77495c152cb4a2a3096f907f6c6e (patch)
tree8e46bdfde429480140698555e473fe1ef9a9fd7e /src
parent0c061aff64625799160dadfb09ade008a38eb6c5 (diff)
cmd_mode Switch to a numeric for showing modes of other users
Diffstat (limited to 'src')
-rw-r--r--src/coremods/core_user/cmd_mode.cpp33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/coremods/core_user/cmd_mode.cpp b/src/coremods/core_user/cmd_mode.cpp
index 65ab96112..2b2652606 100644
--- a/src/coremods/core_user/cmd_mode.cpp
+++ b/src/coremods/core_user/cmd_mode.cpp
@@ -130,6 +130,17 @@ void CommandMode::DisplayListModes(User* user, Channel* chan, const std::string&
}
}
+static std::string GetSnomasks(const User* user)
+{
+ ModeHandler* const snomask = ServerInstance->Modes.FindMode('s', MODETYPE_USER);
+ 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.
+ if (snomaskstr.empty())
+ snomaskstr.push_back('+');
+ return snomaskstr;
+}
+
void CommandMode::DisplayCurrentModes(User* user, User* targetuser, Channel* targetchannel)
{
if (targetchannel)
@@ -140,20 +151,20 @@ void CommandMode::DisplayCurrentModes(User* user, User* targetuser, Channel* tar
}
else
{
- if (targetuser == user || user->HasPrivPermission("users/auspex"))
+ if (targetuser == user)
{
// Display user's current mode string
- // 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->GetModeLetters().c_str());
+ user->WriteNumeric(RPL_UMODEIS, targetuser->GetModeLetters());
if (targetuser->IsOper())
- {
- ModeHandler* snomask = ServerInstance->Modes->FindMode('s', MODETYPE_USER);
- 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());
- }
+ user->WriteNumeric(RPL_SNOMASKIS, GetSnomasks(targetuser), "Server notice mask");
+ }
+ else if (user->HasPrivPermission("users/auspex"))
+ {
+ // Querying the modes of another user.
+ // We cannot use RPL_UMODEIS because that's only for showing the user's own modes.
+ user->WriteNumeric(RPL_OTHERUMODEIS, targetuser->nick, targetuser->GetModeLetters());
+ if (targetuser->IsOper())
+ user->WriteNumeric(RPL_OTHERSNOMASKIS, targetuser->nick, GetSnomasks(targetuser), "Server notice mask");
}
else
{