2024-02-13 02:22:10 -05:00
|
|
|
#define MY_DLL_EXPORTS 1
|
|
|
|
|
2015-04-08 14:56:32 -04:00
|
|
|
#include "irc.h"
|
|
|
|
#include "events.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <libconfig.h>
|
|
|
|
|
2024-02-13 02:22:10 -05:00
|
|
|
MY_API void aj(struct irc_conn *bot, char *text)
|
2015-04-08 14:56:32 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
// Config Parser API
|
|
|
|
|
|
|
|
int count, n;
|
|
|
|
config_t cfg, *cf;
|
|
|
|
const config_setting_t *autojoin;
|
|
|
|
const char *base;
|
|
|
|
const char *chan = NULL;
|
|
|
|
|
|
|
|
cf = &cfg;
|
|
|
|
config_init(cf);
|
|
|
|
|
|
|
|
if (!config_read_file(cf, "./xbot.cfg"))
|
|
|
|
{
|
|
|
|
printf("[xbot.cfg:%d] Configuration error: %s\n",
|
|
|
|
config_error_line(cf),
|
|
|
|
config_error_text(cf)
|
|
|
|
);
|
|
|
|
|
|
|
|
config_destroy(cf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
autojoin = config_lookup(cf, "mods.mod_autojoin");
|
|
|
|
count = config_setting_length(autojoin);
|
|
|
|
|
|
|
|
for (n = 0; n < count; n++)
|
|
|
|
{
|
|
|
|
chan = config_setting_get_string_elem(autojoin, n);
|
|
|
|
irc_raw(bot, "JOIN :%s", chan);
|
|
|
|
}
|
|
|
|
|
|
|
|
config_destroy(cf);
|
|
|
|
}
|
|
|
|
|
2024-02-13 02:22:10 -05:00
|
|
|
MY_API void mod_init()
|
2015-04-08 14:56:32 -04:00
|
|
|
{
|
|
|
|
add_handler(IRC_CONNECTED, aj);
|
|
|
|
}
|