Hi,

I've fixed three 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.
3) "/topic newtopic" changes the topic, 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,15 +37,75 @@
 static void event_status(ICB_SERVER_REC *server, const char *data)
 {
        char **args;
+       int len;
+       char *newnick;
+       char *topic, *setby, *p1, *p2;
 
        /* 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);
+               }
+       }
+
+       /* sample topic msg: nick changed the topic to \"test 1\" */
+       len = strlen("Topic");
+       if (strncmp(args[0],"Topic",len) == 0) {
+               p1 = strchr(args[1], '"');
+               p2 = strrchr(args[1], '"');
+
+               /* make sure there's something between those quotes */
+               if (p1)
+               {
+                       p1++;
+                       topic = g_strdup(p1);
+                       p2 = strrchr(topic, '"');
+                       *p2 = '\0';
+
+                       setby = g_strdup(args[1]);
+                       p2 = strchr(setby, ' ');
+                       *p2 = '\0';
+
+                       icb_channel_change_topic(server, topic, setby, 
time(NULL));
+
+                       g_free(topic);
+                       g_free(setby);
+               }
+       }
+
         icb_split_free(args);
 }
 
+static void icb_channel_change_topic(ICB_SERVER_REC *server, 
+                                const char *topic, const char *setby,
+                                time_t settime)
+{
+       if (topic != NULL) {
+               g_free_not_null(server->group->topic);
+               server->group->topic = g_strdup(topic);
+       }
+
+       if (setby != NULL) {
+               g_free_not_null(server->group->topic_by);
+               server->group->topic_by = g_strdup(setby);
+       }
+       
+       server->group->topic_time = settime;
+
+       signal_emit("channel topic changed", 1, server->group);
+}
+
 static void event_error(ICB_SERVER_REC *server, const char *data)
 {
        printformat(server, NULL, MSGLEVEL_CRAP, ICBTXT_ERROR, data);

Reply via email to