-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

        The following is a patch to add a WALLVOICES command, which seemed to be a 
popular request from our little expedition into asking users what commands 
they wanted.

        The WALLVOICES command will appear the same as a WALLCHOPS command from the 
client side, in that both are dispatched as a NOTICE @#channel :blah.  This 
was to get round the problem that +#channel would have been a valid channel 
name on Undernet until recently and I believe still is on IRCNet (both 
modeless channels).  The only difference is on the server side where 
WALLCHOPS is obviously only sent to channel OPs, but WALLVOICES is also sent 
to channel voices.

Index: ChangeLog
===================================================================
RCS file: /cvsroot/undernet-ircu/ircu2.10/ChangeLog,v
retrieving revision 1.290.2.125
diff -u -r1.290.2.125 ChangeLog
- --- ChangeLog 10 Oct 2002 09:13:23 -0000      1.290.2.125
+++ ChangeLog   24 Nov 2002 14:50:17 -0000
@@ -1,3 +1,21 @@
+2002-11-18 hikari <[EMAIL PROTECTED]>
+
+       * ircd/Makefile.in: fluff to link ircd/m_wallvoices.c
+
+       * ircd/parse.c: addition of wallvoices parsers
+
+       * ircd/send.c: addition of a check for SKIP_NONVOICES which checks
+       for !IsChanOp() && !HasVoice()
+
+       * ircd/m_wallvoices.c: new m_wallvoices() and ms_wallvoices()
+       functions
+
+       * include/send.h: addition of defintion for SKIP_NONVOICES
+
+       * include/msg.h: command defines
+
+       * include/handlers.h: function declarations
+
 2002-10-10  Perry Lorier <[EMAIL PROTECTED]>
 
        * include/patchlevel.h (PATCHLEVEL): release u2.10.11.02
Index: include/handlers.h
===================================================================
RCS file: /cvsroot/undernet-ircu/ircu2.10/include/handlers.h,v
retrieving revision 1.12.2.5
diff -u -r1.12.2.5 handlers.h
- --- include/handlers.h        7 Jun 2002 15:56:36 -0000       1.12.2.5
+++ include/handlers.h  24 Nov 2002 14:50:51 -0000
@@ -132,6 +132,7 @@
 extern int m_userip(struct Client*, struct Client*, int, char*[]);
 extern int m_version(struct Client*, struct Client*, int, char*[]);
 extern int m_wallchops(struct Client*, struct Client*, int, char*[]);
+extern int m_wallvoices(struct Client*, struct Client*, int, char*[]);
 extern int m_who(struct Client*, struct Client*, int, char*[]);
 extern int m_whois(struct Client*, struct Client*, int, char*[]);
 extern int m_whowas(struct Client*, struct Client*, int, char*[]);
@@ -215,6 +216,7 @@
 extern int ms_uping(struct Client*, struct Client*, int, char*[]);
 extern int ms_version(struct Client*, struct Client*, int, char*[]);
 extern int ms_wallchops(struct Client*, struct Client*, int, char*[]);
+extern int ms_wallvoices(struct Client*, struct Client*, int, char*[]);
 extern int ms_wallops(struct Client*, struct Client*, int, char*[]);
 extern int ms_wallusers(struct Client*, struct Client*, int, char*[]);
 extern int ms_whois(struct Client*, struct Client*, int, char*[]);
Index: include/msg.h
===================================================================
RCS file: /cvsroot/undernet-ircu/ircu2.10/include/msg.h,v
retrieving revision 1.11.2.2
diff -u -r1.11.2.2 msg.h
- --- include/msg.h     7 Jun 2002 15:56:36 -0000       1.11.2.2
+++ include/msg.h       24 Nov 2002 14:50:54 -0000
@@ -198,6 +198,10 @@
 #define TOK_WALLCHOPS           "WC"
 #define CMD_WALLCHOPS          MSG_WALLCHOPS, TOK_WALLCHOPS
 
