[cvslog] (2008-10-17 15:57:53 UTC) Module eggdrop1.9: Change committed!

cvslog cvs at tsss.org
Fri Oct 17 09:57:53 CST 2008


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.9
Commit time: 2008-10-17 15:57:53 UTC
Commited by: sven

Modified files:
     modules/pythonscript/pythonscript.c modules/script/scriptconfig.c
     modules/script/scriptdns.c modules/script/scriptmod.c
     modules/script/scriptnet.c modules/script/scriptuser.c
     modules/server/channel_events.c modules/server/channels.c
     modules/server/party_commands.c

Log message:

 * Tried to use scripting namespaces, let's see if that works.
 * Fixed IRC MODE parsing. The bot keeps track of all modes set on all
   channels.
 * .channel on the partyline now works like in eggdrop1.6.

---------------------- diff included ----------------------
Index: eggdrop1.9/modules/pythonscript/pythonscript.c
diff -u eggdrop1.9/modules/pythonscript/pythonscript.c:1.5 eggdrop1.9/modules/pythonscript/pythonscript.c:1.6
--- eggdrop1.9/modules/pythonscript/pythonscript.c:1.5	Sat Jan 13 06:23:40 2007
+++ eggdrop1.9/modules/pythonscript/pythonscript.c	Fri Oct 17 10:57:42 2008
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: pythonscript.c,v 1.5 2007-01-13 12:23:40 sven Exp $";
+static const char rcsid[] = "$Id: pythonscript.c,v 1.6 2008-10-17 15:57:42 sven Exp $";
 #endif
 
 #include <Python.h>
@@ -110,6 +110,7 @@
 /* This function creates the Python <-> C variable linkage on reads, writes, and dels. */
 static int my_link_var(void *ignore, script_linked_var_t *var) {
 	CallableObject *O;
+	char *cmdname;
 
 	O = PyObject_New(CallableObject, &Callable_Type);       /* new reference */
 	if (!O) {
@@ -118,9 +119,16 @@
 		return -1;
 	}
 
+	if (var->class && strlen(var->class)) {
+		cmdname = egg_mprintf("%s_%s", var->class, var->name);
+	}
+	else {
+		cmdname = strdup(var->name);
+	}
 	O->type = PYTHON_VAR;
 	O->client_data = var;
-	PyModule_AddObject(EggdropModule, var->name, (PyObject *) O); /* EggdropModule steals a reference to O */
+	PyModule_AddObject(EggdropModule, cmdname, (PyObject *) O); /* EggdropModule steals a reference to O */
+	free(cmdname);
 	return 0;
 }
 
