summaryrefslogtreecommitdiff
path: root/blabouncer.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-05-15 22:35:39 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-05-15 22:35:39 +0100
commitf5ddf5273300870c6a95279046d692d975789f59 (patch)
tree102e8d2a44f9b3bee0f2c7a7d68d11f30743862a /blabouncer.c
parent39d12c5d9de753b86ca6add5e500a7e78c8991ca (diff)
Improve NOTICE output sent to client when no replay lines are available or when getting the help message.
Diffstat (limited to 'blabouncer.c')
-rw-r--r--blabouncer.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/blabouncer.c b/blabouncer.c
index 9f6f5cf..2e7dc7f 100644
--- a/blabouncer.c
+++ b/blabouncer.c
@@ -445,6 +445,10 @@ int doreplay(int sourcefd, int replayseconds, int arr_clients[], int arr_authed[
if (numlines < 0) {
printf("Error getting number of replay lines.\n");
exit(1);
+ } else if (numlines == 0) {
+ snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :0 replay log lines found in the time requested, nothing to send.", settings->ircnick);
+ sendtoclient(sourcefd, outgoingmsg, arr_clients, arr_authed, arr_ssl, settings);
+ return 1;
}
// Replay those lines!
@@ -894,18 +898,15 @@ int processircmessage(SSL *server_ssl, int *clientsockfd, char *str, int source,
// Custom BLABOUNCER command received
// Case insensitive comparisons here since clients won't be recognising and uppercasing these commands
if (strncasecmp(tokens[0], "BLABOUNCER", strlen(tokens[0])) == 0) {
+ char outgoingmsg[MAXDATASIZE];
printf("Client BLABOUNCER found and it is: %s with length %zd!\n", tokens[1], strlen(tokens[1]));
// REPLAY received, send the requested number of seconds of replay to the client
- if (strncasecmp(tokens[1], "REPLAY", strlen(tokens[1])) == 0) {
+ if (strncasecmp(tokens[1], "REPLAY", strlen("REPLAY")) == 0) {
printf("Client BLABOUNCER REPLAY (custom blabouncer command) found and it is: %s with length %zd!\n", tokens[1], strlen(tokens[1]));
int replayseconds;
if ((replayseconds = strtol(tokens[2], NULL, 10)) == 0) {
printf("Invalid number of replay seconds provided by REPLAY. Telling client.\n");
- char outgoingmsg[MAXDATASIZE];
- if (!snprintf(outgoingmsg, MAXDATASIZE, "Invalid number of seconds of replay requested by REPLAY command.")) {
- fprintf(stderr, "Error while preparing invalid REPLAY command response, exiting!\n");
- exit(1);
- }
+ snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Invalid number of seconds of replay requested by REPLAY command.", settings->ircnick);
sendtoclient(sourcefd, outgoingmsg, arr_clients, arr_authed, arr_ssl, settings);
return 1;
}
@@ -915,10 +916,9 @@ int processircmessage(SSL *server_ssl, int *clientsockfd, char *str, int source,
// Unrecognised BLABOUNCER command received, send some help instructions
} else {
printf("Client BLABOUNCER unrecognised command found and it is: %s with length %zd! Sending a help message.\n", tokens[1], strlen(tokens[1]));
- char outgoingmsg[MAXDATASIZE];
- snprintf(outgoingmsg, MAXDATASIZE, "Unrecognised BLABOUNCER command received. Valid commands are:");
+ snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Unrecognised BLABOUNCER command received. Valid commands are:", settings->ircnick);
sendtoclient(sourcefd, outgoingmsg, arr_clients, arr_authed, arr_ssl, settings);
- snprintf(outgoingmsg, MAXDATASIZE, "\"BLABOUNCER REPLAY [seconds]\" (Where [seconds] is the number of seconds of replay log to replay.)");
+ snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :\"BLABOUNCER REPLAY [seconds]\" (Where [seconds] is the number of seconds of replay log to replay.)", settings->ircnick);
sendtoclient(sourcefd, outgoingmsg, arr_clients, arr_authed, arr_ssl, settings);
return 1;
}