diff options
author | Luke Bratch <luke@bratch.co.uk> | 2019-09-15 15:11:55 +0100 |
---|---|---|
committer | Luke Bratch <luke@bratch.co.uk> | 2019-09-15 15:11:55 +0100 |
commit | aab7a7000cff14afe4cb331721ad55dc139f80c7 (patch) | |
tree | c6b5d7a9dd4d39fdc6dba08005267a209a3ec154 /message.c | |
parent | e9d4ad3c33b81ff56c4e4b2cac4aad559a303104 (diff) |
Log nick changes to the normal log file(s).
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; |