From 1cdc7a91008bc250bfc585f909e3b7c80739d20d Mon Sep 17 00:00:00 2001 From: Nishi Date: Wed, 11 Sep 2024 00:41:52 +0000 Subject: [PATCH] fix git-svn-id: file:///raid/svn-personal/okuu/trunk@8 7d206d2a-66c2-044b-96de-ba755a9b3ba8 --- Bot/bot.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/Bot/bot.c b/Bot/bot.c index 7f76356..807f52e 100644 --- a/Bot/bot.c +++ b/Bot/bot.c @@ -143,31 +143,33 @@ void ok_bot(void){ } if(count <= atoi(list[i]->d_name)){ sprintf(construct, "%s/%s", nntppath, list[i]->d_name); - if(ok_news_read(construct) == 0 && strcmp(news_entry.from, nntpfrom) != 0){ - char* tmp = ok_strcat3("PRIVMSG ", ircchan, " :\x03" "07[USENET] ~ "); - char* temp = ok_strcat3(tmp, news_entry.from, "\x03 "); - free(tmp); - int j; - int incr = 0; - for(j = 0;; j++){ - if(news_entry.content[j] == 0 || news_entry.content[j] == '\n'){ - char* line = malloc(j - incr + 1); - line[j - incr] = 0; - memcpy(line, news_entry.content + incr, j - incr); - - if(strlen(line) > 0){ - char* msg = ok_strcat(temp, line); - ircfw_socket_send_cmd(ok_sock, NULL, msg); - free(msg); - usleep(1000 * 100); /* Sleep for 100ms */ + if(ok_news_read(construct) == 0){ + if(strcmp(news_entry.from, nntpfrom) != 0){ + char* tmp = ok_strcat3("PRIVMSG ", ircchan, " :\x03" "07[USENET] ~ "); + char* temp = ok_strcat3(tmp, news_entry.from, "\x03 "); + free(tmp); + int j; + int incr = 0; + for(j = 0;; j++){ + if(news_entry.content[j] == 0 || news_entry.content[j] == '\n'){ + char* line = malloc(j - incr + 1); + line[j - incr] = 0; + memcpy(line, news_entry.content + incr, j - incr); + + if(strlen(line) > 0){ + char* msg = ok_strcat(temp, line); + ircfw_socket_send_cmd(ok_sock, NULL, msg); + free(msg); + usleep(1000 * 100); /* Sleep for 100ms */ + } + + free(line); + incr = j + 1; + if(news_entry.content[j] == 0) break; } - - free(line); - incr = j + 1; - if(news_entry.content[j] == 0) break; } + free(temp); } - free(temp); }else{ fprintf(stderr, "Could not read %s\n", construct); } -- 2.45.2