[cvslog] Module eggdrop1.7: Change committed

cvslog cvs at tsss.org
Sun Oct 21 01:03:01 CST 2001


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.7
Commit time: 2001-10-21 06:02:58 UTC
Commited by: stdarg <stdarg at techmonkeys.org>

Modified files:
     doc/tcl-commands.doc src/dcc.c src/main.c src/tclhash.c
     src/mod/tclscript.mod/tclscript.c

Log message:

* Changed the FILT bind to use a global variable instead of returning a string.
This will make it easier for multiple callbacks to act on one string.
* Made a new config variable called "dcc_command_chars" that lets you change
which chars represent a command on the console. Default is "./".

---------------------- diff included ----------------------
Index: eggdrop1.7/doc/tcl-commands.doc
diff -u eggdrop1.7/doc/tcl-commands.doc:1.60 eggdrop1.7/doc/tcl-commands.doc:1.61
--- eggdrop1.7/doc/tcl-commands.doc:1.60	Fri Oct 19 00:26:32 2001
+++ eggdrop1.7/doc/tcl-commands.doc	Sun Oct 21 01:02:47 2001
@@ -1276,9 +1276,9 @@
        procname <idx> <text>
 
        DCC party line and file system users have their text sent through
-       filt before being processed; if the proc a blank string, the text
-       is considered parsed; otherwise the bot will use the text returned
-       from the proc and continue parsing that
+       filt before being processed; the proc can modify the global variable
+       filt_string to change the text; if the proc makes filt_string blank ("")
+       the text will be dropped without further processing
 
   (29) NEED   (stackable)
        bind need <flags> <mask> <proc>
Index: eggdrop1.7/src/dcc.c
diff -u eggdrop1.7/src/dcc.c:1.61 eggdrop1.7/src/dcc.c:1.62
--- eggdrop1.7/src/dcc.c:1.61	Sat Oct 20 16:57:15 2001
+++ eggdrop1.7/src/dcc.c	Sun Oct 21 01:02:48 2001
@@ -4,7 +4,7 @@
  *   disconnect on a dcc socket
  *   ...and that's it!  (but it's a LOT)
  *
- * $Id: dcc.c,v 1.61 2001/10/20 21:57:15 stdarg Exp $
+ * $Id: dcc.c,v 1.62 2001/10/21 06:02:48 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -30,6 +30,8 @@
 #include <errno.h>
 #include "modules.h"
 #include "tandem.h"
+#include "script_api.h"
+#include "script.h"
 
 /* Includes for botnet md5 challenge/response code <cybah> */
 #include "md5.h"
@@ -64,11 +66,27 @@
 int	flood_telnet_time = 60;	/* In how many seconds?			   */
 char	bannerfile[121] = "text/banner"; /* File displayed on telnet login */
 
+static char *dcc_command_chars = NULL;
+
 static void dcc_telnet_hostresolved(int);
 static void dcc_telnet_got_ident(int, char *);
 static void dcc_telnet_pass(int, int);
 
 
