X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcommands%2Fcmd_who.cpp;h=90c26a974d4b8c3676fe5b23f673b6753b5f8acf;hb=748b3a0d89e7ecc9a766471b79fb78f63a5ca2bb;hp=8afb3d6e7449c0f42ae2d2de483999c025311804;hpb=23e62cef071f8d037b2d163d60bcc85f5887776c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index 8afb3d6e7..90c26a974 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -1,16 +1,23 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2009-2010 Daniel De Graaf + * Copyright (C) 2007-2008 Robin Burchell * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #include "inspircd.h" /** Handle /WHO. These command handlers can be reloaded by the core, @@ -51,19 +58,16 @@ class CommandWho : public Command }; -static const std::string star = "*"; - -static const std::string& get_first_visible_channel(User *u) +static Channel* get_first_visible_channel(User *u) { UCListIter i = u->chans.begin(); while (i != u->chans.end()) { Channel* c = *i++; if (!c->IsModeSet('s')) - return c->name; + return c; } - - return star; + return NULL; } bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext) @@ -137,7 +141,7 @@ bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext) long seconds = ServerInstance->Duration(matchtext); // Okay, so time matching, we want all users connected `seconds' ago - if (user->age >= ServerInstance->Time() - seconds) + if (user->signon >= ServerInstance->Time() - seconds) match = true; } @@ -162,8 +166,6 @@ bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext) } } - - bool CommandWho::CanView(Channel* chan, User* user) { if (!user || !chan) @@ -186,9 +188,10 @@ bool CommandWho::CanView(Channel* chan, User* user) void CommandWho::SendWhoLine(User* user, const std::vector& parms, const std::string &initial, Channel* ch, User* u, std::vector &whoresults) { - const std::string& lcn = get_first_visible_channel(u); + if (!ch) + ch = get_first_visible_channel(u); - std::string wholine = initial + (ch ? ch->name : lcn) + " " + u->ident + " " + + std::string wholine = initial + (ch ? ch->name : "*") + " " + u->ident + " " + (opt_showrealhost ? u->host : u->dhost) + " "; if (!ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex")) wholine.append(ServerInstance->Config->HideWhoisServer); @@ -215,16 +218,10 @@ void CommandWho::SendWhoLine(User* user, const std::vector& parms, if (ch) wholine.append(ch->GetPrefixChar(u)); - else - { - Channel* lch = ServerInstance->FindChan(lcn); - if (lch) - wholine.append(lch->GetPrefixChar(u)); - } wholine.append(" :0 " + u->fullname); - FOREACH_MOD(I_OnSendWhoLine, OnSendWhoLine(user, parms, u, ch, wholine)); + FOREACH_MOD(I_OnSendWhoLine, OnSendWhoLine(user, parms, u, wholine)); if (!wholine.empty()) whoresults.push_back(wholine); @@ -254,7 +251,7 @@ CmdResult CommandWho::Handle (const std::vector& parameters, User * Channel *ch = NULL; std::vector whoresults; - std::string initial = "352 " + std::string(user->nick) + " "; + std::string initial = "352 " + user->nick + " "; char matchtext[MAXBUF]; bool usingwildcards = false; @@ -267,7 +264,7 @@ CmdResult CommandWho::Handle (const std::vector& parameters, User * for (const char* check = matchtext; *check; check++) { - if (*check == '*' || *check == '?') + if (*check == '*' || *check == '?' || *check == '.') { usingwildcards = true; break; @@ -371,7 +368,7 @@ CmdResult CommandWho::Handle (const std::vector& parameters, User * { if (!user->SharesChannelWith(oper)) { - if (usingwildcards && (!oper->IsModeSet('i')) && (!user->HasPrivPermission("users/auspex"))) + if (usingwildcards && (oper->IsModeSet('i')) && (!user->HasPrivPermission("users/auspex"))) continue; }