summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorailin-nemui <ailin-nemui@users.noreply.github.com>2018-01-07 11:23:42 +0100
committerGitHub <noreply@github.com>2018-01-07 11:23:42 +0100
commite7cce90ec07d2a65d2f5aa561c30b464a88f646f (patch)
tree81bb042e21761a2b74309b7de83ec51a7956c8fa
parente75ee2f74cd8b3de2f28e7b9b8e8b3da90f5c608 (diff)
parent3c7185c5ad61de24f9d1bc39240c8145665fba44 (diff)
downloadirssi-e7cce90ec07d2a65d2f5aa561c30b464a88f646f.zip
Merge pull request #804 from ailin-nemui/patch-1
handle an already used nick different from the one we send
-rw-r--r--src/irc/core/irc-nicklist.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/irc/core/irc-nicklist.c b/src/irc/core/irc-nicklist.c
index 1cb1f3e9..3e16db80 100644
--- a/src/irc/core/irc-nicklist.c
+++ b/src/irc/core/irc-nicklist.c
@@ -323,8 +323,9 @@ static void event_nick_invalid(IRC_SERVER_REC *server, const char *data)
static void event_nick_in_use(IRC_SERVER_REC *server, const char *data)
{
- char *str, *cmd;
+ char *str, *cmd, *params, *nick;
int n;
+ gboolean try_alternate_nick;
g_return_if_fail(data != NULL);
@@ -332,11 +333,21 @@ static void event_nick_in_use(IRC_SERVER_REC *server, const char *data)
/* Already connected, no need to handle this anymore. */
return;
}
+
+ try_alternate_nick = g_ascii_strcasecmp(server->nick, server->connrec->nick) == 0 &&
+ server->connrec->alternate_nick != NULL &&
+ g_ascii_strcasecmp(server->connrec->alternate_nick, server->nick) != 0;
+
+ params = event_get_params(data, 2, NULL, &nick);
+ if (g_ascii_strcasecmp(server->nick, nick) != 0) {
+ /* the server uses a nick different from the one we send */
+ g_free(server->nick);
+ server->nick = g_strdup(nick);
+ }
+ g_free(params);
/* nick already in use - need to change it .. */
- if (g_ascii_strcasecmp(server->nick, server->connrec->nick) == 0 &&
- server->connrec->alternate_nick != NULL &&
- g_ascii_strcasecmp(server->connrec->alternate_nick, server->nick) != 0) {
+ if (try_alternate_nick) {
/* first try, so try the alternative nick.. */
g_free(server->nick);
server->nick = g_strdup(server->connrec->alternate_nick);