@@ -201,15 +209,24 @@
 
 /* Create Python commands with a C callback. */
 static int my_create_command(void *ignore, script_raw_command_t *info) {
+	char *cmdname;
 	CallableObject *O = PyObject_New(CallableObject, &Callable_Type);
 
+	if (info->class && strlen(info->class)) {
+		cmdname = egg_mprintf("%s_%s", info->class, info->name);
+	}
+	else {
+		cmdname = strdup(info->name);
+	}
 	O->type = PYTHON_FUNC;
 	O->client_data = info;
-	if (PyModule_AddObject(EggdropModule, info->name, (PyObject *)O)) {
+	if (PyModule_AddObject(EggdropModule, cmdname, (PyObject *)O)) {
+		free(cmdname);
 		PyErr_Print();
 		FlushAll();
 		return 1;
 	}
+	free(cmdname);
 	return 0;
 }
 
Index: eggdrop1.9/modules/script/scriptconfig.c
diff -u eggdrop1.9/modules/script/scriptconfig.c:1.10 eggdrop1.9/modules/script/scriptconfig.c:1.11
--- eggdrop1.9/modules/script/scriptconfig.c:1.10	Thu Dec  1 15:22:11 2005
+++ eggdrop1.9/modules/script/scriptconfig.c	Fri Oct 17 10:57:43 2008
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: scriptconfig.c,v 1.10 2005-12-01 21:22:11 stdarg Exp $";
+static const char rcsid[] = "$Id: scriptconfig.c,v 1.11 2008-10-17 15:57:43 sven Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -111,10 +111,10 @@
 }
 
 script_command_t script_config_cmds[] = {
-	{"", "config_exists", script_config_exists, NULL, 1, "ss", "?handle? path", SCRIPT_INTEGER, SCRIPT_VAR_ARGS|SCRIPT_VAR_FRONT},	/* DDD */
-	{"", "config_get", script_config_get, NULL, 1, "ss", "?handle? path", SCRIPT_STRING, SCRIPT_VAR_ARGS|SCRIPT_VAR_FRONT}, /* DDD */
-	{"", "config_set", script_config_set, NULL, 2, "sss", "?handle? path value", SCRIPT_INTEGER, SCRIPT_VAR_ARGS|SCRIPT_VAR_FRONT}, /* DDD */
-	{"", "config_load", script_config_load, NULL, 2, "ss", "handle filename", SCRIPT_INTEGER, 0}, /* DDD */
-	{"", "config_save", config_save, NULL, 2, "ss", "handle filename", SCRIPT_INTEGER, 0}, /* DDD */
+	{"config", "exists", script_config_exists, NULL, 1, "ss", "?handle? path", SCRIPT_INTEGER, SCRIPT_VAR_ARGS|SCRIPT_VAR_FRONT},	/* DDD */
+	{"config", "get", script_config_get, NULL, 1, "ss", "?handle? path", SCRIPT_STRING, SCRIPT_VAR_ARGS|SCRIPT_VAR_FRONT}, /* DDD */
+	{"config", "set", script_config_set, NULL, 2, "sss", "?handle? path value", SCRIPT_INTEGER, SCRIPT_VAR_ARGS|SCRIPT_VAR_FRONT}, /* DDD */
+	{"config", "load", script_config_load, NULL, 2, "ss", "handle filename", SCRIPT_INTEGER, 0}, /* DDD */
+	{"config", "save", config_save, NULL, 2, "ss", "handle filename", SCRIPT_INTEGER, 0}, /* DDD */
 	{0}
 };
