commit 3913de3cffaa4a3641075d4b4df4aea388bc3717 from: Alexander Barton date: Tue Sep 23 09:53:15 2008 UTC Fix PRIVMSG/NOTICE handler (II): keep command when forwarding to channels. - new function ngt_UpperStr(). - change Channel_Write() to take command name and error flag. - remove now unneeded function Channel_Notice(). commit - 91e87a37051018c100cff6c72eb7aaf823efe894 commit + 3913de3cffaa4a3641075d4b4df4aea388bc3717 blob - aec6aa2da9e9a6b686535040e46432099c424fd0 blob + d774e576af95882ae134c9b2341a205752709dc9 --- src/ngircd/channel.c +++ src/ngircd/channel.c @@ -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 #include @@ -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) +Channel_Write(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Command, + bool SendErrors, 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) -{ - 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); } blob - 1f78bf87b377f2e70be8a0ebf0c48c0874d1d841 blob + a562645c6c0c6b79c6df9f4ff02ca32865be739f --- src/ngircd/channel.h +++ src/ngircd/channel.h @@ -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, 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 )); blob - 3a2a9affbe97d1dd80cea10c5abe4e784f117a86 blob + 8d2291fe20a0dabdbfe0e0ac109bf1cc18c346a5 --- src/ngircd/irc.c +++ src/ngircd/irc.c @@ -33,6 +33,7 @@ static char UNUSED id[] = "$Id: irc.c,v 1.132 2008/01/ #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 Force /* handle msgtarget = msgto *("," msgto) */ currentTarget = strtok_r(currentTarget, ",", &lastCurrentTarget); + ngt_UpperStr(Req->command); while (currentTarget) { /* Check for and handle valid of form: @@ -460,8 +462,9 @@ Send_Message(CLIENT * Client, REQUEST * Req, int Force 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;