prevent nick collisions by only setting the nick after the server accepted it a… | |
git clone git://git.suckless.org/ii | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 1bc3e103c0cc59b32018c3680f8c97bad4191cce | |
parent 29ff454e808d0ccc8bc53a84d10e5b3df4e0aa5e | |
Author: Nico Golde <[email protected]> | |
Date: Wed, 4 Nov 2015 19:35:23 -0500 | |
prevent nick collisions by only setting the nick after the server accepted it a… | |
Diffstat: | |
M ii.c | 9 +++++++-- | |
1 file changed, 7 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/ii.c b/ii.c | |
@@ -38,6 +38,7 @@ static time_t last_response; | |
static Channel *channels = NULL; | |
static char *host = "irc.freenode.net"; | |
static char nick[32]; /* might change while running */ | |
+static char _nick[32]; /* might change while running */ | |
static char path[_POSIX_PATH_MAX]; | |
static char message[PIPE_BUF]; /* message buf used for communication */ | |
@@ -261,7 +262,7 @@ static void proc_channels_input(Channel *c, char *buf) { | |
break; | |
case 'n': | |
if(strlen(buf)>=3){ | |
- snprintf(nick, sizeof(nick),"%s", &buf[3]); | |
+ snprintf(_nick, sizeof(nick),"%s", &buf[3]); | |
snprintf(message, PIPE_BUF, "NICK %s\r\n", &bu… | |
} | |
break; | |
@@ -357,7 +358,11 @@ static void proc_server_cmd(char *buf) { | |
snprintf(message, PIPE_BUF, "-!- %s changed mode/%s -> %s %s",… | |
else if(!strncmp("QUIT", argv[TOK_CMD], 5)) | |
snprintf(message, PIPE_BUF, "-!- %s(%s) has quit \"%s\"", argv… | |
- else if(!strncmp("NICK", argv[TOK_CMD], 5)) | |
+ else if(!strncmp("NICK", argv[TOK_CMD], 5) && !strcmp(_nick, argv[TOK_… | |
+ snprintf(nick, sizeof(nick), "%s", _nick); | |
+ snprintf(message, PIPE_BUF, "-!- changed nick to \"%s\"", nick… | |
+ print_out(NULL, message); | |
+ } else if(!strncmp("NICK", argv[TOK_CMD], 5)) | |
snprintf(message, PIPE_BUF, "-!- %s changed nick to %s", argv[… | |
else if(!strncmp("TOPIC", argv[TOK_CMD], 6)) | |
snprintf(message, PIPE_BUF, "-!- %s changed topic to \"%s\"", … |