]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_userhost.cpp
Add a helper function for calling the OnCheckExemption event.
[user/henk/code/inspircd.git] / src / coremods / core_userhost.cpp
index 1b34addb509b93dc36878b6d14d57e03fe476150..3100995a82b86c76ebc3e769bf34dda168a13eb6 100644 (file)
  */
 class CommandUserhost : public Command
 {
+       UserModeReference hideopermode;
+
  public:
        /** Constructor for userhost.
         */
-       CommandUserhost ( Module* parent) : Command(parent,"USERHOST", 1, 5) {
-               syntax = "<nick> {<nick>}";
+       CommandUserhost(Module* parent)
+               : Command(parent,"USERHOST", 1)
+               , hideopermode(parent, "hideoper")
+       {
+               syntax = "<nick> [<nick> ...]";
        }
        /** Handle command.
         * @param parameters The parameters to the command
@@ -42,9 +47,13 @@ CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, U
 {
        const bool has_privs = user->HasPrivPermission("users/auspex");
 
-       std::string retbuf = "302 " + user->nick + " :";
+       std::string retbuf;
+
+       unsigned int max = parameters.size();
+       if (max > 5)
+               max = 5;
 
-       for (unsigned int i = 0; i < parameters.size(); i++)
+       for (unsigned int i = 0; i < max; i++)
        {
                User *u = ServerInstance->FindNickOnly(parameters[i]);
 
@@ -53,7 +62,11 @@ CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, U
                        retbuf += u->nick;
 
                        if (u->IsOper())
-                               retbuf += '*';
+                       {
+                               // XXX: +H hidden opers must not be shown as opers
+                               if ((u == user) || (has_privs) || (!u->IsModeSet(hideopermode)))
+                                       retbuf += '*';
+                       }
 
                        retbuf += '=';
                        retbuf += (u->IsAway() ? '-' : '+');
@@ -64,7 +77,7 @@ CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, U
                }
        }
 
-       user->WriteServ(retbuf);
+       user->WriteNumeric(RPL_USERHOST, retbuf);
 
        return CMD_SUCCESS;
 }