Subversion Repositories Okuu

Rev

Rev 7 | Rev 11 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7 Rev 8
Line 1... Line 1...
1
/* $Id: bot.c 7 2024-09-11 00:40:20Z nishi $ */
1
/* $Id: bot.c 8 2024-09-11 00:41:52Z nishi $ */
2
 
2
 
3
#include "ok_bot.h"
3
#include "ok_bot.h"
4
 
4
 
5
#include "ok_util.h"
5
#include "ok_util.h"
6
#include "ok_news.h"
6
#include "ok_news.h"
Line 141... Line 141...
141
						free(list[i]);
141
						free(list[i]);
142
						continue;
142
						continue;
143
					}
143
					}
144
					if(count <= atoi(list[i]->d_name)){
144
					if(count <= atoi(list[i]->d_name)){
145
						sprintf(construct, "%s/%s", nntppath, list[i]->d_name);
145
						sprintf(construct, "%s/%s", nntppath, list[i]->d_name);
-
 
146
						if(ok_news_read(construct) == 0){
146
						if(ok_news_read(construct) == 0 && strcmp(news_entry.from, nntpfrom) != 0){
147
							if(strcmp(news_entry.from, nntpfrom) != 0){
147
							char* tmp = ok_strcat3("PRIVMSG ", ircchan, " :\x03" "07[USENET] ~ ");
148
								char* tmp = ok_strcat3("PRIVMSG ", ircchan, " :\x03" "07[USENET] ~ ");
148
							char* temp = ok_strcat3(tmp, news_entry.from, "\x03 ");
149
								char* temp = ok_strcat3(tmp, news_entry.from, "\x03 ");
149
							free(tmp);
150
								free(tmp);
150
							int j;
151
								int j;
151
							int incr = 0;
152
								int incr = 0;
152
							for(j = 0;; j++){
153
								for(j = 0;; j++){
153
								if(news_entry.content[j] == 0 || news_entry.content[j] == '\n'){
154
									if(news_entry.content[j] == 0 || news_entry.content[j] == '\n'){
154
									char* line = malloc(j - incr + 1);
155
										char* line = malloc(j - incr + 1);
155
									line[j - incr] = 0;
156
										line[j - incr] = 0;
156
									memcpy(line, news_entry.content + incr, j - incr);
157
										memcpy(line, news_entry.content + incr, j - incr);
157
 
158
	
158
									if(strlen(line) > 0){
159
										if(strlen(line) > 0){
159
										char* msg = ok_strcat(temp, line);
160
											char* msg = ok_strcat(temp, line);
160
										ircfw_socket_send_cmd(ok_sock, NULL, msg);
161
											ircfw_socket_send_cmd(ok_sock, NULL, msg);
161
										free(msg);
162
											free(msg);
162
										usleep(1000 * 100); /* Sleep for 100ms */
163
											usleep(1000 * 100); /* Sleep for 100ms */
-
 
164
										}
-
 
165
	
-
 
166
										free(line);
-
 
167
										incr = j + 1;
-
 
168
										if(news_entry.content[j] == 0) break;
163
									}
169
									}
164
 
-
 
165
									free(line);
-
 
166
									incr = j + 1;
-
 
167
									if(news_entry.content[j] == 0) break;
-
 
168
								}
170
								}
-
 
171
								free(temp);
169
							}
172
							}
170
							free(temp);
-
 
171
						}else{
173
						}else{
172
							fprintf(stderr, "Could not read %s\n", construct);
174
							fprintf(stderr, "Could not read %s\n", construct);
173
						}
175
						}
174
					}
176
					}
175
					free(list[i]);
177
					free(list[i]);