]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/commands/cmd_userhost.cpp
Merge pull request #1018 from SaberUK/insp20+hidekills
[user/henk/code/inspircd.git] / src / commands / cmd_userhost.cpp
index 726c063b334f80d2f38d6ef10ac427090ab11968..7e1efd6375de04c8c041c588f32580e03c91f6ee 100644 (file)
@@ -30,7 +30,9 @@ class CommandUserhost : public Command
  public:
        /** Constructor for userhost.
         */
-       CommandUserhost ( Module* parent) : Command(parent,"USERHOST",0,1) { syntax = "<nick>{,<nick>}"; }
+       CommandUserhost ( Module* parent) : Command(parent,"USERHOST", 1) {
+               syntax = "<nick> [<nick> ...]";
+       }
        /** Handle command.
         * @param parameters The parameters to the comamnd
         * @param pcnt The number of parameters passed to teh command
@@ -42,9 +44,14 @@ class CommandUserhost : public Command
 
 CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, User *user)
 {
-       std::string retbuf = std::string("302 ") + user->nick + " :";
+       std::string retbuf = "302 " + user->nick + " :";
+
+       unsigned int max = parameters.size();
+       if (max > 5)
+               max = 5;
 
-       for (unsigned int i = 0; i < parameters.size(); i++)
+       bool has_privs = user->HasPrivPermission("users/auspex");
+       for (unsigned int i = 0; i < max; i++)
        {
                User *u = ServerInstance->FindNickOnly(parameters[i]);
 
@@ -54,13 +61,14 @@ CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, U
 
                        if (IS_OPER(u))
                        {
-                               retbuf = retbuf + "*=";
-                       }
-                       else
-                       {
-                               retbuf = retbuf + "=";
+                               // XXX: +H hidden opers must not be shown as opers
+                               ModeHandler* mh = ServerInstance->Modes->FindMode('H', MODETYPE_USER);
+                               if ((u == user) || (has_privs) || (!mh) || (!u->IsModeSet('H')) || (mh->name != "hideoper"))
+                                       retbuf += '*';
                        }
 
+                       retbuf = retbuf + "=";
+
                        if (IS_AWAY(u))
                                retbuf += "-";
                        else
@@ -68,7 +76,7 @@ CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, U
 
                        retbuf = retbuf + u->ident + "@";
 
-                       if (user->HasPrivPermission("users/auspex"))
+                       if (has_privs)
                        {
                                retbuf = retbuf + u->host;
                        }