#include "saxdb.h"
#include "timeq.h"
-#define KEY_SENT "sent"
+#define KEY_BADWORDS "badwords"
+#define KEY_BADWORD_MASK "mask"
+#define KEY_BADWORD_TRIGGERED "count"
+#define KEY_BADWORD_ACTION "action"
static const struct message_entry msgtab[] = {
{ "WDMSG_NULL", "null." },
#define BADACTION_GLINE 3
static struct {
- char *nick;
- char *modes;
+ const char *nick;
+ const char *modes;
} watchdog_conf;
+const char *watchdog_module_deps[] = { NULL };
struct userNode *watchdog;
static struct module *watchdog_module;
static struct service *watchdog_service;
-static struct shitList *shitlist;
+static struct shitList shitlist;
+static struct log_type *MS_LOG;
static MODCMD_FUNC(cmd_addbad)
}
static struct badword*
-add_badword(char *badword, unsigned int triggered, unsigned int action)
+add_badword(char *badword_mask, unsigned int triggered, unsigned int action)
{
struct badword *badword;
if (!badword)
return NULL;
- badword->badword_mask = strdup(badword);
+ badword->badword_mask = strdup(badword_mask);
badword->triggered = triggered;
badword->action = action;
- shitlist_append(&shitlist, badword);
+ shitList_append(&shitlist, badword);
return badword;
}
static void
delete_badword(struct badword *badword)
{
- shitlist_remove(&shitlist, badword);
+ shitList_remove(&shitlist, badword);
free(badword->badword_mask);
free(badword);
}
watchdog_conf.nick = str;
str = database_get_data(conf_node, "modes", RECDB_QSTRING);
- watchdog_conf.modes = str;
+ watchdog_conf.modes = (str ? str : NULL);
}
static int
watchdog_saxdb_read(struct dict *db)
{
struct dict *object;
- if ((object = database_get_data(conf_db, KEY_BADWORDS, RECDB_OBJECT)))
+ if ((object = database_get_data(db, KEY_BADWORDS, RECDB_OBJECT)))
dict_foreach(object, watchdog_saxdb_read_shitlist, NULL);
+ return 1;
}
static int
unsigned int id = 0, ii;
saxdb_start_record(ctx, KEY_BADWORDS, 1);
- for (ii = 0; ii < ma->recvd.used; ++ii) {
- badword = ma->recvd.list[ii];
+ for (ii = 0; ii < shitlist.used; ++ii) {
+ badword = shitlist.list[ii];
snprintf(str, sizeof(str), "%x", id++);
saxdb_start_record(ctx, str, 0);
saxdb_write_string(ctx, KEY_BADWORD_MASK, badword->badword_mask);
{
while (shitlist.used)
delete_badword(shitlist.list[0]);
- shitlist_clean(&shitlist);
+ shitList_clean(&shitlist);
}
int
watchdog_init(void)
{
MS_LOG = log_register_type("Watchdog", "file:watchdog.log");
+ shitList_init(&shitlist);
conf_register_reload(watchdog_conf_read);
reg_exit_func(watchdog_cleanup);
saxdb_register("Watchdog", watchdog_saxdb_read, watchdog_saxdb_write);
const char *nick, *modes;
- if(nick = conf_get_data("services/spamserv/nick", RECDB_QSTRING)) {
- modes = conf_get_data("services/spamserv/modes", RECDB_QSTRING);
- spamserv = AddLocalUser(nick, nick, NULL, "Watchdog Service", modes);
- spamserv_service = service_register(spamserv);
- reg_allchanmsg_func(spamserv, watchdog_channel_message);
+ if((nick = conf_get_data("services/watchdog/nick", RECDB_QSTRING))) {
+ modes = conf_get_data("services/watchdog/modes", RECDB_QSTRING);
+ watchdog = AddLocalUser(nick, nick, NULL, "Watchdog Service", modes);
+ watchdog_service = service_register(watchdog);
+ reg_allchanmsg_func(watchdog, watchdog_channel_message);
}
watchdog_module = module_register("Watchdog", MS_LOG, "mod-watchdog.help", NULL);