]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/commands/cmd_whois.cpp
Remove virtual User::GetClass() (but keep LocalUser::GetClass())
[user/henk/code/inspircd.git] / src / commands / cmd_whois.cpp
index de3d71152bd2cda7ce2cf70cf776975325e71746..0df6b65f0e8cde5dd8db2393c93f5c6c5b0ae80d 100644 (file)
  */
 class CommandWhois : public SplitCommand
 {
+       ChanModeReference secretmode;
+       ChanModeReference privatemode;
+       UserModeReference snomaskmode;
+
        void SplitChanList(User* source, User* dest, const std::string& cl);
        void DoWhois(User* user, User* dest, unsigned long signon, unsigned long idle);
        std::string ChannelList(User* source, User* dest, bool spy);
@@ -35,7 +39,16 @@ class CommandWhois : public SplitCommand
  public:
        /** Constructor for whois.
         */
-       CommandWhois ( Module* parent) : SplitCommand(parent,"WHOIS", 1) { Penalty = 2; syntax = "<nick>{,<nick>}"; }
+       CommandWhois(Module* parent)
+               : SplitCommand(parent, "WHOIS", 1)
+               , secretmode(parent, "secret")
+               , privatemode(parent, "private")
+               , snomaskmode(parent, "snomask")
+       {
+               Penalty = 2;
+               syntax = "<nick>{,<nick>}";
+       }
+
        /** Handle command.
         * @param parameters The parameters to the comamnd
         * @param pcnt The number of parameters passed to teh command
@@ -56,7 +69,7 @@ std::string CommandWhois::ChannelList(User* source, User* dest, bool spy)
                /* If the target is the sender, neither +p nor +s is set, or
                 * the channel contains the user, it is not a spy channel
                 */
-               if (spy != (source == dest || !(c->IsModeSet('p') || c->IsModeSet('s')) || c->HasUser(source)))
+               if (spy != (source == dest || !(c->IsModeSet(privatemode) || c->IsModeSet(secretmode)) || c->HasUser(source)))
                        list.append(c->GetPrefixChar(dest)).append(c->name).append(" ");
        }
 
@@ -150,9 +163,9 @@ void CommandWhois::DoWhois(User* user, User* dest, unsigned long signon, unsigne
 
        if (user == dest || user->HasPrivPermission("users/auspex"))
        {
-               if (dest->IsModeSet('s') != 0)
+               if (dest->IsModeSet(snomaskmode))
                {
-                       ServerInstance->SendWhoisLine(user, dest, 379, "%s %s :is using modes +%s +%s", user->nick.c_str(), dest->nick.c_str(), dest->FormatModes(), dest->FormatNoticeMasks().c_str());
+                       ServerInstance->SendWhoisLine(user, dest, 379, "%s %s :is using modes +%s %s", user->nick.c_str(), dest->nick.c_str(), dest->FormatModes(), snomaskmode->GetUserParameter(dest).c_str());
                }
                else
                {
@@ -160,7 +173,7 @@ void CommandWhois::DoWhois(User* user, User* dest, unsigned long signon, unsigne
                }
        }
 
-       FOREACH_MOD(I_OnWhois,OnWhois(user,dest));
+       FOREACH_MOD(OnWhois, (user,dest));
 
        /*
         * We only send these if we've been provided them. That is, if hidewhois is turned off, and user is local, or
@@ -183,7 +196,7 @@ CmdResult CommandWhois::HandleRemote(const std::vector<std::string>& parameters,
        if (!user)
                return CMD_FAILURE;
 
-       unsigned long idle = ConvToInt(parameters[1]);
+       unsigned long idle = ConvToInt(parameters.back());
        DoWhois(user, target, target->signon, idle);
 
        return CMD_SUCCESS;
@@ -195,7 +208,7 @@ CmdResult CommandWhois::HandleLocal(const std::vector<std::string>& parameters,
        int userindex = 0;
        unsigned long idle = 0, signon = 0;
 
-       if (ServerInstance->Parser->LoopCall(user, this, parameters, 0))
+       if (CommandParser::LoopCall(user, this, parameters, 0))
                return CMD_SUCCESS;
 
        /*