- /* Send the results out */
- for (std::vector<std::string>::const_iterator n = whoresults.begin(); n != whoresults.end(); n++)
- user->WriteServ(*n);
- user->WriteNumeric(RPL_ENDOFWHO, "%s :End of /WHO list.", *parameters[0].c_str() ? parameters[0].c_str() : "*");
-
- // Penalize the user a bit for large queries
- // (add one unit of penalty per 200 results)
- if (IS_LOCAL(user))
- IS_LOCAL(user)->CommandFloodPenalty += whoresults.size() * 5;
+
+ ModResult res;
+ FIRST_MOD_RESULT_CUSTOM(whoevprov, Who::EventListener, OnWhoLine, res, (data, source, user, memb, wholine));
+ if (res != MOD_RES_DENY)
+ data.results.push_back(wholine);
+}
+
+CmdResult CommandWho::HandleLocal(LocalUser* user, const Params& parameters)
+{
+ WhoData data(parameters);
+
+ // Is the source running a WHO on a channel?
+ Channel* chan = ServerInstance->FindChan(data.matchtext);
+ if (chan)
+ WhoChannel(user, parameters, chan, data);
+
+ // If we only want to match against opers we only have to iterate the oper list.
+ else if (data.flags['o'])
+ WhoUsers(user, parameters, ServerInstance->Users->all_opers, data);
+
+ // Otherwise we have to use the global user list.
+ else
+ WhoUsers(user, parameters, ServerInstance->Users->GetUsers(), data);
+
+ // Send the results to the source.
+ for (std::vector<Numeric::Numeric>::const_iterator n = data.results.begin(); n != data.results.end(); ++n)
+ user->WriteNumeric(*n);
+ user->WriteNumeric(RPL_ENDOFWHO, (data.matchtext.empty() ? "*" : data.matchtext.c_str()), "End of /WHO list.");
+
+ // Penalize the source a bit for large queries with one unit of penalty per 200 results.
+ user->CommandFloodPenalty += data.results.size() * 5;