X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_who.cpp;h=132f8bc1e29d5d2af8396ab3310a3b0a7c3d011c;hb=be91435ccb8e05c84ecd126b5c41b74c45f4535b;hp=8bba1f8604c0146b78bf4f1c790b0e2ba5cf44bb;hpb=384ef31bc01e4a1a2e59d082c9066002410ba54a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_who.cpp b/src/coremods/core_who.cpp index 8bba1f860..132f8bc1e 100644 --- a/src/coremods/core_who.cpp +++ b/src/coremods/core_who.cpp @@ -22,6 +22,7 @@ #include "inspircd.h" #include "modules/account.h" +#include "modules/who.h" enum { @@ -33,31 +34,9 @@ enum RPL_WHOSPCRPL = 354 }; -struct WhoData +struct WhoData : public Who::Request { - // The flags for matching users to include. - std::bitset flags; - - // Whether we are matching using a wildcard or a flag. - bool fuzzy_match; - - // The text to match against. - std::string matchtext; - - // The WHO/WHOX responses we will send to the source. - std::vector results; - - // Whether the source requested a WHOX response. - bool whox; - - // The fields to include in the WHOX response. - std::bitset whox_fields; - - // A user specified label for the WHOX response. - std::string whox_querytype; - WhoData(const CommandBase::Params& parameters) - : whox(false) { // Find the matchtext and swap the 0 for a * so we can use InspIRCd::Match on it. matchtext = parameters.size() > 2 ? parameters[2] : parameters[0]; @@ -105,6 +84,7 @@ class CommandWho : public SplitCommand ChanModeReference privatemode; UserModeReference hidechansmode; UserModeReference invisiblemode; + Events::ModuleEventProvider whoevprov; /** Determines whether a user can view the users of a channel. */ bool CanView(Channel* chan, User* user) @@ -137,7 +117,7 @@ class CommandWho : public SplitCommand } /** Determines whether WHO flags match a specific channel user. */ - static bool MatchChannel(LocalUser* source, Membership* memb, WhoData& data); + bool MatchChannel(LocalUser* source, Membership* memb, WhoData& data); /** Determines whether WHO flags match a specific user. */ static bool MatchUser(LocalUser* source, User* target, WhoData& data); @@ -160,9 +140,10 @@ class CommandWho : public SplitCommand , privatemode(parent, "private") , hidechansmode(parent, "hidechans") , invisiblemode(parent, "invisible") + , whoevprov(parent, "event/who") { allow_empty_last_param = false; - syntax = "|||||0 [[Aafhilmnoprstu] |||||0]"; + syntax = "|||||0 [[Aafhilmnoprstux][%acdfhilnorstu] |||||0]"; } /** Sends a WHO reply to a user. */ @@ -304,7 +285,7 @@ bool CommandWho::MatchUser(LocalUser* source, User* user, WhoData& data) // The source wants to match against users' real names. else if (data.flags['r']) - match = InspIRCd::Match(user->fullname, data.matchtext, ascii_case_insensitive_map); + match = InspIRCd::Match(user->GetRealName(), data.matchtext, ascii_case_insensitive_map); else if (data.flags['s']) { @@ -340,7 +321,7 @@ bool CommandWho::MatchUser(LocalUser* source, User* user, WhoData& data) } if (!match) - match = InspIRCd::Match(user->fullname, data.matchtext, ascii_case_insensitive_map); + match = InspIRCd::Match(user->GetRealName(), data.matchtext, ascii_case_insensitive_map); if (!match) match = InspIRCd::Match(user->nick, data.matchtext); @@ -484,7 +465,7 @@ void CommandWho::SendWhoLine(LocalUser* source, const std::vector& // Include the user's real name. if (data.whox_fields['r']) - wholine.push(user->fullname); + wholine.push(user->GetRealName()); } else { @@ -530,11 +511,11 @@ void CommandWho::SendWhoLine(LocalUser* source, const std::vector& // Include the number of hops between the users and the user's real name. wholine.push("0 "); - wholine.GetParams().back().append(user->fullname); + wholine.GetParams().back().append(user->GetRealName()); } ModResult res; - FIRST_MOD_RESULT(OnSendWhoLine, res, (source, parameters, user, memb, wholine)); + FIRST_MOD_RESULT_CUSTOM(whoevprov, Who::EventListener, OnWhoLine, res, (data, source, user, memb, wholine)); if (res != MOD_RES_DENY) data.results.push_back(wholine); }