Subversion Repositories Okuu

Rev

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

Rev 3 Rev 4
Line 1... Line 1...
1
/* $Id: bot.c 3 2024-09-10 19:21:48Z nishi $ */
1
/* $Id: bot.c 4 2024-09-10 19:26:12Z 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 109... Line 109...
109
 
109
 
110
	sprintf(construct, "NICK :%s", ircnick);
110
	sprintf(construct, "NICK :%s", ircnick);
111
	ircfw_socket_send_cmd(ok_sock, NULL, construct);
111
	ircfw_socket_send_cmd(ok_sock, NULL, construct);
112
 
112
 
113
	bool is_in = false;
113
	bool is_in = false;
-
 
114
	bool sendable = false;
114
 
115
 
115
	struct pollfd pollfds[1];
116
	struct pollfd pollfds[1];
116
	pollfds[0].fd = ok_sock;
117
	pollfds[0].fd = ok_sock;
117
	pollfds[0].events = POLLIN | POLLPRI;
118
	pollfds[0].events = POLLIN | POLLPRI;
118
 
119
 
Line 129... Line 130...
129
			struct dirent** list;
130
			struct dirent** list;
130
			int n = scandir(nntppath, &list, nodots, namesort);
131
			int n = scandir(nntppath, &list, nodots, namesort);
131
			if(n >= 0){
132
			if(n >= 0){
132
				int i;
133
				int i;
133
				for(i = 0; i < n; i++){
134
				for(i = 0; i < n; i++){
-
 
135
					if(!sendable){
-
 
136
						free(list[i]);
-
 
137
						continue;
-
 
138
					}
134
					if(count <= atoi(list[i]->d_name)){
139
					if(count <= atoi(list[i]->d_name)){
135
						sprintf(construct, "%s/%s", nntppath, list[i]->d_name);
140
						sprintf(construct, "%s/%s", nntppath, list[i]->d_name);
136
						if(ok_news_read(construct) == 0){
141
						if(ok_news_read(construct) == 0){
137
							char* tmp = ok_strcat3("PRIVMSG ", ircchan, " :\x03" "07[USENET] ~ ");
142
							char* tmp = ok_strcat3("PRIVMSG ", ircchan, " :\x03" "07[USENET] ~ ");
138
							char* temp = ok_strcat3(tmp, news_entry.from, "\x03 ");
143
							char* temp = ok_strcat3(tmp, news_entry.from, "\x03 ");
Line 190... Line 195...
190
			if(res == 376){
195
			if(res == 376){
191
				is_in = true;
196
				is_in = true;
192
				fprintf(stderr, "Login successful\n");
197
				fprintf(stderr, "Login successful\n");
193
				sprintf(construct, "JOIN :%s", ircchan);
198
				sprintf(construct, "JOIN :%s", ircchan);
194
				ircfw_socket_send_cmd(ok_sock, NULL, construct);
199
				ircfw_socket_send_cmd(ok_sock, NULL, construct);
-
 
200
			}else if(res == 331 || res == 332){
-
 
201
				sendable = true;
195
			}
202
			}
196
		}else{
203
		}else{
197
			if(strcasecmp(ircfw_message.command, "PING") == 0){
204
			if(strcasecmp(ircfw_message.command, "PING") == 0){
198
				fprintf(stderr, "Ping request\n");
205
				fprintf(stderr, "Ping request\n");
199
				sprintf(construct, "PONG :%s", ok_null(ircfw_message.prefix));
206
				sprintf(construct, "PONG :%s", ok_null(ircfw_message.prefix));