mirror of
https://github.com/osmarks/ngircd.git
synced 2025-05-29 04:24:09 +00:00
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().
This commit is contained in:
parent
91e87a3705
commit
3913de3cff
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* ngIRCd -- The Next Generation IRC Daemon
|
* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
#include "portab.h"
|
#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 "imp.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -770,30 +768,21 @@ Can_Send_To_Channel(CHANNEL *Chan, CLIENT *From)
|
|||||||
|
|
||||||
|
|
||||||
GLOBAL bool
|
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))
|
if (!Can_Send_To_Channel(Chan, From)) {
|
||||||
return IRC_WriteStrClient(From, ERR_CANNOTSENDTOCHAN_MSG, Client_ID(From), Channel_Name(Chan));
|
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)
|
if (Client_Conn(From) > NONE)
|
||||||
Conn_UpdateIdle(Client_Conn(From));
|
Conn_UpdateIdle(Client_Conn(From));
|
||||||
|
|
||||||
return IRC_WriteStrChannelPrefix(Client, Chan, From, true,
|
return IRC_WriteStrChannelPrefix(Client, Chan, From, true,
|
||||||
"PRIVMSG %s :%s", Channel_Name(Chan), Text);
|
"%s %s :%s", Command, 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 (Client_Conn(From) > NONE)
|
|
||||||
Conn_UpdateIdle(Client_Conn(From));
|
|
||||||
|
|
||||||
return IRC_WriteStrChannelPrefix(Client, Chan, From, true,
|
|
||||||
"NOTICE %s :%s", Channel_Name(Chan), Text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* ngIRCd -- The Next Generation IRC Daemon
|
* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -8,8 +8,6 @@
|
|||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* Please read the file COPYING, README and AUTHORS for more information.
|
* 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)
|
* 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_IsMemberOf PARAMS(( CHANNEL *Chan, CLIENT *Client ));
|
||||||
|
|
||||||
GLOBAL bool Channel_Write PARAMS(( CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Text ));
|
GLOBAL bool Channel_Write PARAMS((CHANNEL *Chan, CLIENT *From, CLIENT *Client,
|
||||||
GLOBAL bool Channel_Notice PARAMS(( CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Text));
|
const char *Command, bool SendErrors,
|
||||||
|
const char *Text));
|
||||||
|
|
||||||
GLOBAL CHANNEL *Channel_Create PARAMS(( char *Name ));
|
GLOBAL CHANNEL *Channel_Create PARAMS(( char *Name ));
|
||||||
|
|
||||||
|
@ -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 "match.h"
|
||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
|
#include "tool.h"
|
||||||
|
|
||||||
#include "exp.h"
|
#include "exp.h"
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
@ -349,6 +350,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
|
|||||||
|
|
||||||
/* handle msgtarget = msgto *("," msgto) */
|
/* handle msgtarget = msgto *("," msgto) */
|
||||||
currentTarget = strtok_r(currentTarget, ",", &lastCurrentTarget);
|
currentTarget = strtok_r(currentTarget, ",", &lastCurrentTarget);
|
||||||
|
ngt_UpperStr(Req->command);
|
||||||
|
|
||||||
while (currentTarget) {
|
while (currentTarget) {
|
||||||
/* Check for and handle valid <msgto> of form:
|
/* Check for and handle valid <msgto> of form:
|
||||||
@ -460,8 +462,9 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
|
|||||||
return DISCONNECTED;
|
return DISCONNECTED;
|
||||||
} else if ((chan = Channel_Search(currentTarget))) {
|
} else if ((chan = Channel_Search(currentTarget))) {
|
||||||
/* channel */
|
/* channel */
|
||||||
if (!Channel_Write(chan, from, Client, Req->argv[1]))
|
if (!Channel_Write(chan, from, Client, Req->command,
|
||||||
return DISCONNECTED;
|
SendErrors, Req->argv[1]))
|
||||||
|
return DISCONNECTED;
|
||||||
} else {
|
} else {
|
||||||
if (!SendErrors)
|
if (!SendErrors)
|
||||||
return CONNECTED;
|
return CONNECTED;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user