[NeoStats-Devel] [Commits] r2786 - in trunk: . include src

[email protected] Thu, 1 Sep 2005 08:17:50 +1000
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: Mark
Date: Thu Sep  1 06:17:47 2005
New Revision: 2786

Modified:
   trunk/ChangeLog
   trunk/include/events.h
   trunk/include/neostats.h
   trunk/src/ctcp.c
   trunk/src/nsevents.c
Log:
Introduce framework for unknown ctcp messages

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	(original)
+++ trunk/ChangeLog	Thu Sep  1 06:17:47 2005
@@ -4,6 +4,7 @@
 Fish (F), Mark (M), DeadNotBuried (D)
 ===============================================================================
 * NeoStats * Version 3.0.a3-dev
+ - Introduce framework for unknown ctcp messages. (M)
  - Fix a memleak in ExtAuth (F)
  - Netinfo on Ultimate3 is like Globops, not a burst function (F)
  - Create core support for map generation accessible to all modules via a 

Modified: trunk/include/events.h
==============================================================================
--- trunk/include/events.h	(original)
+++ trunk/include/events.h	Thu Sep  1 06:17:47 2005
@@ -387,6 +387,20 @@
  */
 	EVENT_CTCPPINGREQ,
 
+/*  EVENT_CTCPUNHANDLEDRPL 
+ *    parameters:
+ *      user in cmdparams->source
+ *      ???
+ */
+	EVENT_CTCPUNHANDLEDRPL,
+
+/*  EVENT_CTCPUNHANDLEDREQ
+ *    parameters:
+ *      user in cmdparams->source
+ *      ???
+ */
+	EVENT_CTCPUNHANDLEDREQ,
+
 /*  DCC events 
  *    Generated in response to ctcp dcc events
  */

Modified: trunk/include/neostats.h
==============================================================================
--- trunk/include/neostats.h	(original)
+++ trunk/include/neostats.h	Thu Sep  1 06:17:47 2005
@@ -1321,10 +1321,14 @@
 EXPORTFUNC int irc_ctcp_finger_req( const Bot *botptr, const Client *target );
 
 EXPORTFUNC int irc_ctcp_action_req( const Bot *botptr, const Client *target, const char *action );
-EXPORTFUNC int irc_ctcp_action_req_channel( const Bot* botptr, const Channel* channel, const char *action );
+EXPORTFUNC int irc_ctcp_action_req_channel( const Bot *botptr, const Channel *channel, const char *action );
 
 EXPORTFUNC int irc_ctcp_time_req( const Bot* botptr, const Client* target );
 
+EXPORTFUNC int irc_ctcp_unhandled_req( const Bot *botptr, const Client *target, const char *ctcp_command );
+EXPORTFUNC int irc_ctcp_unhandled_rpl( const Bot *botptr, const Client *target, const char *ctcp_command, const char *ctcp_parameters );
+
+
 /* bots.c */
 EXPORTFUNC int GenerateBotNick( char *nickbuf, int stublen, int alphacount, int numcount);
 

Modified: trunk/src/ctcp.c
==============================================================================
--- trunk/src/ctcp.c	(original)
+++ trunk/src/ctcp.c	Thu Sep  1 06:17:47 2005
@@ -45,6 +45,8 @@
 static int ctcp_rpl_time( CmdParams* cmdparams );
 static int ctcp_req_ping( CmdParams* cmdparams );
 static int ctcp_rpl_ping( CmdParams* cmdparams );
+static int ctcp_req_unhandled( CmdParams* cmdparams );
+static int ctcp_rpl_unhandled( CmdParams* cmdparams );
 
 static ctcp_cmd ctcp_cmds[]= {
 	{"VERSION",	ctcp_req_version,	ctcp_rpl_version },
@@ -92,6 +94,7 @@
 			cmd++;
 		}
 	}
+	ctcp_req_unhandled( cmdparams );
 	return NS_SUCCESS;
 }
 
@@ -116,6 +119,7 @@
 			cmd++;
 		}
 	}
+	ctcp_rpl_unhandled( cmdparams );
 	return NS_SUCCESS;
 }
 
@@ -253,3 +257,32 @@
 	irc_privmsg( botptr, target, "\1PING\1" );
 	return NS_SUCCESS;
 }
+
+static int ctcp_req_unhandled( CmdParams* cmdparams )
+{
+	dlog( DEBUG5, "RX: CTCP UNHANDLED request from %s to %s", cmdparams->source->name, cmdparams->bot->name );
+	SendModuleEvent( EVENT_CTCPUNHANDLEDREQ, cmdparams, cmdparams->bot->moduleptr );
+	return NS_SUCCESS;
+}
+
+static int ctcp_rpl_unhandled( CmdParams* cmdparams )
+{
+	dlog( DEBUG5, "RX: CTCP UNHANDLED reply from %s to %s", cmdparams->source->name, cmdparams->bot->name );
+	SendModuleEvent( EVENT_CTCPUNHANDLEDRPL, cmdparams, cmdparams->bot->moduleptr );
+	return NS_SUCCESS;
+}
+
+int irc_ctcp_unhandled_req( const Bot *botptr, const Client *target, const char *ctcp_command )
+{
+	dlog( DEBUG5, "TX: CTCP UNHANDLED request from %s to %s: %s %s", botptr->name, target->name, ctcp_command );
+	irc_privmsg( botptr, target, "\1%s\1", ctcp_command );
+	return NS_SUCCESS;
+}
+
+int irc_ctcp_unhandled_rpl( const Bot *botptr, const Client *target, const char *ctcp_command, const char *ctcp_parameters )
+{
+	dlog( DEBUG5, "TX: CTCP UNHANDLED request from %s to %s: %s %s", botptr->name, target->name, ctcp_command, ctcp_parameters );
+	irc_privmsg( botptr, target, "\1%s %s\1", ctcp_command, ctcp_parameters );
+	return NS_SUCCESS;
+}
+

Modified: trunk/src/nsevents.c
==============================================================================
--- trunk/src/nsevents.c	(original)
+++ trunk/src/nsevents.c	Thu Sep  1 06:17:47 2005
@@ -85,6 +85,8 @@
 	"EVENT_CTCPTIMEREQ",
 	"EVENT_CTCPPINGRPL",
 	"EVENT_CTCPPINGREQ",
+	"EVENT_CTCPUNHANDLEDRPL",
+	"EVENT_CTCPUNHANDLEDREQ",
 	"EVENT_DCCSEND",
 	"EVENT_DCCCHAT",
 	"EVENT_DCCCHATMSG",