summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-08-19 13:36:41 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-08-19 13:36:41 +0000
commit9f58ebc0b182aea1b951e383dd03b447b46ceb58 (patch)
tree97de4788e844e6cfa67d45d17fc0f6e2dfc0b25a
parent05c95857273e6c68ca05ee786948c455ac7d3d39 (diff)
Fix some /who oddities, fixes bug #383 amongst other issues. Nothing serious.
Ability to see users who share a common channel with you in /who *wildmask* now. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7746 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/cmd_who.cpp52
1 files changed, 37 insertions, 15 deletions
diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp
index b8f0684ff..6376d8dff 100644
--- a/src/cmd_who.cpp
+++ b/src/cmd_who.cpp
@@ -120,15 +120,17 @@ bool cmd_who::CanView(chanrec* chan, userrec* user)
if (!user || !chan)
return false;
- /* Execute items in fastest-to-execute first order */
-
+ /* Bug #383 - moved higher up the list, because if we are in the channel
+ * we can see all its users
+ */
+ if (chan->HasUser(user))
+ return true;
/* Opers see all */
if (IS_OPER(user))
return true;
+ /* Cant see inside a +s or a +p channel unless we are a member (see above) */
else if (!chan->IsModeSet('s') && !chan->IsModeSet('p'))
return true;
- else if (chan->HasUser(user))
- return true;
return false;
}
@@ -193,12 +195,22 @@ CmdResult cmd_who::Handle (const char** parameters, int pcnt, userrec *user)
std::string initial = "352 " + std::string(user->nick) + " ";
const char* matchtext = NULL;
+ bool usingwildcards = false;
/* Change '0' into '*' so the wildcard matcher can grok it */
matchtext = parameters[0];
if (!strcmp(matchtext,"0"))
matchtext = "*";
+ for (const char* check = matchtext; *check; check++)
+ {
+ if (*check == '*' || *check == '?')
+ {
+ usingwildcards = true;
+ break;
+ }
+ }
+
if (pcnt > 1)
{
/* parse flags */
@@ -264,13 +276,17 @@ CmdResult cmd_who::Handle (const char** parameters, int pcnt, userrec *user)
for (CUList::iterator i = cu->begin(); i != cu->end(); i++)
{
- /* opers only, please */
- if (opt_viewopersonly && !IS_OPER(i->first))
- continue;
+ /* None of this applies if we WHO ourselves */
+ if (user != i->first)
+ {
+ /* opers only, please */
+ if (opt_viewopersonly && !IS_OPER(i->first))
+ continue;
- /* If we're not inside the channel, hide +i users */
- if (i->first->IsModeSet('i') && !inside)
- continue;
+ /* If we're not inside the channel, hide +i users */
+ if (i->first->IsModeSet('i') && !inside)
+ continue;
+ }
SendWhoLine(user, initial, ch, i->first, whoresults);
}
@@ -279,7 +295,6 @@ CmdResult cmd_who::Handle (const char** parameters, int pcnt, userrec *user)
else
{
/* Match against wildcard of nick, server or host */
-
if (opt_viewopersonly)
{
/* Showing only opers */
@@ -289,8 +304,11 @@ CmdResult cmd_who::Handle (const char** parameters, int pcnt, userrec *user)
if (whomatch(oper, matchtext))
{
- if ((!oper->IsModeSet('i')) && (!IS_OPER(user)))
- continue;
+ if (!user->SharesChannelWith(oper))
+ {
+ if (usingwildcards && (!oper->IsModeSet('i')) && (!IS_OPER(user)))
+ continue;
+ }
SendWhoLine(user, initial, NULL, oper, whoresults);
}
@@ -302,8 +320,11 @@ CmdResult cmd_who::Handle (const char** parameters, int pcnt, userrec *user)
{
if (whomatch(i->second, matchtext))
{
- if ((i->second != user) && (i->second->IsModeSet('i')) && (!IS_OPER(user)))
- continue;
+ if (!user->SharesChannelWith(i->second))
+ {
+ if (usingwildcards && (i->second->IsModeSet('i')) && (!IS_OPER(user)))
+ continue;
+ }
SendWhoLine(user, initial, NULL, i->second, whoresults);
}
@@ -325,3 +346,4 @@ CmdResult cmd_who::Handle (const char** parameters, int pcnt, userrec *user)
return CMD_FAILURE;
}
}
+