+extern void init_dcc_max();
+
+static script_str_t dcc_script_strings[] = {
+	{"", "dcc_command_chars", &dcc_command_chars},
+	0
+};
+
+void dcc_init()
+{
+	malloc_strcpy(dcc_command_chars, "./");
+	script_link_str_table(dcc_script_strings);
+	init_dcc_max();
+}
+
 static void strip_telnet(int sock, char *buf, int *len)
 {
   unsigned char *p = (unsigned char *) buf, *o = (unsigned char *) buf;
@@ -823,16 +841,20 @@
 static void dcc_chat(int idx, char *buf, int i)
 {
   int nathan = 0, doron = 0, fixed = 0;
+  int iscommand;
   char *v, *d;
 
   strip_telnet(dcc[idx].sock, buf, &i);
-  if (buf[0] && (buf[0] != '.') &&
-      detect_dcc_flood(&dcc[idx].timeval, dcc[idx].u.chat, idx))
-    return;
+  if (!buf[0]) return;
+  iscommand = (strchr(dcc_command_chars, buf[0]) != NULL);
+
+  /* If it's not a command, check for a flood, and abort if it is a flood. */
+  if (!iscommand && detect_dcc_flood(&dcc[idx].timeval, dcc[idx].u.chat, idx)) return;
+
   dcc[idx].timeval = now;
-  if (buf[0])
-    strcpy(buf, check_tcl_filt(idx, buf));
-  if (buf[0]) {
+
+  strcpy(buf, check_tcl_filt(idx, buf));
+
     /* Check for beeps and cancel annoying ones */
     v = buf;
     d = buf;
@@ -871,38 +893,34 @@
     else
       *d = 0;
 
-    if ((buf[0] == '.') || (dcc[idx].u.chat->channel < 0)) {
-	if (buf[0] == '.')
-	  buf++;
+    if (iscommand || (dcc[idx].u.chat->channel < 0)) {
+	if (iscommand) buf++;
 	v = newsplit(&buf);
 	rmspace(buf);
 	check_tcl_dcc(v, idx, buf);
-    } else if (buf[0] == ',') {
+    }
+    else if (buf[0] == ',') {
 	int me = 0;
 
 	if ((buf[1] == 'm') && (buf[2] == 'e') && buf[3] == ' ')
 	  me = 1;
 	for (i = 0; i < dcc_total; i++) {
-	  int ok = 0;
-
-	  if (dcc[i].type->flags & DCT_MASTER) {
-	    if ((dcc[i].type != &DCC_CHAT) ||
-		(dcc[i].u.chat->channel >= 0))
-	      if ((i != idx) || (dcc[idx].status & STAT_ECHO))
-		ok = 1;
-	  }
-	  if (ok) {
-	    struct userrec *u = get_user_by_handle(userlist, dcc[i].nick);
+	  struct userrec *u;
 
-	    if (u && (u->flags & USER_MASTER)) {
-	      if (me)
-		dprintf(i, "-> %s%s\n", dcc[idx].nick, buf + 3);
-	      else
-		dprintf(i, "-%s-> %s\n", dcc[idx].nick, buf + 1);
-	    }
+	  if (!(dcc[i].type->flags & DCT_MASTER) ||
+		(dcc[i].type != &DCC_CHAT) ||
+		(dcc[i].u.chat->channel < 0) ||
+		(i == idx && dcc[idx].status != STAT_ECHO)) continue;
+
+	  u = get_user_by_handle(userlist, dcc[i].nick);
+
+	  if (u && (u->flags & USER_MASTER)) {
+	    if (me) dprintf(i, "-> %s%s\n", dcc[idx].nick, buf + 3);
+	    else dprintf(i, "-%s-> %s\n", dcc[idx].nick, buf + 1);
 	  }
 	}
-    } else if (buf[0] == '\'') {
+    }
+    else if (buf[0] == '\'') {
 	int me = 0;
 
 	if ((buf[1] == 'm') && (buf[2] == 'e') &&
@@ -919,7 +937,7 @@
     } else {
 	int r;
 
-	r = check_tcl_chat(dcc[idx].user, dcc[idx].u.chat->channel, buf);
+	r = check_tcl_chat(dcc[idx].nick, dcc[idx].u.chat->channel, buf);
 	if (r & BIND_RET_BREAK) return;
 
 	if (dcc[idx].u.chat->away != NULL)
@@ -932,8 +950,7 @@
 		      dcc[idx].nick, buf);
 	botnet_send_chan(-1, botnetnick, dcc[idx].nick,
 			 dcc[idx].u.chat->channel, buf);
-      }
-  }
+    }
   if (dcc[idx].type == &DCC_CHAT)	/* Could have change to files */
     if (dcc[idx].status & STAT_PAGE)
       flush_lines(idx, dcc[idx].u.chat);
Index: eggdrop1.7/src/main.c
diff -u eggdrop1.7/src/main.c:1.93 eggdrop1.7/src/main.c:1.94
--- eggdrop1.7/src/main.c:1.93	Sat Oct 20 03:04:22 2001
+++ eggdrop1.7/src/main.c	Sun Oct 21 01:02:48 2001
@@ -5,7 +5,7 @@
  *   command line arguments
  *   context and assert debugging
  *
- * $Id: main.c,v 1.93 2001/10/20 08:04:22 guppy Exp $
+ * $Id: main.c,v 1.94 2001/10/21 06:02:48 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -590,7 +590,7 @@
 extern module_entry *module_list;
 void restart_chons();
 
-int init_dcc_max(), init_userent(), init_misc(), init_net(),
+int init_userent(), init_misc(), init_net(),
  init_modules(), init_tcl(int, char **);
 void timer_init();
 void logfile_init();
@@ -598,6 +598,7 @@
 void dns_init();
 void script_init();
 void binds_init();
+void dcc_init();
 
 void patch(const char *str)
 {
@@ -720,7 +721,7 @@
   dns_init();
   binds_init();
   core_binds_init();
-  init_dcc_max();
+  dcc_init();
   init_userent();
   init_misc();
   botnet_init();
Index: eggdrop1.7/src/mod/tclscript.mod/tclscript.c
diff -u eggdrop1.7/src/mod/tclscript.mod/tclscript.c:1.10 eggdrop1.7/src/mod/tclscript.mod/tclscript.c:1.11
--- eggdrop1.7/src/mod/tclscript.mod/tclscript.c:1.10	Sat Oct 20 22:44:31 2001
+++ eggdrop1.7/src/mod/tclscript.mod/tclscript.c	Sun Oct 21 01:02:48 2001
@@ -139,7 +139,7 @@
 	n = Tcl_EvalObjEx(cd->myinterp, final_command, TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
 	if (n == TCL_OK) {
 		result = Tcl_GetObjResult(cd->myinterp);
-		Tcl_GetIntFromObj(cd->myinterp, result, &retval);
+		Tcl_GetIntFromObj(NULL, result, &retval);
 	}
 	else {
 		FILE *fp;
Index: eggdrop1.7/src/tclhash.c
diff -u eggdrop1.7/src/tclhash.c:1.53 eggdrop1.7/src/tclhash.c:1.54
--- eggdrop1.7/src/tclhash.c:1.53	Sat Oct 20 22:49:33 2001
+++ eggdrop1.7/src/tclhash.c	Sun Oct 21 01:02:48 2001
@@ -7,7 +7,7 @@
  *   (non-Tcl) procedure lookups for msg/dcc/file commands
  *   (Tcl) binding internal procedures to msg/dcc/file commands
  *
- * $Id: tclhash.c,v 1.53 2001/10/21 03:49:33 stdarg Exp $
+ * $Id: tclhash.c,v 1.54 2001/10/21 06:02:48 stdarg Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -58,6 +58,12 @@
 static bind_table_t *BT_chjn;
 static bind_table_t *BT_filt;
 
+static char *global_filt_string; /* String for FILT binds to modify. */
+static script_str_t tclhash_script_strings[] = {
+	{"", "filt_string", &global_filt_string},
+	0
+};
+
 p_tcl_bind_list		bind_table_list;
 
 static int builtin_5int();
@@ -163,6 +169,8 @@
 void binds_init(void)
 {
 	bind_table_list_head = NULL;
+	malloc_strcpy(global_filt_string, "");
+	script_link_str_table(tclhash_script_strings);
 	script_create_simple_cmd_table(script_commands);
 	BT_link = add_bind_table2("link", 2, "ss", MATCH_MASK, BIND_STACKABLE);
 	BT_nkch = add_bind_table2("nkch", 2, "ss", MATCH_MASK, BIND_STACKABLE);
@@ -935,14 +943,9 @@
   struct flag_record	fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
 
   get_user_flagrec(dcc[idx].user, &fr, dcc[idx].u.chat->con_chan);
-  x = check_bind(BT_filt, text, &fr, dcc[idx].sock, text);
-  if (x == BIND_EXECUTED || x == BIND_EXEC_LOG) {
-    if (interp->result == NULL || !interp->result[0])
-      return "";
-    else
-      return interp->result;
-  } else
-    return text;
+  malloc_strcpy(global_filt_string, text);
+  x = check_bind(BT_filt, text, &fr, idx, text);
+  return(global_filt_string);
 }
 
 int check_tcl_note(const char *from, const char *to, const char *text)
----------------------- End of diff -----------------------



More information about the Changes mailing list