irclogbot/irclogbot.c

41 lines
1.1 KiB
C
Raw Normal View History

2007-04-11 19:36:53 +02:00
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "configfile.h"
2007-07-07 17:24:03 +02:00
#include "event.h"
#include "ircsession.h"
2007-04-11 19:36:53 +02:00
#include "list.h"
#include "logging.h"
2007-07-07 17:24:03 +02:00
#include "sockaddr.h"
2007-04-11 19:36:53 +02:00
2007-12-04 16:56:05 +01:00
#define DEFAULT_CONFIG "irclogbot.conf"
2007-04-11 19:36:53 +02:00
int main(int argc, char *argv[])
{
2007-12-04 16:56:05 +01:00
/* parse config file */
if (config_parse(DEFAULT_CONFIG))
exit(1);
char *server_str = (char *)config_get_string("global", "server", NULL);
if (server_str == NULL)
exit(1);
2007-07-07 17:24:03 +02:00
struct irc_session *session = irc_create_session();
2007-12-04 16:56:05 +01:00
parse_sockaddr(server_str, &session->srv_addr);
2007-04-11 19:36:53 +02:00
2007-12-04 16:56:05 +01:00
session->server_pass = (char *)config_get_string("global", "server-pass", NULL);
session->nickname = (char *)config_get_string("global", "nickname", "logbot");
session->username = (char *)config_get_string("global", "username", NULL);
session->realname = (char *)config_get_string("global", "realname", NULL);
2007-04-11 19:36:53 +02:00
2007-12-04 17:09:14 +01:00
session->channel = (char *)config_get_string("global", "channel", "logbot");
session->channel_key = (char *)config_get_string("global", "channel-key", NULL);
2007-04-11 19:36:53 +02:00
2007-12-04 17:09:14 +01:00
irc_connect(session);
2007-07-07 17:24:03 +02:00
event_loop();
2007-04-11 19:36:53 +02:00
2007-12-04 16:56:05 +01:00
config_free();
2007-04-11 19:36:53 +02:00
return 0;
}