Implementec numeric "333": Time and user name who set a channel topic.
This commit is contained in:
parent
342f20f889
commit
ca32c1b311
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
ngIRCd CVSHEAD
|
ngIRCd CVSHEAD
|
||||||
|
|
||||||
|
- Implementec numeric "333": Time and user name who set a channel topic.
|
||||||
- Fixed server NOTICEs to users with "s" mode ("server messages").
|
- Fixed server NOTICEs to users with "s" mode ("server messages").
|
||||||
- Enhanced the handler for PING and PONG commands: fix forwarding and enable
|
- Enhanced the handler for PING and PONG commands: fix forwarding and enable
|
||||||
back-passing of a client supplied additional argument of PING.
|
back-passing of a client supplied additional argument of PING.
|
||||||
|
@ -637,4 +638,4 @@ ngIRCd 0.0.1, 31.12.2001
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
$Id: ChangeLog,v 1.291 2005/08/29 10:58:00 alex Exp $
|
$Id: ChangeLog,v 1.292 2005/09/02 12:50:25 alex Exp $
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "portab.h"
|
#include "portab.h"
|
||||||
|
|
||||||
static char UNUSED id[] = "$Id: channel.c,v 1.53 2005/07/31 20:13:08 alex Exp $";
|
static char UNUSED id[] = "$Id: channel.c,v 1.54 2005/09/02 12:50:25 alex Exp $";
|
||||||
|
|
||||||
#include "imp.h"
|
#include "imp.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -101,21 +101,24 @@ Channel_InitPredefined( void )
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Channel anlegen */
|
/* Create channel */
|
||||||
chan = Channel_Create(Conf_Channel[i].name);
|
chan = Channel_Create(Conf_Channel[i].name);
|
||||||
if( chan )
|
if (chan) {
|
||||||
{
|
|
||||||
Channel_ModeAdd(chan, 'P');
|
Channel_ModeAdd(chan, 'P');
|
||||||
if (!array_copy(&chan->topic, &Conf_Channel[i].topic)) {
|
|
||||||
Log( LOG_WARNING, "Could not set topic for new pre-defined channel: %s",
|
Channel_SetTopic(chan, NULL,
|
||||||
strerror(errno));
|
array_start(&Conf_Channel[i].topic));
|
||||||
}
|
|
||||||
array_free(&Conf_Channel[i].topic);
|
array_free(&Conf_Channel[i].topic);
|
||||||
|
|
||||||
c = Conf_Channel[i].modes;
|
c = Conf_Channel[i].modes;
|
||||||
while( *c ) Channel_ModeAdd( chan, *c++ );
|
while (*c)
|
||||||
Log( LOG_INFO, "Created pre-defined channel \"%s\".", Conf_Channel[i].name );
|
Channel_ModeAdd(chan, *c++);
|
||||||
|
|
||||||
|
Log(LOG_INFO, "Created pre-defined channel \"%s\".",
|
||||||
|
Conf_Channel[i].name );
|
||||||
}
|
}
|
||||||
else Log( LOG_ERR, "Can't create pre-defined channel \"%s\"!", Conf_Channel[i].name );
|
else Log(LOG_ERR, "Can't create pre-defined channel \"%s\"!",
|
||||||
|
Conf_Channel[i].name );
|
||||||
}
|
}
|
||||||
} /* Channel_InitPredefined */
|
} /* Channel_InitPredefined */
|
||||||
|
|
||||||
|
@ -636,8 +639,28 @@ Channel_Topic( CHANNEL *Chan )
|
||||||
} /* Channel_Topic */
|
} /* Channel_Topic */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef STRICT_RFC
|
||||||
|
|
||||||
|
GLOBAL unsigned int
|
||||||
|
Channel_TopicTime(CHANNEL *Chan)
|
||||||
|
{
|
||||||
|
assert(Chan != NULL);
|
||||||
|
return (unsigned int) Chan->topic_time;
|
||||||
|
} /* Channel_TopicTime */
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL char *
|
||||||
|
Channel_TopicWho(CHANNEL *Chan)
|
||||||
|
{
|
||||||
|
assert(Chan != NULL);
|
||||||
|
return Chan->topic_who;
|
||||||
|
} /* Channel_TopicWho */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
GLOBAL void
|
GLOBAL void
|
||||||
Channel_SetTopic( CHANNEL *Chan, char *Topic )
|
Channel_SetTopic(CHANNEL *Chan, CLIENT *Client, char *Topic)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
assert( Chan != NULL );
|
assert( Chan != NULL );
|
||||||
|
@ -648,9 +671,22 @@ Channel_SetTopic( CHANNEL *Chan, char *Topic )
|
||||||
array_free(&Chan->topic);
|
array_free(&Chan->topic);
|
||||||
|
|
||||||
if (!array_copyb(&Chan->topic, Topic, len))
|
if (!array_copyb(&Chan->topic, Topic, len))
|
||||||
Log(LOG_WARNING, "could not set new Topic %s: %s", Topic, strerror(errno));
|
Log(LOG_WARNING, "could not set new Topic \"%s\" on %s: %s",
|
||||||
|
Topic, Chan->name, strerror(errno));
|
||||||
|
|
||||||
array_cat0(&Chan->topic);
|
array_cat0(&Chan->topic);
|
||||||
|
|
||||||
|
#ifndef STRICT_RFC
|
||||||
|
Chan->topic_time = time(NULL);
|
||||||
|
if (Client != NULL && Client_Type(Client) != CLIENT_SERVER)
|
||||||
|
strlcpy(Chan->topic_who, Client_ID(Client),
|
||||||
|
sizeof Chan->topic_who);
|
||||||
|
else
|
||||||
|
strlcpy(Chan->topic_who, DEFAULT_TOPIC_ID,
|
||||||
|
sizeof Chan->topic_who);
|
||||||
|
#else
|
||||||
|
(void) Client;
|
||||||
|
#endif
|
||||||
} /* Channel_SetTopic */
|
} /* Channel_SetTopic */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* (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.28 2005/07/28 16:23:55 fw Exp $
|
* $Id: channel.h,v 1.29 2005/09/02 12:50:25 alex Exp $
|
||||||
*
|
*
|
||||||
* Channel management (header)
|
* Channel management (header)
|
||||||
*/
|
*/
|
||||||
|
@ -30,6 +30,10 @@ typedef struct _CHANNEL
|
||||||
UINT32 hash; /* Hash of the (lowecase!) name */
|
UINT32 hash; /* Hash of the (lowecase!) name */
|
||||||
char modes[CHANNEL_MODE_LEN]; /* Channel modes */
|
char modes[CHANNEL_MODE_LEN]; /* Channel modes */
|
||||||
array topic; /* Topic of the channel */
|
array topic; /* Topic of the channel */
|
||||||
|
#ifndef STRICT_RFC
|
||||||
|
time_t topic_time; /* Time when topic was set */
|
||||||
|
char topic_who[CLIENT_NICK_LEN];/* Nickname of user that set topic */
|
||||||
|
#endif
|
||||||
char key[CLIENT_PASS_LEN]; /* Channel key ("password", mode "k" ) */
|
char key[CLIENT_PASS_LEN]; /* Channel key ("password", mode "k" ) */
|
||||||
long maxusers; /* Maximum number of members (mode "l") */
|
long maxusers; /* Maximum number of members (mode "l") */
|
||||||
} CHANNEL;
|
} CHANNEL;
|
||||||
|
@ -72,7 +76,7 @@ GLOBAL char *Channel_Topic PARAMS(( CHANNEL *Chan ));
|
||||||
GLOBAL char *Channel_Key PARAMS(( CHANNEL *Chan ));
|
GLOBAL char *Channel_Key PARAMS(( CHANNEL *Chan ));
|
||||||
GLOBAL long Channel_MaxUsers PARAMS(( CHANNEL *Chan ));
|
GLOBAL long Channel_MaxUsers PARAMS(( CHANNEL *Chan ));
|
||||||
|
|
||||||
GLOBAL void Channel_SetTopic PARAMS(( CHANNEL *Chan, char *Topic ));
|
GLOBAL void Channel_SetTopic PARAMS(( CHANNEL *Chan, CLIENT *Client, char *Topic ));
|
||||||
GLOBAL void Channel_SetModes PARAMS(( CHANNEL *Chan, char *Modes ));
|
GLOBAL void Channel_SetModes PARAMS(( CHANNEL *Chan, char *Modes ));
|
||||||
GLOBAL void Channel_SetKey PARAMS(( CHANNEL *Chan, char *Key ));
|
GLOBAL void Channel_SetKey PARAMS(( CHANNEL *Chan, char *Key ));
|
||||||
GLOBAL void Channel_SetMaxUsers PARAMS(( CHANNEL *Chan, long Count ));
|
GLOBAL void Channel_SetMaxUsers PARAMS(( CHANNEL *Chan, long Count ));
|
||||||
|
@ -105,6 +109,11 @@ GLOBAL bool Channel_Write PARAMS(( CHANNEL *Chan, CLIENT *From, CLIENT *Client,
|
||||||
|
|
||||||
GLOBAL CHANNEL *Channel_Create PARAMS(( char *Name ));
|
GLOBAL CHANNEL *Channel_Create PARAMS(( char *Name ));
|
||||||
|
|
||||||
|
#ifndef STRICT_RFC
|
||||||
|
GLOBAL unsigned int Channel_TopicTime PARAMS(( CHANNEL *Chan ));
|
||||||
|
GLOBAL char *Channel_TopicWho PARAMS(( CHANNEL *Chan ));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* (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: defines.h,v 1.56 2005/07/28 16:23:55 fw Exp $
|
* $Id: defines.h,v 1.57 2005/09/02 12:50:25 alex Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,6 +103,8 @@
|
||||||
#define DEFAULT_AWAY_MSG "Away" /* Away message for users connected to
|
#define DEFAULT_AWAY_MSG "Away" /* Away message for users connected to
|
||||||
linked servers. */
|
linked servers. */
|
||||||
|
|
||||||
|
#define DEFAULT_TOPIC_ID "-Server-" /* Default ID for "topic owner". */
|
||||||
|
|
||||||
#define CONFIG_FILE "/ngircd.conf" /* Configuration file name. */
|
#define CONFIG_FILE "/ngircd.conf" /* Configuration file name. */
|
||||||
#define MOTD_FILE "/ngircd.motd" /* Name of the MOTD file. */
|
#define MOTD_FILE "/ngircd.motd" /* Name of the MOTD file. */
|
||||||
#define MOTD_PHRASE "" /* Default MOTD phrase string. */
|
#define MOTD_PHRASE "" /* Default MOTD phrase string. */
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "portab.h"
|
#include "portab.h"
|
||||||
|
|
||||||
static char UNUSED id[] = "$Id: irc-channel.c,v 1.30 2005/06/12 18:23:59 alex Exp $";
|
static char UNUSED id[] = "$Id: irc-channel.c,v 1.31 2005/09/02 12:50:25 alex Exp $";
|
||||||
|
|
||||||
#include "imp.h"
|
#include "imp.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -211,9 +211,18 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
|
||||||
/* an Client bestaetigen */
|
/* an Client bestaetigen */
|
||||||
IRC_WriteStrClientPrefix( Client, target, "JOIN :%s", channame );
|
IRC_WriteStrClientPrefix( Client, target, "JOIN :%s", channame );
|
||||||
|
|
||||||
/* Topic an Client schicken */
|
/* Send topic to client, if any */
|
||||||
topic = Channel_Topic(chan);
|
topic = Channel_Topic(chan);
|
||||||
if( *topic ) IRC_WriteStrClient( Client, RPL_TOPIC_MSG, Client_ID( Client ), channame, topic );
|
if (*topic) {
|
||||||
|
IRC_WriteStrClient(Client, RPL_TOPIC_MSG,
|
||||||
|
Client_ID(Client), channame, topic);
|
||||||
|
#ifndef STRICT_RFC
|
||||||
|
IRC_WriteStrClient(Client, RPL_TOPICSETBY_MSG,
|
||||||
|
Client_ID(Client), channame,
|
||||||
|
Channel_TopicWho(chan),
|
||||||
|
Channel_TopicTime(chan));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* Mitglieder an Client Melden */
|
/* Mitglieder an Client Melden */
|
||||||
IRC_Send_NAMES( Client, chan );
|
IRC_Send_NAMES( Client, chan );
|
||||||
|
@ -268,6 +277,7 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
|
||||||
CHANNEL *chan;
|
CHANNEL *chan;
|
||||||
CLIENT *from;
|
CLIENT *from;
|
||||||
char *topic;
|
char *topic;
|
||||||
|
bool r;
|
||||||
|
|
||||||
assert( Client != NULL );
|
assert( Client != NULL );
|
||||||
assert( Req != NULL );
|
assert( Req != NULL );
|
||||||
|
@ -288,10 +298,22 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
|
||||||
|
|
||||||
if( Req->argc == 1 )
|
if( Req->argc == 1 )
|
||||||
{
|
{
|
||||||
/* Topic erfragen */
|
/* Request actual topic */
|
||||||
topic = Channel_Topic(chan);
|
topic = Channel_Topic(chan);
|
||||||
if( *topic ) return IRC_WriteStrClient( from, RPL_TOPIC_MSG, Client_ID( from ), Channel_Name( chan ), topic );
|
if (*topic) {
|
||||||
else return IRC_WriteStrClient( from, RPL_NOTOPIC_MSG, Client_ID( from ), Channel_Name( chan ));
|
r = IRC_WriteStrClient(from, RPL_TOPIC_MSG,
|
||||||
|
Client_ID(Client), Channel_Name(chan), topic);
|
||||||
|
#ifndef STRICT_RFC
|
||||||
|
r = IRC_WriteStrClient(from, RPL_TOPICSETBY_MSG,
|
||||||
|
Client_ID(Client), Channel_Name(chan),
|
||||||
|
Channel_TopicWho(chan),
|
||||||
|
Channel_TopicTime(chan));
|
||||||
|
#endif
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return IRC_WriteStrClient(from, RPL_NOTOPIC_MSG,
|
||||||
|
Client_ID(from), Channel_Name(chan));
|
||||||
}
|
}
|
||||||
|
|
||||||
if( strchr( Channel_Modes( chan ), 't' ))
|
if( strchr( Channel_Modes( chan ), 't' ))
|
||||||
|
@ -300,9 +322,11 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
|
||||||
if( ! strchr( Channel_UserModes( chan, from ), 'o' )) return IRC_WriteStrClient( from, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( from ), Channel_Name( chan ));
|
if( ! strchr( Channel_UserModes( chan, from ), 'o' )) return IRC_WriteStrClient( from, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( from ), Channel_Name( chan ));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Topic setzen */
|
/* Set new topic */
|
||||||
Channel_SetTopic( chan, Req->argv[1] );
|
Channel_SetTopic(chan, from, Req->argv[1]);
|
||||||
Log( LOG_DEBUG, "User \"%s\" set topic on \"%s\": %s", Client_Mask( from ), Channel_Name( chan ), Req->argv[1][0] ? Req->argv[1] : "<none>" );
|
Log(LOG_DEBUG, "User \"%s\" set topic on \"%s\": %s",
|
||||||
|
Client_Mask(from), Channel_Name(chan),
|
||||||
|
Req->argv[1][0] ? Req->argv[1] : "<none>");
|
||||||
|
|
||||||
/* im Channel bekannt machen und an Server weiterleiten */
|
/* im Channel bekannt machen und an Server weiterleiten */
|
||||||
IRC_WriteStrServersPrefix( Client, from, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
|
IRC_WriteStrServersPrefix( Client, from, "TOPIC %s :%s", Req->argv[0], Req->argv[1] );
|
||||||
|
@ -478,8 +502,9 @@ IRC_CHANINFO( CLIENT *Client, REQUEST *Req )
|
||||||
if(( ! *ptr ) && ( Req->argv[arg_topic][0] ))
|
if(( ! *ptr ) && ( Req->argv[arg_topic][0] ))
|
||||||
{
|
{
|
||||||
/* OK, there is no topic jet */
|
/* OK, there is no topic jet */
|
||||||
Channel_SetTopic( chan, Req->argv[arg_topic] );
|
Channel_SetTopic(chan, Client, Req->argv[arg_topic]);
|
||||||
IRC_WriteStrChannelPrefix( Client, chan, from, false, "TOPIC %s :%s", Req->argv[0], Channel_Topic( chan ));
|
IRC_WriteStrChannelPrefix(Client, chan, from, false,
|
||||||
|
"TOPIC %s :%s", Req->argv[0], Channel_Topic(chan));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* (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: messages.h,v 1.66 2004/02/28 02:18:16 alex Exp $
|
* $Id: messages.h,v 1.67 2005/09/02 12:50:25 alex Exp $
|
||||||
*
|
*
|
||||||
* IRC numerics (Header)
|
* IRC numerics (Header)
|
||||||
*/
|
*/
|
||||||
|
@ -62,6 +62,7 @@
|
||||||
#define RPL_CHANNELMODEIS_MSG "324 %s %s +%s"
|
#define RPL_CHANNELMODEIS_MSG "324 %s %s +%s"
|
||||||
#define RPL_NOTOPIC_MSG "331 %s %s :No topic is set"
|
#define RPL_NOTOPIC_MSG "331 %s %s :No topic is set"
|
||||||
#define RPL_TOPIC_MSG "332 %s %s :%s"
|
#define RPL_TOPIC_MSG "332 %s %s :%s"
|
||||||
|
#define RPL_TOPICSETBY_MSG "333 %s %s %s %u"
|
||||||
#define RPL_INVITING_MSG "341 %s %s %s"
|
#define RPL_INVITING_MSG "341 %s %s %s"
|
||||||
#define RPL_INVITELIST_MSG "346 %s %s %s"
|
#define RPL_INVITELIST_MSG "346 %s %s %s"
|
||||||
#define RPL_ENDOFINVITELIST_MSG "347 %s %s :End of channel invite list"
|
#define RPL_ENDOFINVITELIST_MSG "347 %s %s :End of channel invite list"
|
||||||
|
|
Loading…
Reference in New Issue