[NeoStats-Devel] [Commits] r2602 - in trunk: include modules/textserv src
[email protected] Fri, 20 May 2005 08:41:55 +1000
Newsgroups
gmane.comp.neostats.devel
Message-ID
<[email protected] >
Author: Mark
Date: Fri May 20 06:41:37 2005
New Revision: 2602
Modified:
trunk/include/neostats.h
trunk/modules/textserv/main.c
trunk/src/ctcp.c
Log:
textserv is now a channel system and supports CTCP ACTION
Modified: trunk/include/neostats.h
==============================================================================
--- trunk/include/neostats.h (original)
+++ trunk/include/neostats.h Fri May 20 06:41:37 2005
@@ -1250,6 +1250,7 @@
EXPORTFUNC int irc_ctcp_finger_req( Bot *botptr, Client *target );
EXPORTFUNC int irc_ctcp_action_req( Bot *botptr, Client *target, const char *action );
+EXPORTFUNC int irc_ctcp_action_req_channel( Bot* botptr, Channel* channel, const char *action );
EXPORTFUNC int irc_ctcp_time_req( Bot* botptr, Client* target );
Modified: trunk/modules/textserv/main.c
==============================================================================
--- trunk/modules/textserv/main.c (original)
+++ trunk/modules/textserv/main.c Fri May 20 06:41:37 2005
@@ -129,7 +129,7 @@
static bot_cmd ts_commandtemplate[]=
{
- {NULL, ts_cmd_msg, 1, 0, ts_help_cmd, ts_help_cmd_oneline },
+ {NULL, ts_cmd_msg, 1, 0, ts_help_cmd, ts_help_cmd_oneline, CMD_FLAG_CHANONLY },
};
static bot_cmd ts_commandtemplateabout[]=
@@ -479,7 +479,7 @@
tshash = hash_create( -1, 0, 0 );
if( !tshash ) {
nlog( LOG_CRITICAL, "Unable to create database hash" );
- return -1;
+ return NS_FAILURE;
}
DBAFetchRows( "databases", load_dbentry );
ModuleConfig( ts_settings );
@@ -504,11 +504,10 @@
ts_bot = AddBot( &ts_botinfo );
if( !ts_bot )
- {
return NS_FAILURE;
- }
hash_scan_begin( &hs, tshash );
- while( ( hn = hash_scan_next( &hs ) ) != NULL ) {
+ while( ( hn = hash_scan_next( &hs ) ) != NULL )
+ {
db =( ( dbbot * )hnode_get( hn ) );
JoinBot( db );
}
@@ -687,8 +686,10 @@
static int ts_cmd_msg( CmdParams* cmdparams )
{
static char buf[BUFSIZE];
+ char *fmt;
dbbot *db;
Client *target;
+ int isaction = 0;
SET_SEGV_LOCATION();
db = (dbbot *) GetBotModValue( cmdparams->bot );
@@ -698,19 +699,28 @@
return NS_FAILURE;
}
irc_prefmsg( cmdparams->bot, cmdparams->source, "%s has been sent to %s", cmdparams->cmd, target->name );
+ fmt = ( char * ) cmdparams->cmd_ptr->moddata;
+ if( ircstrncasecmp( fmt, "ACTION ", 7 ) == 0 )
+ {
+ isaction = 1;
+ fmt += 7;
+ }
if( cmdparams->ac > 1)
{
char *message;
message = joinbuf( cmdparams->av, cmdparams->ac, 1 );
- tsprintf( cmdparams->bot->u->name, cmdparams->source->name, target->name, buf, BUFSIZE, ( char * ) cmdparams->cmd_ptr->moddata, message );
+ tsprintf( cmdparams->bot->u->name, cmdparams->source->name, target->name, buf, BUFSIZE, fmt, message );
ns_free( message );
}
else
{
- tsprintf( cmdparams->bot->u->name, cmdparams->source->name, target->name, buf, BUFSIZE, ( char * ) cmdparams->cmd_ptr->moddata );
+ tsprintf( cmdparams->bot->u->name, cmdparams->source->name, target->name, buf, BUFSIZE, fmt );
}
- irc_prefmsg( cmdparams->bot, cmdparams->source, buf );
+ if( isaction )
+ irc_ctcp_action_req_channel( cmdparams->bot, cmdparams->channel, buf );
+ else
+ irc_chanprivmsg( cmdparams->bot, cmdparams->channel, buf );
return NS_SUCCESS;
}
Modified: trunk/src/ctcp.c
==============================================================================
--- trunk/src/ctcp.c (original)
+++ trunk/src/ctcp.c Fri May 20 06:41:37 2005
@@ -187,6 +187,13 @@
return NS_SUCCESS;
}
+int irc_ctcp_action_req_channel( Bot* botptr, Channel* channel, const char *action )
+{
+ dlog( DEBUG5, "TX: Sending CTCP ACTION request from %s to %s", botptr->name, channel->name );
+ irc_chanprivmsg( botptr, channel->name, "\1ACTION %s\1", action );
+ return NS_SUCCESS;
+}
+
static int ctcp_req_dcc( CmdParams* cmdparams )
{
dlog( DEBUG5, "RX: CTCP DCC request from %s to %s", cmdparams->source->name, cmdparams->bot->name );