Subversion Repositories Okuu

Rev

Rev 14 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14 Rev 15
Line 1... Line 1...
1
/* $Id: bot.c 14 2024-09-12 22:19:34Z nishi $ */
1
/* $Id: bot.c 15 2024-09-13 16:13:27Z 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 99... Line 99...
99
	}
99
	}
100
 
100
 
101
	signal(SIGINT, ok_bot_kill);
101
	signal(SIGINT, ok_bot_kill);
102
	signal(SIGTERM, ok_bot_kill);
102
	signal(SIGTERM, ok_bot_kill);
103
 
103
 
104
	char* construct = malloc(1025);
104
	char* construct = malloc(4097);
105
 
105
 
106
	if(ircpass != NULL && strlen(ircpass) > 0) {
106
	if(ircpass != NULL && strlen(ircpass) > 0) {
107
		sprintf(construct, "PASS :%s", ircpass);
107
		sprintf(construct, "PASS :%s", ircpass);
108
		ircfw_socket_send_cmd(ok_sock, NULL, construct);
108
		ircfw_socket_send_cmd(ok_sock, NULL, construct);
109
	}
109
	}
Line 133... Line 133...
133
			}
133
			}
134
			struct dirent** list;
134
			struct dirent** list;
135
			int n = scandir(nntppath, &list, nodots, namesort);
135
			int n = scandir(nntppath, &list, nodots, namesort);
136
			if(n >= 0) {
136
			if(n >= 0) {
137
				int i;
137
				int i;
-
 
138
				uint64_t last = 0;
138
				for(i = 0; i < n; i++) {
139
				for(i = 0; i < n; i++) {
139
					if(!sendable) {
140
					if(!sendable || strcmp(list[i]->d_name, ".") == 0 || strcmp(list[i]->d_name, "..") == 0) {
140
						free(list[i]);
141
						free(list[i]);
141
						continue;
142
						continue;
142
					}
143
					}
143
					if(count <= atoi(list[i]->d_name)) {
144
					if(count <= atoi(list[i]->d_name)) {
144
						sprintf(construct, "%s/%s", nntppath, list[i]->d_name);
145
						sprintf(construct, "%s/%s", nntppath, list[i]->d_name);
Line 173... Line 174...
173
							}
174
							}
174
						} else {
175
						} else {
175
							fprintf(stderr, "Could not read %s\n", construct);
176
							fprintf(stderr, "Could not read %s\n", construct);
176
						}
177
						}
177
					}
178
					}
-
 
179
					last = atoi(list[i]->d_name) + 1;
178
					free(list[i]);
180
					free(list[i]);
179
				}
181
				}
180
				count = atoi(list[i - 1]->d_name) + 1;
182
				count = last;
181
				free(list);
183
				free(list);
182
			}
184
			}
183
			if(sendable) {
185
			if(sendable) {
184
				f = fopen(nntpcount, "wb");
186
				f = fopen(nntpcount, "wb");
185
				if(f != NULL) {
187
				if(f != NULL) {
Line 206... Line 208...
206
			if(res == 376) {
208
			if(res == 376) {
207
				is_in = true;
209
				is_in = true;
208
				fprintf(stderr, "Login successful\n");
210
				fprintf(stderr, "Login successful\n");
209
				sprintf(construct, "JOIN :%s", ircchan);
211
				sprintf(construct, "JOIN :%s", ircchan);
210
				ircfw_socket_send_cmd(ok_sock, NULL, construct);
212
				ircfw_socket_send_cmd(ok_sock, NULL, construct);
211
			} else if(res == 331 || res == 332) {
213
			} else if(res == 366) {
212
				sendable = true;
214
				sendable = true;
213
			}
215
			}
214
		} else {
216
		} else {
215
			if(strcasecmp(ircfw_message.command, "PING") == 0) {
217
			if(strcasecmp(ircfw_message.command, "PING") == 0) {
216
				fprintf(stderr, "Ping request\n");
218
				fprintf(stderr, "Ping request\n");