From: Michael Poole Date: Mon, 5 Nov 2007 03:01:34 +0000 (+0000) Subject: Support /LIST M to show modes in channels (using the list_chan privilege). X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=c9187071b40a2a03bfc7a77eb18ff4ac4d2855d3 Support /LIST M to show modes in channels (using the list_chan privilege). git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1841 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index 91d249b..fe5b3cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-11-04 Michael Poole + + * 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 * ircd/m_list.c (param_parse): Reverse comparison direction when diff --git a/doc/example.conf b/doc/example.conf index 7c1b80a..8ffe137 100644 --- a/doc/example.conf +++ b/doc/example.conf @@ -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) diff --git a/include/channel.h b/include/channel.h index 4f2c1c0..dc083ea 100644 --- a/include/channel.h +++ b/include/channel.h @@ -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 diff --git a/ircd/hash.c b/ircd/hash.c index eb483d2..aa264dd 100644 --- a/ircd/hash.c +++ b/ircd/hash.c @@ -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 diff --git a/ircd/m_list.c b/ircd/m_list.c index e634caa..b43ab15 100644 --- a/ircd/m_list.c +++ b/ircd/m_list.c @@ -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, '*') ||