diff options
Diffstat (limited to 'blabouncer.c')
-rw-r--r-- | blabouncer.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/blabouncer.c b/blabouncer.c index 2e1f414..29b90ae 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -514,7 +514,7 @@ int processircmessage(int *serversockfd, int *clientsockfd, char *str, int sourc } } - // Server TOPIC received? Update our local channel topic info then relay to clients + // Server TOPIC received? Update our local channel topic info then relay to clients. if (strncmp(tokens[1], "TOPIC", strlen(tokens[1])) == 0) { printf("Server TOPIC found and it is: %s with length %zd! Next token is '%s'. Updating our local channel topic info.\n", tokens[0], strlen(tokens[0]), tokens[2]); @@ -547,6 +547,18 @@ int processircmessage(int *serversockfd, int *clientsockfd, char *str, int sourc return 1; } + // Server PRIVMSG received? Relay to all clients and write to replay log. + if (strncmp(tokens[1], "PRIVMSG", strlen(tokens[1])) == 0) { + printf("Server PRIVMSG found and it is: %s with length %zd! Next token is '%s'. Relaying to all clients.\n", tokens[0], strlen(tokens[0]), tokens[2]); + + sendtoallclients(clientsockfd, fdmax, arr_clients, str, sourcefd); + + // Write to relay log + writerelayline(str); + + return 1; + } + // Don't return if we got here because this means we didn't process something above } @@ -701,7 +713,7 @@ int processircmessage(int *serversockfd, int *clientsockfd, char *str, int sourc return 1; } - // If PRIVMSG received, send to server, but also reformat and send to all other clients + // If PRIVMSG received, send to server, but also reformat and send to all other clients and log to replay file. if (strncmp(tokens[0], "PRIVMSG", strlen(tokens[0])) == 0) { printf("Client PRIVMSG found and it is: %s with length %zd! Sending to server then back to other clients...\n", tokens[0], strlen(tokens[0])); // Send original request straight to server @@ -717,6 +729,9 @@ int processircmessage(int *serversockfd, int *clientsockfd, char *str, int sourc // Send to all except source client sendtoallclients(clientsockfd, fdmax, arr_clients, outgoingmsg, sourcefd); + // Write to relay log + writerelayline(outgoingmsg); + return 1; } |