]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Fix PRIVMSG/NOTICE handler (II): keep command when forwarding to channels.
authorAlexander Barton <alex@barton.de>
Sun, 17 Aug 2008 12:59:36 +0000 (14:59 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 23 Sep 2008 09:53:15 +0000 (11:53 +0200)
- new function ngt_UpperStr().
- change Channel_Write() to take command name and error flag.
- remove now unneeded function Channel_Notice().

src/ngircd/channel.c
src/ngircd/channel.h
src/ngircd/irc.c

index aec6aa2da9e9a6b686535040e46432099c424fd0..d774e576af95882ae134c9b2341a205752709dc9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2005 by Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2008 by Alexander Barton (alex@barton.de)
  *
  * 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
@@ -17,8 +17,6 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: channel.c,v 1.65 2008/02/05 16:31:35 fw Exp $";
-
 #include "imp.h"
 #include <assert.h>
 #include <stdlib.h>
@@ -770,30 +768,21 @@ Can_Send_To_Channel(CHANNEL *Chan, CLIENT *From)
 
 
 GLOBAL bool
-Channel_Write(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Text)
-{
-       if (!Can_Send_To_Channel(Chan, From))
-               return IRC_WriteStrClient(From, ERR_CANNOTSENDTOCHAN_MSG, Client_ID(From), Channel_Name(Chan));
-
-       if (Client_Conn(From) > NONE)
-               Conn_UpdateIdle(Client_Conn(From));
-
-       return IRC_WriteStrChannelPrefix(Client, Chan, From, true,
-                       "PRIVMSG %s :%s", Channel_Name(Chan), Text);
-}
-
-
-GLOBAL bool
-Channel_Notice(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Text)
+Channel_Write(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Command,
+             bool SendErrors, const char *Text)
 {
-       if (!Can_Send_To_Channel(Chan, From))
-               return true; /* no error, see RFC 2812 */
+       if (!Can_Send_To_Channel(Chan, From)) {
+               if (! SendErrors)
+                       return CONNECTED;       /* no error, see RFC 2812 */
+               return IRC_WriteStrClient(From, ERR_CANNOTSENDTOCHAN_MSG,
+                                         Client_ID(From), Channel_Name(Chan));
+       }
 
        if (Client_Conn(From) > NONE)
                Conn_UpdateIdle(Client_Conn(From));
 
        return IRC_WriteStrChannelPrefix(Client, Chan, From, true,
-                       "NOTICE %s :%s", Channel_Name(Chan), Text);
+                       "%s %s :%s", Command, Channel_Name(Chan), Text);
 }
 
 
index 1f78bf87b377f2e70be8a0ebf0c48c0874d1d841..a562645c6c0c6b79c6df9f4ff02ca32865be739f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2008 by Alexander Barton (alex@barton.de)
  *
  * 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
@@ -8,8 +8,6 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: channel.h,v 1.35 2008/02/05 16:31:35 fw Exp $
- *
  * Channel management (header)
  */
 
@@ -109,8 +107,9 @@ GLOBAL char *Channel_UserModes PARAMS(( CHANNEL *Chan, CLIENT *Client ));
 
 GLOBAL bool Channel_IsMemberOf PARAMS(( CHANNEL *Chan, CLIENT *Client ));
 
-GLOBAL bool Channel_Write PARAMS(( CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Text ));
-GLOBAL bool Channel_Notice PARAMS(( CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Text));
+GLOBAL bool Channel_Write PARAMS((CHANNEL *Chan, CLIENT *From, CLIENT *Client,
+                                 const char *Command, bool SendErrors,
+                                 const char *Text));
 
 GLOBAL CHANNEL *Channel_Create PARAMS(( char *Name ));
 
index 3a2a9affbe97d1dd80cea10c5abe4e784f117a86..8d2291fe20a0dabdbfe0e0ac109bf1cc18c346a5 100644 (file)
@@ -33,6 +33,7 @@ static char UNUSED id[] = "$Id: irc.c,v 1.132 2008/01/15 22:28:14 fw Exp $";
 #include "match.h"
 #include "messages.h"
 #include "parse.h"
+#include "tool.h"
 
 #include "exp.h"
 #include "irc.h"
@@ -349,6 +350,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
 
        /* handle msgtarget = msgto *("," msgto) */
        currentTarget = strtok_r(currentTarget, ",", &lastCurrentTarget);
+       ngt_UpperStr(Req->command);
 
        while (currentTarget) {
                /* Check for and handle valid <msgto> of form:
@@ -460,8 +462,9 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
                                return DISCONNECTED;
                } else if ((chan = Channel_Search(currentTarget))) {
                        /* channel */
-                       if (!Channel_Write(chan, from, Client, Req->argv[1]))
-                               return DISCONNECTED;
+                       if (!Channel_Write(chan, from, Client, Req->command,
+                                          SendErrors, Req->argv[1]))
+                                       return DISCONNECTED;
                } else {
                        if (!SendErrors)
                                return CONNECTED;