diff options
Diffstat (limited to 'message.c')
-rw-r--r-- | message.c | 32 |
1 files changed, 24 insertions, 8 deletions
@@ -270,7 +270,7 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int writereplayline(str, settings->basedir); } - // Get each channel the QUITting user was in, and log the quit from that channel + // Get each channel the QUITting user was in, and log the quit from that channel if enabled if (settings->logging) { char quitnick[MAXNICKLENGTH]; strcpy(quitnick, tokens[0]); @@ -475,11 +475,6 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int free(prefixcopy); } - // Update old nick to the new nick in our local channel struct - if (!updatenickinallchannels(tokens[0], tokens[2], channels)) { - debugprint(DEBUG_CRIT, "Failed to update old nick to new nick in channels.\n"); - } - // Relay to all clients sendtoallclients(clients, str, sourcefd, settings); @@ -488,8 +483,29 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int writereplayline(str, settings->basedir); } - // TODO - Is there a way to log nick changes to the normal log despite not tracking nicks in each channel? - // (We do track channel names themselves.) + // Get each channel the old nick was in, and log the NICK change in that channel if enabled + if (settings->logging) { + char oldnick[MAXNICKLENGTH]; + strcpy(oldnick, tokens[0]); + extractnickfromprefix(oldnick); + for (int i = 0; i < MAXCHANNELS; i++) { + if (channels[i].name[0]) { + for (int j = 0; j < MAXCHANNICKS; j++) { + if (strlen(channels[i].nicks[j]) == strlen(oldnick) && !strcmp(channels[i].nicks[j], oldnick)) { + char logstring[MAXDATASIZE]; + snprintf(logstring, MAXDATASIZE, "%s %s", channels[i].name, str); + logline(logstring, ircdstate, settings->basedir, LOG_NICK); + break; + } + } + } + } + } + + // Update old nick to the new nick in our local channel struct + if (!updatenickinallchannels(tokens[0], tokens[2], channels)) { + debugprint(DEBUG_CRIT, "Failed to update old nick to new nick in channels.\n"); + } free(svrprefixcopy); return 1; |