Support /LIST M to show modes in channels (using the list_chan privilege).
authorMichael Poole <mdpoole@troilus.org>
Mon, 5 Nov 2007 03:01:34 +0000 (03:01 +0000)
committerMichael Poole <mdpoole@troilus.org>
Mon, 5 Nov 2007 03:01:34 +0000 (03:01 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1841 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
doc/example.conf
include/channel.h
ircd/hash.c
ircd/m_list.c

index 91d249bf5b689fb2128fb3f86598be51383ed4a7..fe5b3cba50626b2712618c759089675d10d7ec34 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-11-04  Michael Poole <mdpoole@troilus.org>
+
+       * doc/example.conf: Document /LIST M as controlled by list_chan.
+
+       * include/channel.h (LISTARG_SHOWMODES): Define.
+
+       * ircd/hash.c (list_next_channels): Handle it.
+
+       * ircd/m_list.c (show_usage): Document 'M' flag.
+       (param_parse): Recognize 'M' as LISTARGS_SHOWMODES.
+
 2007-11-04  Michael Poole <mdpoole@troilus.org>
 
        * ircd/m_list.c (param_parse): Reverse comparison direction when
index 7c1b80aba080c1c41370ca6bee88107d17c33cf1..8ffe13704979b164234398c6f07a4b593fb7d0d3 100644 (file)
@@ -216,7 +216,7 @@ Class {
  # local_gline (can set a G-line for this server only)
  # local_badchan (can set a Gchan for this server only)
  # see_chan (can see users in +s channels in /WHO)
- # list_chan (can see +s channels with /LIST S)
+ # list_chan (can see +s channels with /LIST S, or modes with /LIST M)
  # wide_gline (can use ! to force a wide G-line)
  # see_opers (can see opers without DISPLAY privilege)
  # local_opmode (can use OPMODE/CLEARMODE on local channels)
index 4f2c1c0bbc40079bea035a34b42c3ff9c104bc5c..dc083eacae509843d9303577538620644627623d 100644 (file)
@@ -149,6 +149,7 @@ typedef enum ChannelGetType {
 #define LISTARG_TOPICLIMITS     0x0001
 #define LISTARG_SHOWSECRET      0x0002
 #define LISTARG_NEGATEWILDCARD  0x0004
+#define LISTARG_SHOWMODES       0x0008
 
 /**
  * Maximum acceptable lag time in seconds: A channel younger than
index eb483d27ac5071303f0ba000a3cf758a33a68545..aa264ddb158500431bc94d4830e4d9b00e48a4bc 100644 (file)
@@ -452,7 +452,17 @@ void list_next_channels(struct Client *cptr)
           && ((args->flags & LISTARG_SHOWSECRET)
               || ShowChannel(cptr, chptr)))
       {
-        send_reply(cptr, RPL_LIST, chptr->chname, chptr->users, chptr->topic);
+        if (args->flags & LISTARG_SHOWMODES) {
+          char modebuf[MODEBUFLEN];
+          char parabuf[MODEBUFLEN];
+
+          modebuf[0] = modebuf[1] = parabuf[0] = '\0';
+          channel_modes(cptr, modebuf, parabuf, sizeof(parabuf), chptr, NULL);
+          send_reply(cptr, RPL_LIST | SND_EXPLICIT, "%s %u %s %s :%s",
+                     chptr->chname, chptr->users, modebuf, parabuf, chptr->topic);
+        } else {
+          send_reply(cptr, RPL_LIST, chptr->chname, chptr->users, chptr->topic);
+        }
       }
     }
     /* If, at the end of the bucket, client sendq is more than half
index e634caa9ba2edccadb9cbf31aa536aee575559e7..b43ab1575762b3330d2886a6327169d43a8d9cec 100644 (file)
@@ -168,9 +168,12 @@ show_usage(struct Client *sptr)
              "matching \037pattern\037. ");
   send_reply(sptr, RPL_LISTUSAGE, "Note: Patterns may contain * and ?. "
              "You may only give one pattern match constraint.");
-  if (IsAnOper(sptr))
+  if (IsAnOper(sptr)) {
     send_reply(sptr, RPL_LISTUSAGE,
                " \002S\002             ; Show secret channels.");
+    send_reply(sptr, RPL_LISTUSAGE,
+               " \002M\002             ; Show channel modes.");
+  }
   send_reply(sptr, RPL_LISTUSAGE,
             "Example: LIST <3,>1,C<10,T>0,#a*  ; 2 users, younger than 10 "
             "min., topic set., starts with #a");
@@ -262,6 +265,18 @@ param_parse(struct Client *sptr, const char *param, struct ListingArgs *args,
         return show_usage(sptr);
       break;
 
+    case 'M':
+    case 'm':
+      if (!IsAnOper(sptr) || !HasPriv(sptr, PRIV_LIST_CHAN))
+        return show_usage(sptr);
+
+      args->flags |= LISTARG_SHOWMODES;
+      param++;
+
+      if (*param != ',' && *param != ' ' && *param != '\0') /* check syntax */
+        return show_usage(sptr);
+      break;
+
     default:
       /* It might be a wildcard... */
       if (strchr(param, '*') ||