summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--blabouncer.c45
-rw-r--r--logging.c2
-rw-r--r--logging.h2
4 files changed, 49 insertions, 2 deletions
diff --git a/TODO b/TODO
index 7e6fb96..4fce189 100644
--- a/TODO
+++ b/TODO
@@ -10,5 +10,3 @@ Might need to #include <limits.h> in blabouncer.c to make some operating systems
Send a PING to the server before assuming a timeout is definite.
Implement daemon (background) mode.
-
-Include NOTICEs in the replay log.
diff --git a/blabouncer.c b/blabouncer.c
index e5f1723..8a718df 100644
--- a/blabouncer.c
+++ b/blabouncer.c
@@ -1479,6 +1479,32 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli
// We didn't handle it
debugprint("Unhandled server CAP response.\n");
}
+
+ // Server NOTICE received? Handle and log if it's from a user, otherwise let pass through to default handler.
+ if (strncmp(tokens[1], "NOTICE", strlen(tokens[1])) == 0) {
+ debugprint("Server NOTICE found and it is: %s with length %zd! Analysing...\n", tokens[1], strlen(tokens[1]));
+ // If the first token is a nick!user@host then it's probably from a user
+ if (strstr(tokens[0], "!") != NULL && strstr(tokens[0], "@") != NULL) {
+ debugprint("Server NOTICE appears to be from a user, sending to all clients and logging.\n");
+
+ sendtoallclients(clients, str, 0, settings);
+
+ // Write to replay log if replay logging enabled
+ if (settings->replaylogging) {
+ writereplayline(str, settings->basedir);
+ }
+
+ // Write to normal log if logging enabled
+ if (settings->logging) {
+ logline(str, settings->ircnick, settings->basedir, LOG_PRIVMSG);
+ }
+
+ free(strcopyPtr);
+ return 1;
+ } else {
+ debugprint("Server NOTICE does not appear to be from a user, passing through.\n");
+ }
+ }
}
// Don't return if we got here because this means we didn't process something above
@@ -1877,6 +1903,25 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli
// Client NOTICE received
if (strncasecmp(tokens[0], "NOTICE", strlen(tokens[0])) == 0) {
+
+ // Rebuild to full NOTICE string including our nick!user@host for logging
+ char fullmsg[MAXDATASIZE];
+
+ if (!snprintf(fullmsg, MAXDATASIZE, "%s %s", ircdstrings->nickuserhost, str)) {
+ fprintf(stderr, "Error while preparing NOTICE string for logging.\n");
+ exit(1);
+ }
+
+ // Write to replay log if replay logging enabled
+ if (settings->replaylogging) {
+ writereplayline(fullmsg, settings->basedir);
+ }
+
+ // Write to normal log if logging enabled
+ if (settings->logging) {
+ logline(fullmsg, settings->ircnick, settings->basedir, LOG_PRIVMSG);
+ }
+
// If it's a CTCP VERSION response then only send to the server (CTCP requests are delimited with \1)
if (counter >= 3 && strncmp(tokens[2], ":\1VERSION", strlen(tokens[2])) == 0) {
debugprint("Client NOTICE looked like a CTCP VERSION response, so just sending to the server.\n");
diff --git a/logging.c b/logging.c
index 944dc91..23e2170 100644
--- a/logging.c
+++ b/logging.c
@@ -10,6 +10,8 @@
// If LOG_PRIVMSG then it expects a string in the format:
// :from!bar@baz PRIVMSG to :hello world
//
+// LOG_PRIVMSG is also used for NOTICEs.
+//
// If LOG_JOINPART then it expects a string in the format:
// :nick!bar@baz JOIN :#channel
// or
diff --git a/logging.h b/logging.h
index 012d239..e998773 100644
--- a/logging.h
+++ b/logging.h
@@ -30,6 +30,8 @@
// If LOG_PRIVMSG then it expects a string in the format:
// :from!bar@baz PRIVMSG to :hello world
//
+// LOG_PRIVMSG is also used for NOTICEs.
+//
// If LOG_JOINPART then it expects a string in the format:
// :nick!bar@baz JOIN :#channel
// or