summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-02-01 01:31:40 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-02-01 01:31:40 +0000
commit23e62cef071f8d037b2d163d60bcc85f5887776c (patch)
treebb5b7ebc71ca4d8609b13420162d59a7866e15ca
parente336f4047eacfd09d4c57d61b348c9178d4573af (diff)
Add parameters to OnSendWhoLine hook, fixes "/who * o" returning opers with +H
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12345 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/modules.h3
-rw-r--r--src/commands/cmd_who.cpp37
-rw-r--r--src/modules.cpp2
-rw-r--r--src/modules/m_hideoper.cpp5
-rw-r--r--src/modules/m_invisible.cpp4
5 files changed, 34 insertions, 17 deletions
diff --git a/include/modules.h b/include/modules.h
index 6ec1a8ad4..bb9a55dbf 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -1270,11 +1270,12 @@ class CoreExport Module : public classbase, public usecountbase
/** Called whenever a result from /WHO is about to be returned
* @param source The user running the /WHO query
+ * @param params The parameters to the /WHO query
* @param user The user that this line of the query is about
* @param channel The channel being queried (or NULL if not a channel query)
* @param line The raw line to send; modifiable, if empty no line will be returned.
*/
- virtual void OnSendWhoLine(User* source, User* user, Channel* channel, std::string& line);
+ virtual void OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Channel* channel, std::string& line);
/** Called to check whether a channel restriction mode applies to a user on it
* @return MOD_RES_DENY to apply the restriction, MOD_RES_ALLOW to bypass
diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp
index 6aac6eeea..8afb3d6e7 100644
--- a/src/commands/cmd_who.cpp
+++ b/src/commands/cmd_who.cpp
@@ -39,7 +39,7 @@ class CommandWho : public Command
CommandWho ( Module* parent) : Command(parent,"WHO", 1) {
syntax = "<server>|<nickname>|<channel>|<realname>|<host>|0 [ohurmMiaplf]";
}
- void SendWhoLine(User* user, const std::string &initial, Channel* ch, User* u, std::vector<std::string> &whoresults);
+ void SendWhoLine(User* user, const std::vector<std::string>& parms, const std::string &initial, Channel* ch, User* u, std::vector<std::string> &whoresults);
/** Handle command.
* @param parameters The parameters to the comamnd
* @param pcnt The number of parameters passed to teh command
@@ -184,14 +184,18 @@ bool CommandWho::CanView(Channel* chan, User* user)
return false;
}
-void CommandWho::SendWhoLine(User* user, const std::string &initial, Channel* ch, User* u, std::vector<std::string> &whoresults)
+void CommandWho::SendWhoLine(User* user, const std::vector<std::string>& parms, const std::string &initial, Channel* ch, User* u, std::vector<std::string> &whoresults)
{
const std::string& lcn = get_first_visible_channel(u);
- Channel* chlast = ServerInstance->FindChan(lcn);
- std::string wholine = initial + (ch ? ch->name : lcn) + " " + u->ident + " " + (opt_showrealhost ? u->host : u->dhost) + " " +
- ((!ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex")) ? ServerInstance->Config->HideWhoisServer : u->server) +
- " " + u->nick + " ";
+ std::string wholine = initial + (ch ? ch->name : lcn) + " " + u->ident + " " +
+ (opt_showrealhost ? u->host : u->dhost) + " ";
+ if (!ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex"))
+ wholine.append(ServerInstance->Config->HideWhoisServer);
+ else
+ wholine.append(u->server);
+
+ wholine.append(" " + u->nick + " ");
/* away? */
if (IS_AWAY(u))
@@ -206,12 +210,21 @@ void CommandWho::SendWhoLine(User* user, const std::string &initial, Channel* ch
/* oper? */
if (IS_OPER(u))
{
- wholine.append("*");
+ wholine.push_back('*');
+ }
+
+ if (ch)
+ wholine.append(ch->GetPrefixChar(u));
+ else
+ {
+ Channel* lch = ServerInstance->FindChan(lcn);
+ if (lch)
+ wholine.append(lch->GetPrefixChar(u));
}
- wholine = wholine + (ch ? ch->GetPrefixChar(u) : (chlast ? chlast->GetPrefixChar(u) : "")) + " :0 " + u->fullname;
+ wholine.append(" :0 " + u->fullname);
- FOREACH_MOD(I_OnSendWhoLine, OnSendWhoLine(user, u, ch, wholine));
+ FOREACH_MOD(I_OnSendWhoLine, OnSendWhoLine(user, parms, u, ch, wholine));
if (!wholine.empty())
whoresults.push_back(wholine);
@@ -340,7 +353,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
continue;
}
- SendWhoLine(user, initial, ch, i->first, whoresults);
+ SendWhoLine(user, parameters, initial, ch, i->first, whoresults);
}
}
}
@@ -362,7 +375,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
continue;
}
- SendWhoLine(user, initial, NULL, oper, whoresults);
+ SendWhoLine(user, parameters, initial, NULL, oper, whoresults);
}
}
}
@@ -378,7 +391,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
continue;
}
- SendWhoLine(user, initial, NULL, i->second, whoresults);
+ SendWhoLine(user, parameters, initial, NULL, i->second, whoresults);
}
}
}
diff --git a/src/modules.cpp b/src/modules.cpp
index 58c27e490..9186e38be 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -161,7 +161,7 @@ void Module::OnNamesListItem(User*, Membership*, std::string&, std::string&) {
ModResult Module::OnNumeric(User*, unsigned int, const std::string&) { return MOD_RES_PASSTHRU; }
void Module::OnHookIO(StreamSocket*, ListenSocket*) { }
ModResult Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { return MOD_RES_PASSTHRU; }
-void Module::OnSendWhoLine(User*, User*, Channel*, std::string&) { }
+void Module::OnSendWhoLine(User*, const std::vector<std::string>&, User*, Channel*, std::string&) { }
ModResult Module::OnChannelRestrictionApply(User*, Channel*, const char*) { return MOD_RES_PASSTHRU; }
ModuleManager::ModuleManager() : ModCount(0)
diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp
index 18db0320c..360dae014 100644
--- a/src/modules/m_hideoper.cpp
+++ b/src/modules/m_hideoper.cpp
@@ -88,7 +88,7 @@ class ModuleHideOper : public Module
return MOD_RES_PASSTHRU;
}
- void OnSendWhoLine(User* source, User* user, Channel* channel, std::string& line)
+ void OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Channel* channel, std::string& line)
{
if (user->IsModeSet('H') && !source->HasPrivPermission("users/auspex"))
{
@@ -96,6 +96,9 @@ class ModuleHideOper : public Module
std::string::size_type pos = line.find("* ");
if (pos != std::string::npos)
line.erase(pos);
+ // hide the line completely if doing a "/who * o" query
+ if (params.size() > 1 && params[1].find('o') != std::string::npos)
+ line.clear();
}
}
};
diff --git a/src/modules/m_invisible.cpp b/src/modules/m_invisible.cpp
index abedaf0ce..602a45b49 100644
--- a/src/modules/m_invisible.cpp
+++ b/src/modules/m_invisible.cpp
@@ -133,7 +133,7 @@ class ModuleInvisible : public Module
void OnBuildNeighborList(User* source, UserChanList &include, std::map<User*,bool> &exceptions);
ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list);
ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list);
- void OnSendWhoLine(User* source, User* user, Channel* channel, std::string& line);
+ void OnSendWhoLine(User* source, const std::vector<std::string>&, User* user, Channel* channel, std::string& line);
void OnNamesListItem(User* issuer, Membership* memb, std::string &prefixes, std::string &nick);
};
@@ -191,7 +191,7 @@ ModResult ModuleInvisible::OnUserPreMessage(User* user,void* dest,int target_typ
return OnUserPreNotice(user, dest, target_type, text, status, exempt_list);
}
-void ModuleInvisible::OnSendWhoLine(User* source, User* user, Channel* channel, std::string& line)
+void ModuleInvisible::OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Channel* channel, std::string& line)
{
if (user->IsModeSet('Q') && !IS_OPER(source))
line.clear();