Subversion Repositories Okuu

Rev

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

Rev 4 Rev 5
Line 1... Line 1...
1
/* $Id: bot.c 4 2024-09-10 19:26:12Z nishi $ */
1
/* $Id: bot.c 5 2024-09-11 00:26:25Z 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 25... Line 25...
25
#include <netinet/in.h>
25
#include <netinet/in.h>
26
#endif
26
#endif
27
 
27
 
28
#define OKUU_VERSION "1.00"
28
#define OKUU_VERSION "1.00"
29
 
29
 
30
extern char* nntpserver;
-
 
31
extern char* nntpuser;
-
 
32
extern char* nntppass;
-
 
33
extern char* nntppath;
30
extern char* nntppath;
34
extern char* nntpcount;
31
extern char* nntpcount;
35
extern int nntpport;
-
 
36
 
32
 
37
extern char* ircserver;
33
extern char* ircserver;
38
extern char* ircchan;
34
extern char* ircchan;
39
extern char* ircpass;
35
extern char* ircpass;
40
extern char* ircuser;
36
extern char* ircuser;
Line 85... Line 81...
85
 
81
 
86
	bzero((char*)&ok_addr, sizeof(ok_addr));
82
	bzero((char*)&ok_addr, sizeof(ok_addr));
87
	ok_addr.sin_family = PF_INET;
83
	ok_addr.sin_family = PF_INET;
88
	ok_addr.sin_addr.s_addr = inet_addr(ircserver);
84
	ok_addr.sin_addr.s_addr = inet_addr(ircserver);
89
	ok_addr.sin_port = htons(ircport);
85
	ok_addr.sin_port = htons(ircport);
-
 
86
 
-
 
87
	int yes = 1;
-
 
88
 
-
 
89
	if(setsockopt(ok_sock, IPPROTO_TCP, TCP_NODELAY, (char*)&yes, sizeof(yes)) < 0) {
-
 
90
		fprintf(stderr, "setsockopt failure");
-
 
91
		ok_close(ok_sock);
-
 
92
		return;
-
 
93
	}
90
	
94
	
91
	if(connect(ok_sock, (struct sockaddr*)&ok_addr, sizeof(ok_addr)) < 0){
95
	if(connect(ok_sock, (struct sockaddr*)&ok_addr, sizeof(ok_addr)) < 0){
92
		fprintf(stderr, "Connection failure\n");
96
		fprintf(stderr, "Connection failure\n");
93
		ok_close(ok_sock);
97
		ok_close(ok_sock);
94
		return;
98
		return;
Line 232... Line 236...
232
							sprintf(construct, "NOTICE %s :\x01VERSION Okuu %s / IRC Frameworks %s: http://nishi.boats/okuu\x01", nick, OKUU_VERSION, IRCFW_VERSION);
236
							sprintf(construct, "NOTICE %s :\x01VERSION Okuu %s / IRC Frameworks %s: http://nishi.boats/okuu\x01", nick, OKUU_VERSION, IRCFW_VERSION);
233
							ircfw_socket_send_cmd(ok_sock, NULL, construct);
237
							ircfw_socket_send_cmd(ok_sock, NULL, construct);
234
						}
238
						}
235
					}else if(sentin[0] == '#'){
239
					}else if(sentin[0] == '#'){
236
						/* This was sent in channel */
240
						/* This was sent in channel */
-
 
241
						if(ok_news_write(nick, msg) != 0){
-
 
242
							sprintf(construct, "PRIVMSG %s :Could not send the message to the USENET", sentin);
-
 
243
							ircfw_socket_send_cmd(ok_sock, NULL, construct);
-
 
244
						}
237
					}
245
					}
238
 
246
 
239
					free(nick);
247
					free(nick);
240
				}
248
				}
241
			}else if(strcasecmp(ircfw_message.command, "ERROR") == 0){
249
			}else if(strcasecmp(ircfw_message.command, "ERROR") == 0){