Index: eggdrop1.9/modules/script/scriptdns.c
diff -u eggdrop1.9/modules/script/scriptdns.c:1.2 eggdrop1.9/modules/script/scriptdns.c:1.3
--- eggdrop1.9/modules/script/scriptdns.c:1.2	Mon Sep 11 20:50:51 2006
+++ eggdrop1.9/modules/script/scriptdns.c	Fri Oct 17 10:57:43 2008
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: scriptdns.c,v 1.2 2006-09-12 01:50:51 sven Exp $";
+static const char rcsid[] = "$Id: scriptdns.c,v 1.3 2008-10-17 15:57:43 sven Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -35,8 +35,8 @@
 }
 
 script_command_t script_dns_cmds[] = {
-	{"", "dns_lookup", script_dns_lookup, NULL, 2, "scsi", "host callback ?callbackdata? ?len?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
-	{"", "dns_reverse", script_dns_reverse, NULL, 2, "scsi", "ip  callback ?callbackdata? ?len?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
-	{"", "dns_cancel", egg_dns_cancel, NULL, 1, "ii", "id ?docallback?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
+	{"dns", "lookup", script_dns_lookup, NULL, 2, "scsi", "host callback ?callbackdata? ?len?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
+	{"dns", "reverse", script_dns_reverse, NULL, 2, "scsi", "ip  callback ?callbackdata? ?len?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
+	{"dns", "cancel", egg_dns_cancel, NULL, 1, "ii", "id ?docallback?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
 	{0}
 };
Index: eggdrop1.9/modules/script/scriptmod.c
diff -u eggdrop1.9/modules/script/scriptmod.c:1.15 eggdrop1.9/modules/script/scriptmod.c:1.16
--- eggdrop1.9/modules/script/scriptmod.c:1.15	Thu Sep 13 17:20:57 2007
+++ eggdrop1.9/modules/script/scriptmod.c	Fri Oct 17 10:57:43 2008
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: scriptmod.c,v 1.15 2007-09-13 22:20:57 sven Exp $";
+static const char rcsid[] = "$Id: scriptmod.c,v 1.16 2008-10-17 15:57:43 sven Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -33,10 +33,10 @@
 }
 
 static script_command_t script_mod_cmds[] = {
-	{"", "module_load", (Function) module_load, NULL, 1, "s", "name", SCRIPT_INTEGER, 0},	/* DDD */
-	{"", "module_unload", (Function) script_module_unload, NULL, 1, "s", "name", SCRIPT_INTEGER, 0},	/* DDD */
-	{"", "module_add_dir", (Function) module_add_dir, NULL, 1, "s", "dir", SCRIPT_INTEGER, 0},	/* DDD */
-	{"", "module_loaded", (Function) module_loaded, NULL, 1, "s", "name", SCRIPT_INTEGER, 0},	/* DDD */
+	{"module", "load", (Function) module_load, NULL, 1, "s", "name", SCRIPT_INTEGER, 0},	/* DDD */
+	{"module", "unload", (Function) script_module_unload, NULL, 1, "s", "name", SCRIPT_INTEGER, 0},	/* DDD */
+	{"module", "add_dir", (Function) module_add_dir, NULL, 1, "s", "dir", SCRIPT_INTEGER, 0},	/* DDD */
+	{"module", "loaded", (Function) module_loaded, NULL, 1, "s", "name", SCRIPT_INTEGER, 0},	/* DDD */
 	{0}
 };
 
Index: eggdrop1.9/modules/script/scriptnet.c
diff -u eggdrop1.9/modules/script/scriptnet.c:1.12 eggdrop1.9/modules/script/scriptnet.c:1.13
--- eggdrop1.9/modules/script/scriptnet.c:1.12	Thu Sep 13 17:20:57 2007
+++ eggdrop1.9/modules/script/scriptnet.c	Fri Oct 17 10:57:43 2008
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: scriptnet.c,v 1.12 2007-09-13 22:20:57 sven Exp $";
+static const char rcsid[] = "$Id: scriptnet.c,v 1.13 2008-10-17 15:57:43 sven Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -346,17 +346,17 @@
 }
 
 script_command_t script_net_cmds[] = {
-	{"", "net_takeover", script_net_takeover, NULL, 1, "i", "idx", SCRIPT_INTEGER, 0},	/* DDD */
-	{"", "net_listen", script_net_listen, NULL, 1, "i", "port", 0, SCRIPT_PASS_RETVAL},	/* DDD */
-	{"", "net_open", script_net_open, NULL, 2, "sii", "host port ?timeout?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
-	{"", "net_close", script_net_close, NULL, 1, "i", "idx", SCRIPT_INTEGER, 0},	/* DDD */
-	{"", "net_write", script_net_write, NULL, 2, "isi", "idx text ?len?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
-	{"", "net_handler", script_net_handler, NULL, 2, "isc", "idx event callback", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
-	{"", "net_linemode", script_net_linemode, NULL, 1, "ii", "idx ?on-off?", SCRIPT_INTEGER, SCRIPT_PASS_COUNT | SCRIPT_VAR_ARGS},	/* DDD */
-	{"", "net_info", script_net_info, NULL, 2, "is", "idx what", 0, SCRIPT_PASS_RETVAL},	/* DDD */
-	{"", "net_throttle", script_net_throttle, NULL, 3, "iii", "idx speed-in speed-out", SCRIPT_INTEGER, 0},	/* DDD */
-	{"", "net_throttle_in", script_net_throttle_set, (void *)0, 2, "ii", "idx speed", SCRIPT_INTEGER, SCRIPT_PASS_CDATA},	/* DDD */
-	{"", "net_throttle_out", script_net_throttle_set, (void *)1, 2, "ii", "idx speed", SCRIPT_INTEGER, SCRIPT_PASS_CDATA},	/* DDD */
-	{"", "net_throttle_off", throttle_off, NULL, 1, "i", "idx", SCRIPT_INTEGER, 0},	/* DDD */
+	{"net", "takeover", script_net_takeover, NULL, 1, "i", "idx", SCRIPT_INTEGER, 0},	/* DDD */
+	{"net", "listen", script_net_listen, NULL, 1, "i", "port", 0, SCRIPT_PASS_RETVAL},	/* DDD */
+	{"net", "open", script_net_open, NULL, 2, "sii", "host port ?timeout?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
+	{"net", "close", script_net_close, NULL, 1, "i", "idx", SCRIPT_INTEGER, 0},	/* DDD */
+	{"net", "write", script_net_write, NULL, 2, "isi", "idx text ?len?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
+	{"net", "handler", script_net_handler, NULL, 2, "isc", "idx event callback", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
+	{"net", "linemode", script_net_linemode, NULL, 1, "ii", "idx ?on-off?", SCRIPT_INTEGER, SCRIPT_PASS_COUNT | SCRIPT_VAR_ARGS},	/* DDD */
+	{"net", "info", script_net_info, NULL, 2, "is", "idx what", 0, SCRIPT_PASS_RETVAL},	/* DDD */
+	{"net", "throttle", script_net_throttle, NULL, 3, "iii", "idx speed-in speed-out", SCRIPT_INTEGER, 0},	/* DDD */
+	{"net", "throttle_in", script_net_throttle_set, (void *)0, 2, "ii", "idx speed", SCRIPT_INTEGER, SCRIPT_PASS_CDATA},	/* DDD */
+	{"net", "throttle_out", script_net_throttle_set, (void *)1, 2, "ii", "idx speed", SCRIPT_INTEGER, SCRIPT_PASS_CDATA},	/* DDD */
+	{"net", "throttle_off", throttle_off, NULL, 1, "i", "idx", SCRIPT_INTEGER, 0},	/* DDD */
 	{0}
 };
Index: eggdrop1.9/modules/script/scriptuser.c
diff -u eggdrop1.9/modules/script/scriptuser.c:1.12 eggdrop1.9/modules/script/scriptuser.c:1.13
--- eggdrop1.9/modules/script/scriptuser.c:1.12	Thu Dec  1 15:22:11 2005
+++ eggdrop1.9/modules/script/scriptuser.c	Fri Oct 17 10:57:43 2008
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: scriptuser.c,v 1.12 2005-12-01 21:22:11 stdarg Exp $";
+static const char rcsid[] = "$Id: scriptuser.c,v 1.13 2008-10-17 15:57:43 sven Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -160,26 +160,26 @@
 }
 
 script_command_t script_new_user_cmds[] = {
-	{"", "user_uid_to_handle", script_uid_to_handle, NULL, 1, "i", "uid", SCRIPT_STRING, 0},	/* DDD */
-	{"", "user_handle_to_uid", script_handle_to_uid, NULL, 1, "U", "handle", SCRIPT_INTEGER, 0},	/* DDD */
-	{"", "user_validhandle", script_validhandle, NULL, 1, "s", "handle", SCRIPT_INTEGER, 0},	/* DDD */
-	{"", "user_validuid", script_validuid, NULL, 1, "i", "uid", SCRIPT_INTEGER, 0},			/* DDD */
-	{"", "user_add", script_adduser, NULL, 1, "s", "handle", SCRIPT_INTEGER, 0},			/* DDD */
-	{"", "user_delete", user_delete, NULL, 1, "U", "user", SCRIPT_INTEGER, 0},			/* DDD */
-	{"", "user_addmask", user_add_ircmask, NULL, 2, "Us", "user ircmask", SCRIPT_INTEGER, 0},	/* DDD */
-	{"", "user_getmasks", script_get_ircmasks, NULL, 1, "U", "user", 0, SCRIPT_PASS_RETVAL},	/* DDD */
-	{"", "user_delmask", user_del_ircmask, NULL, 2, "Us", "user ircmask", SCRIPT_INTEGER, 0},	/* DDD */
-	{"", "user_find", script_user_find, NULL, 1, "s", "irchost", SCRIPT_STRING, 0},			/* DDD */
-	{"", "user_get", script_user_get, NULL, 2, "Uss", "user ?channel? setting", SCRIPT_STRING, SCRIPT_VAR_ARGS | SCRIPT_PASS_COUNT},	/* DDD */
-	{"", "user_set", script_user_set, NULL, 3, "Usss", "user ?channel? setting value", SCRIPT_INTEGER, SCRIPT_VAR_ARGS | SCRIPT_PASS_COUNT},	/* DDD */
-	{"", "user_getflags", script_getflags, NULL, 1, "Us", "user ?chan?", SCRIPT_STRING | SCRIPT_FREE, SCRIPT_VAR_ARGS},	/* DDD */
-	{"", "user_setflags", script_setflags, NULL, 2, "Uss", "user ?chan? flags", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
-	{"", "user_matchflags", script_matchflags, 0, 2, "Uss", "user ?chan? flags", SCRIPT_INTEGER, SCRIPT_VAR_ARGS | SCRIPT_PASS_CDATA},	/* DDD */
-	{"", "user_matchflags_or", script_matchflags, (void *)1, 2, "Uss", "user ?chan? flags", SCRIPT_INTEGER, SCRIPT_VAR_ARGS | SCRIPT_PASS_CDATA},	/* DDD */
-	{"", "user_load", user_save, NULL, 0, "s", "?fname?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
-	{"", "user_save", script_user_save, NULL, 0, "s", "?fname?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
-	{"", "user_haspass", user_has_pass, NULL, 1, "U", "user", SCRIPT_INTEGER, 0},	/* DDD */
-	{"", "user_checkpass", user_check_pass, NULL, 2, "Us", "user pass", SCRIPT_INTEGER, 0},	/* DDD */
-	{"", "user_setpass", user_set_pass, NULL, 2, "Us", "user pass", SCRIPT_INTEGER, 0},	/* DDD */
+	{"user", "uid_to_handle", script_uid_to_handle, NULL, 1, "i", "uid", SCRIPT_STRING, 0},	/* DDD */
+	{"user", "handle_to_uid", script_handle_to_uid, NULL, 1, "U", "handle", SCRIPT_INTEGER, 0},	/* DDD */
+	{"user", "validhandle", script_validhandle, NULL, 1, "s", "handle", SCRIPT_INTEGER, 0},	/* DDD */
+	{"user", "validuid", script_validuid, NULL, 1, "i", "uid", SCRIPT_INTEGER, 0},			/* DDD */
+	{"user", "add", script_adduser, NULL, 1, "s", "handle", SCRIPT_INTEGER, 0},			/* DDD */
+	{"user", "delete", user_delete, NULL, 1, "U", "user", SCRIPT_INTEGER, 0},			/* DDD */
+	{"user", "addmask", user_add_ircmask, NULL, 2, "Us", "user ircmask", SCRIPT_INTEGER, 0},	/* DDD */
+	{"user", "getmasks", script_get_ircmasks, NULL, 1, "U", "user", 0, SCRIPT_PASS_RETVAL},	/* DDD */
+	{"user", "delmask", user_del_ircmask, NULL, 2, "Us", "user ircmask", SCRIPT_INTEGER, 0},	/* DDD */
+	{"user", "find", script_user_find, NULL, 1, "s", "irchost", SCRIPT_STRING, 0},			/* DDD */
+	{"user", "get", script_user_get, NULL, 2, "Uss", "user ?channel? setting", SCRIPT_STRING, SCRIPT_VAR_ARGS | SCRIPT_PASS_COUNT},	/* DDD */
+	{"user", "set", script_user_set, NULL, 3, "Usss", "user ?channel? setting value", SCRIPT_INTEGER, SCRIPT_VAR_ARGS | SCRIPT_PASS_COUNT},	/* DDD */
+	{"user", "getflags", script_getflags, NULL, 1, "Us", "user ?chan?", SCRIPT_STRING | SCRIPT_FREE, SCRIPT_VAR_ARGS},	/* DDD */
+	{"user", "setflags", script_setflags, NULL, 2, "Uss", "user ?chan? flags", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
+	{"user", "matchflags", script_matchflags, 0, 2, "Uss", "user ?chan? flags", SCRIPT_INTEGER, SCRIPT_VAR_ARGS | SCRIPT_PASS_CDATA},	/* DDD */
+	{"user", "matchflags_or", script_matchflags, (void *)1, 2, "Uss", "user ?chan? flags", SCRIPT_INTEGER, SCRIPT_VAR_ARGS | SCRIPT_PASS_CDATA},	/* DDD */
+	{"user", "load", user_save, NULL, 0, "s", "?fname?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
+	{"user", "save", script_user_save, NULL, 0, "s", "?fname?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},	/* DDD */
+	{"user", "haspass", user_has_pass, NULL, 1, "U", "user", SCRIPT_INTEGER, 0},	/* DDD */
+	{"user", "checkpass", user_check_pass, NULL, 2, "Us", "user pass", SCRIPT_INTEGER, 0},	/* DDD */
+	{"user", "setpass", user_set_pass, NULL, 2, "Us", "user pass", SCRIPT_INTEGER, 0},	/* DDD */
 	{0}
 };
Index: eggdrop1.9/modules/server/channel_events.c
diff -u eggdrop1.9/modules/server/channel_events.c:1.5 eggdrop1.9/modules/server/channel_events.c:1.6
--- eggdrop1.9/modules/server/channel_events.c:1.5	Wed Dec 28 11:27:31 2005
+++ eggdrop1.9/modules/server/channel_events.c	Fri Oct 17 10:57:43 2008
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: channel_events.c,v 1.5 2005-12-28 17:27:31 sven Exp $";
+static const char rcsid[] = "$Id: channel_events.c,v 1.6 2008-10-17 15:57:43 sven Exp $";
  #endif
 
 #include "server.h"
@@ -560,8 +560,8 @@
 		else if (strchr(current_server.type2modes, *change)) {
 			hasarg = 1;
 		}
-		else if (changestr[0] == '+' && strchr(current_server.type3modes, *change)) {
-			hasarg = 1;
+		else if (strchr(current_server.type3modes, *change)) {
+			if (changestr[0] == '+') hasarg = 1;
 		}
 		else {
 			modify_channel = 1;
@@ -579,6 +579,7 @@
 		if (modify_member) {
 			/* Find the person it modifies and apply. */
 			m = channel_lookup_member(chan, arg);
+			flag_merge_str(&m->mode, changestr);
 		}
 		else if (modify_channel) {
 			/* Simple flag change for channel. */
Index: eggdrop1.9/modules/server/channels.c
diff -u eggdrop1.9/modules/server/channels.c:1.39 eggdrop1.9/modules/server/channels.c:1.40
--- eggdrop1.9/modules/server/channels.c:1.39	Mon Aug 28 21:15:55 2006
+++ eggdrop1.9/modules/server/channels.c	Fri Oct 17 10:57:43 2008
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: channels.c,v 1.39 2006-08-29 02:15:55 sven Exp $";
+static const char rcsid[] = "$Id: channels.c,v 1.40 2008-10-17 15:57:43 sven Exp $";
  #endif
 
 #include "server.h"
@@ -123,12 +123,17 @@
 channel_mode_arg_t *channel_get_arg(channel_t *chan, int type)
 {
 	int i;
+	char *c;
+	channel_mode_arg_t *arg;
 
-	if (!chan->args && current_server.type2modes) {
-		chan->nargs = strlen(current_server.type2modes);
+	if (!chan->args && (current_server.type2modes || current_server.type3modes)) {
+		chan->nargs = strlen(current_server.type2modes) + strlen(current_server.type3modes);
 		chan->args = calloc(chan->nargs, sizeof(*chan->args));
-		for (i = 0; i < chan->nargs; i++) {
-			chan->args[i].type = current_server.type2modes[i];
+		for (arg = chan->args, c = current_server.type2modes; *c; arg++, c++) {
+			arg->type = *c;
+		}
+		for (c = current_server.type3modes; *c; arg++, c++) {
+			arg->type = *c;
 		}
 	}
 	for (i = 0; i < chan->nargs; i++) {
Index: eggdrop1.9/modules/server/party_commands.c
diff -u eggdrop1.9/modules/server/party_commands.c:1.27 eggdrop1.9/modules/server/party_commands.c:1.28
--- eggdrop1.9/modules/server/party_commands.c:1.27	Mon Aug 28 21:15:55 2006
+++ eggdrop1.9/modules/server/party_commands.c	Fri Oct 17 10:57:43 2008
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: party_commands.c,v 1.27 2006-08-29 02:15:55 sven Exp $";
+static const char rcsid[] = "$Id: party_commands.c,v 1.28 2008-10-17 15:57:43 sven Exp $";
 #endif
 
 #include "server.h"
@@ -352,20 +352,88 @@
 	return(BIND_RET_LOG);
 }
 
+static int channel_get_modes(channel_t *chan, char *buf, int maxlen)
+{
+	int i, len, l;
+
+	flag_to_str(&chan->mode, buf);
+	len = strlen(buf);
+	for (i = 0; i < chan->nargs; ++i) {
+		if (!chan->args[i].value) continue;
+		buf[len++] = chan->args[i].type;
+		if (len + 1 > maxlen) {
+			buf[len] = 0;
+			return 1;
+		}
+	}
+	buf[len] = 0;
+	for (i = 0; i < chan->nargs; ++i) {
+		if (!chan->args[i].value) continue;
+		l = strlen(chan->args[i].value);
+		if (len + 2 + l > maxlen) return 1;
+		buf[len++] = ' ';
+		strcpy(buf + len, chan->args[i].value);
+		len += l;
+	}
+	return 0;
+}
+
+static char channel_get_prefix(channel_member_t *m)
+{
+	int i, len;
+	char buf[256];
+
+	flag_to_str(&m->mode, buf);
+	len = strlen(current_server.modeprefix);
+	for (i = 0; i < len; ++i) {
+		if (strchr(buf, current_server.modeprefix[i])) return current_server.whoprefix[i];
+	}
+	return ' ';
+}
+
 /* channels */
 static int party_channels(partymember_t *p, const char *nick, user_t *u, const char *cmd, const char *text)
 {
+	char buf[512];
+	user_t *user;
 	channel_t *chan;
+	channel_member_t *m;
 
-	if (nchannels <= 0) {
-		partymember_printf(p, _("The channel list is empty."));
-		return(BIND_RET_LOG);
+	if ( !text || !*text) {
+		if (nchannels <= 0) {
+			partymember_printf(p, _("The channel list is empty."));
+			return BIND_RET_LOG;
+		}
+
+		for (chan = channel_head; chan; chan = chan->next) {
+			partymember_printf(p, "   %s : %d member%s", chan->name, chan->nmembers, chan->nmembers == 1 ? "" : "s");
+		}
+		return BIND_RET_LOG;
 	}
 
-	for (chan = channel_head; chan; chan = chan->next) {
-		partymember_printf(p, "   %s : %d member%s", chan->name, chan->nmembers, chan->nmembers == 1 ? "" : "s");
+	chan = channel_probe(text, 0);
+	if (!chan) {
+		partymember_printf(p, "Channel not found!");
+		return 0;
 	}
-	return(BIND_RET_LOG);
+
+	if (!chan->nmembers) {
+		partymember_printf(p, "Not in channel.");
+		return 0;
+	}
+
+	channel_get_modes(chan, buf, 512);
+	partymember_printf(p, "Channel %s, %d member%s, mode +%s:", chan->name, chan->nmembers, chan->nmembers == 1 ? "" : "s", buf);
+	partymember_printf(p, "Channel Topic: %s", chan->topic);
+	partymember_printf(p, "(n = owner, m = master, o = op, d = deop, b = bot)");
+	partymember_printf(p, " NICKNAME        HANDLE          JOIN  IDLE  USER at HOST");
+	for (m = chan->member_head; m; m = m->next) {
+		snprintf(buf, 512, "%s!%s", m->nick, m->uhost);
+		user = user_lookup_by_irchost(buf);
+		partymember_printf(p, "%c%-15s %-15s %-5s %-5s %s", channel_get_prefix(m), m->nick, user ? user->handle : "*", "N/A", "N/A", m->uhost);
+	}
+	partymember_printf(p, "End of channel info.");
+	return BIND_RET_LOG;
 }
 
 /* chanset <channel / *> <setting> [data] */
----------------------- End of diff -----------------------



More information about the Changes mailing list