+#define MSG_WALLVOICES           "WALLVOICES"     /* WV */
+#define TOK_WALLVOICES           "WV"
+#define CMD_WALLVOICES           MSG_WALLVOICES, TOK_WALLVOICES
+
 #define MSG_CPRIVMSG            "CPRIVMSG"      /* CPRI */
 #define TOK_CPRIVMSG            "CP"
 #define CMD_CPRIVMSG           MSG_CPRIVMSG, TOK_CPRIVMSG
Index: include/send.h
===================================================================
RCS file: /cvsroot/undernet-ircu/ircu2.10/include/send.h,v
retrieving revision 1.15.2.3
diff -u -r1.15.2.3 send.h
- --- include/send.h    5 May 2002 19:18:37 -0000       1.15.2.3
+++ include/send.h      24 Nov 2002 14:50:56 -0000
@@ -72,6 +72,8 @@
 #define SKIP_DEAF      0x01    /* skip users that are +d */
 #define SKIP_BURST     0x02    /* skip users that are bursting */
 #define SKIP_NONOPS    0x04    /* skip users that aren't chanops */
+#define SKIP_NONVOICES  0x08    /* skip users that aren't voiced (includes
+                                   chanops) */
 
 /* Send command to all users having a particular flag set */
 extern void sendwallto_group_butone(struct Client *from, int type, 
Index: include/supported.h
===================================================================
RCS file: /cvsroot/undernet-ircu/ircu2.10/include/supported.h,v
retrieving revision 1.9.2.5
diff -u -r1.9.2.5 supported.h
- --- include/supported.h       14 Sep 2002 20:44:32 -0000      1.9.2.5
+++ include/supported.h 24 Nov 2002 14:50:56 -0000
@@ -34,6 +34,7 @@
 #define FEATURES1 \
                 "WHOX"\
                 " WALLCHOPS"\
+               " WALLVOICES"\
                 " USERIP"\
                 " CPRIVMSG"\
                 " CNOTICE"\
Index: ircd/Makefile.in
===================================================================
RCS file: /cvsroot/undernet-ircu/ircu2.10/ircd/Makefile.in,v
retrieving revision 1.37.2.9
diff -u -r1.37.2.9 Makefile.in
- --- ircd/Makefile.in  22 Aug 2002 21:00:51 -0000      1.37.2.9
+++ ircd/Makefile.in    24 Nov 2002 14:50:59 -0000
@@ -166,6 +166,7 @@
        m_userip.c \
        m_version.c \
        m_wallchops.c \
+       m_wallvoices.c \
        m_wallops.c \
        m_wallusers.c \
        m_who.c \
@@ -957,6 +958,13 @@
   ../include/s_user.h ../include/send.h ../include/supported.h \
   ../include/channel.h ../include/version.h
 m_wallchops.o: m_wallchops.c ../config.h ../include/channel.h \
+  ../include/ircd_defs.h ../include/client.h ../include/dbuf.h \
+  ../include/msgq.h ../include/ircd_events.h ../include/ircd_handler.h \
+  ../include/hash.h ../include/ircd.h ../include/struct.h \
+  ../include/ircd_reply.h ../include/ircd_string.h \
+  ../include/ircd_chattr.h ../include/msg.h ../include/numeric.h \
+  ../include/numnicks.h ../include/s_user.h ../include/send.h
+m_wallvoices.o: m_wallvoices.c ../config.h ../include/channel.h \
   ../include/ircd_defs.h ../include/client.h ../include/dbuf.h \
   ../include/msgq.h ../include/ircd_events.h ../include/ircd_handler.h \
   ../include/hash.h ../include/ircd.h ../include/struct.h \
Index: ircd/parse.c
===================================================================
RCS file: /cvsroot/undernet-ircu/ircu2.10/ircd/parse.c,v
retrieving revision 1.30.2.7
diff -u -r1.30.2.7 parse.c
- --- ircd/parse.c      17 Jul 2002 22:55:41 -0000      1.30.2.7
+++ ircd/parse.c        24 Nov 2002 14:51:39 -0000
@@ -93,6 +93,13 @@
     { m_unregistered, m_wallchops, ms_wallchops, m_wallchops, m_ignore }
   },
   {
+    MSG_WALLVOICES,
+    TOK_WALLVOICES,
+    0, MAXPARA, MFLG_SLOW, 0,
+    /* UNREG, CLIENT, SERVER, OPER, SERVICE */
+    { m_unregistered, m_wallvoices, ms_wallvoices, m_wallvoices, m_ignore }
+  },
+  {
     MSG_CPRIVMSG,
     TOK_CPRIVMSG,
     0, MAXPARA, MFLG_SLOW, 0,
Index: ircd/send.c
===================================================================
RCS file: /cvsroot/undernet-ircu/ircu2.10/ircd/send.c,v
retrieving revision 1.44.2.8
diff -u -r1.44.2.8 send.c
- --- ircd/send.c       30 Aug 2002 16:12:24 -0000      1.44.2.8
+++ ircd/send.c 24 Nov 2002 14:51:49 -0000
@@ -480,8 +480,8 @@
 
   /* Build buffer to send to users */
   va_start(vd.vd_args, pattern);
- -  user_mb = msgq_make(0, skip & SKIP_NONOPS ? "%:#C %s @%v" : "%:#C %s %v",
- -                   from, skip & SKIP_NONOPS ? MSG_NOTICE : cmd, &vd);
+  user_mb = msgq_make(0, skip & (SKIP_NONOPS | SKIP_NONVOICES) ? "%:#C %s 
@%v" : "%:#C %s %v",
+     from, skip & (SKIP_NONOPS | SKIP_NONVOICES) ? MSG_NOTICE : cmd, &vd);
   va_end(vd.vd_args);
 
   /* Build buffer to send to servers */
@@ -496,6 +496,7 @@
     if (cli_from(member->user) == one || IsZombie(member) ||
        (skip & SKIP_DEAF && IsDeaf(member->user)) ||
        (skip & SKIP_NONOPS && !IsChanOp(member)) ||
+       (skip & SKIP_NONVOICES && !HasVoice(member) && !IsChanOp(member)) ||
        (skip & SKIP_BURST && IsBurstOrBurstAck(cli_from(member->user))) ||
        cli_fd(cli_from(member->user)) < 0 ||
        sentalong[cli_fd(cli_from(member->user))] == sentalong_marker)
Index: m_wallvoices.c
===================================================================
diff -u /dev/null ircd/m_wallvoices.c
- --- /dev/null 2002-10-21 15:26:49.000000000 +0100
+++ ircd/m_wallvoices.c 2002-11-18 21:38:14.000000000 +0000
@@ -0,0 +1,154 @@
+/*
+ * IRC - Internet Relay Chat, ircd/m_wallvoices.c
+ * Copyright (c) 2002 hikari
+ *
+ * See file AUTHORS in IRC package for additional names of
+ * the programmers.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 1, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id:$
+ */
+
+/*
+ * m_functions execute protocol messages on this server:
+ *
+ *    cptr    is always NON-NULL, pointing to a *LOCAL* client
+ *            structure (with an open socket connected!). This
+ *            identifies the physical socket where the message
+ *            originated (or which caused the m_function to be
+ *            executed--some m_functions may call others...).
+ *
+ *    sptr    is the source of the message, defined by the
+ *            prefix part of the message if present. If not
+ *            or prefix not found, then sptr==cptr.
+ *
+ *            (!IsServer(cptr)) => (cptr == sptr), because
+ *            prefixes are taken *only* from servers...
+ *
+ *            (IsServer(cptr))
+ *                    (sptr == cptr) => the message didn't
+ *                    have the prefix.
+ *
+ *                    (sptr != cptr && IsServer(sptr) means
+ *                    the prefix specified servername. (?)
+ *
+ *                    (sptr != cptr && !IsServer(sptr) means
+ *                    that message originated from a remote
+ *                    user (not local).
+ *
+ *            combining
+ *
+ *            (!IsServer(sptr)) means that, sptr can safely
+ *            taken as defining the target structure of the
+ *            message in this server.
+ *
+ *    *Always* true (if 'parse' and others are working correct):
+ *
+ *    1)      sptr->from == cptr  (note: cptr->from == cptr)
+ *
+ *    2)      MyConnect(sptr) <=> sptr == cptr (e.g. sptr
+ *            *cannot* be a local connection, unless it's
+ *            actually cptr!). [MyConnect(x) should probably
+ *            be defined as (x == x->from) --msa ]
+ *
+ *    parc    number of variable parameter strings (if zero,
+ *            parv is allowed to be NULL)
+ *
+ *    parv    a NULL terminated list of parameter pointers,
+ *
+ *                    parv[0], sender (prefix string), if not present
+ *                            this points to an empty string.
+ *                    parv[1]...parv[parc-1]
+ *                            pointers to additional parameters
+ *                    parv[parc] == NULL, *always*
+ *
+ *            note:   it is guaranteed that parv[0]..parv[parc-1] are all
+ *                    non-NULL pointers.
+ */
+#include "config.h"
+
+#include "channel.h"
+#include "client.h"
+#include "hash.h"
+#include "ircd.h"
+#include "ircd_reply.h"
+#include "ircd_string.h"
+#include "msg.h"
+#include "numeric.h"
+#include "numnicks.h"
+#include "s_user.h"
+#include "send.h"
+
+#include <assert.h>
+
+/*
+ * m_wallvoices - local generic message handler
+ */
+int m_wallvoices(struct Client* cptr, struct Client* sptr, int parc, char* 
parv[])
+{
+  struct Channel *chptr;
+
+  assert(0 != cptr);
+  assert(cptr == sptr);
+
+  cli_flags(sptr) &= ~FLAGS_TS8;
+
+  if (parc < 2 || EmptyString(parv[1]))
+    return send_reply(sptr, ERR_NORECIPIENT, "WALLVOICES");
+
+  if (parc < 3 || EmptyString(parv[parc - 1]))
+    return send_reply(sptr, ERR_NOTEXTTOSEND);
+
+  if (IsChannelName(parv[1]) && (chptr = FindChannel(parv[1]))) {
+    if (client_can_send_to_channel(sptr, chptr)) {
+      if ((chptr->mode.mode & MODE_NOPRIVMSGS) &&
+          check_target_limit(sptr, chptr, chptr->chname, 0))
+        return 0;
+      sendcmdto_channel_butone(sptr, CMD_WALLVOICES, chptr, cptr,
+                              SKIP_DEAF | SKIP_BURST | SKIP_NONVOICES, 
+                              "%H :%s", chptr, parv[parc - 1]);
+    }
+    else
+      send_reply(sptr, ERR_CANNOTSENDTOCHAN, parv[1]);
+  }
+  else
+    send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]);
+
+  return 0;
+}
+
+/*
+ * ms_wallvoices - server message handler
+ */
+int ms_wallvoices(struct Client* cptr, struct Client* sptr, int parc, char* 
parv[])
+{
+  struct Channel *chptr;
+  assert(0 != cptr);
+  assert(0 != sptr);
+
+  if (parc < 3 || !IsUser(sptr))
+    return 0;
+
+  if ((chptr = FindChannel(parv[1]))) {
+    if (client_can_send_to_channel(sptr, chptr)) {
+      sendcmdto_channel_butone(sptr, CMD_WALLVOICES, chptr, cptr,
+                              SKIP_DEAF | SKIP_BURST | SKIP_NONVOICES, 
+                              "%H :%s", chptr, parv[parc - 1]);
+    } else
+      send_reply(sptr, ERR_CANNOTSENDTOCHAN, parv[1]);
+  }
+  return 0;
+}

- -- 
Chris "hikari" Crowther
[EMAIL PROTECTED]
oper @ London.UK.EU.Undernet.Org
http://www.shad0w.org.uk/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE94OrZz8bl0gyT/hERAnS0AJ9oDksXU9fWXjF6I6aXSykEAmk5xgCfZicv
WyCkWYI1xaHWC9n+xFq0J2g=
=nv4M
-----END PGP SIGNATURE-----

Reply via email to