irssi-icb patch: misc bugs

Matt Dunford <[email protected]> Mon, 6 Jun 2005 15:40:54 -0700
Newsgroups gmane.network.irc.irssi.devel
Message-ID <[email protected]>
Hi,

I've fixed two bugs that have been annoying me in the icb plugin:
1) the name of the person beeping you doesn't appear.
2) "/nick newnick" changes your nick, but doesn't update the statusbar.

This patch is against the svn irssi-icb module:

Index: src/fe-common/module-formats.c
===================================================================
--- src/fe-common/module-formats.c	(revision 3757)
+++ src/fe-common/module-formats.c	(working copy)
@@ -30,7 +30,7 @@
 	{ "status", "[$0] $1", 2, { 0, 0 } },
 	{ "important", "[$0!] $1", 2, { 0, 0 } },
 	{ "status", "{error [Error]} $0", 1, { 0 } },
-	{ "beep", "[beep] $1 beeps you", 1, { 0 } },
+	{ "beep", "[beep] $0 beeps you", 1, { 0 } },
 
 	{ NULL, NULL, 0 }
 };
Index: src/fe-common/fe-icb.c
===================================================================
--- src/fe-common/fe-icb.c	(revision 3757)
+++ src/fe-common/fe-icb.c	(working copy)
@@ -24,6 +24,7 @@
 #include "commands.h"
 #include "servers-setup.h"
 #include "levels.h"
+#include "nicklist.h"
 
 #include "icb.h"
 #include "icb-servers.h"
@@ -36,12 +37,27 @@
 static void event_status(ICB_SERVER_REC *server, const char *data)
 {
 	char **args;
+	int len;
+	char *newnick;
 
 	/* FIXME: status messages should probably divided into their own
 	   signals so irssi could track joins, parts, etc. */
 	args = icb_split(data, 2);
 	printformat(server, server->group->name, MSGLEVEL_CRAP,
 		    ICBTXT_STATUS, args[0], args[1]);
+
+	len = strlen("Name");
+	if (strncmp(args[0],"Name",len) == 0) {
+
+		newnick = strrchr(args[1], ' ');
+		if (newnick != NULL) {
+			newnick++;  /* skip the space */
+
+			server_change_nick(SERVER(server), newnick);
+			nicklist_rename(SERVER(server), server->connrec->nick, newnick);
+		}
+	}
+
         icb_split_free(args);
 }