X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/c9ec8867a3e4f44ef6a0885d86f1ef97de900ebd..3a498ccda2d848f9f5d3fc5b7ba7308392a4a432:/src/spamserv.c diff --git a/src/spamserv.c b/src/spamserv.c index 0c871eb..a452614 100644 --- a/src/spamserv.c +++ b/src/spamserv.c @@ -3,7 +3,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. Important limitations are * listed in the COPYING file that accompanies this software. * @@ -43,6 +43,7 @@ #define KEY_ISSUED "issued" #define KEY_TRUSTED_ACCOUNTS "trusted" #define KEY_DEBUG_CHANNEL "debug_channel" +#define KEY_DEBUG_CHANNEL_MODES "debug_channel_modes" #define KEY_GLOBAL_EXCEPTIONS "global_exceptions" #define KEY_GLOBAL_BADWORDS "global_badwords" #define KEY_NETWORK_RULES "network_rules" @@ -596,8 +597,8 @@ spamserv_create_user(struct userNode *user) if(kNode) { + /* free(kNode); dict_remove does this */ dict_remove(killed_users_dict, irc_ntoa(&user->ip)); - free(kNode); } } @@ -624,7 +625,7 @@ spamserv_delete_user(struct userInfo *uInfo) } static int -spamserv_new_user_func(struct userNode *user) +spamserv_new_user_func(struct userNode *user, UNUSED_ARG(void *extra)) { if(!IsLocal(user)) spamserv_create_user(user); @@ -633,7 +634,7 @@ spamserv_new_user_func(struct userNode *user) } static void -spamserv_del_user_func(struct userNode *user, struct userNode *killer, UNUSED_ARG(const char *why)) +spamserv_del_user_func(struct userNode *user, struct userNode *killer, UNUSED_ARG(const char *why), UNUSED_ARG(void *extra)) { struct userInfo *uInfo = get_userInfo(user->nick); struct killNode *kNode; @@ -663,7 +664,7 @@ spamserv_del_user_func(struct userNode *user, struct userNode *killer, UNUSED_AR } static void -spamserv_nick_change_func(struct userNode *user, const char *old_nick) +spamserv_nick_change_func(struct userNode *user, const char *old_nick, UNUSED_ARG(void *extra)) { struct userInfo *uInfo = get_userInfo(old_nick); @@ -674,7 +675,7 @@ spamserv_nick_change_func(struct userNode *user, const char *old_nick) } static int -spamserv_user_join(struct modeNode *mNode) +spamserv_user_join(struct modeNode *mNode, UNUSED_ARG(void *extra)) { struct chanNode *channel = mNode->channel; struct userNode *user = mNode->user; @@ -719,7 +720,7 @@ spamserv_user_join(struct modeNode *mNode) } static void -spamserv_user_part(struct modeNode *mn, UNUSED_ARG(const char *reason)) +spamserv_user_part(struct modeNode *mn, UNUSED_ARG(const char *reason), UNUSED_ARG(void *extra)) { struct userNode *user = mn->user; struct chanNode *channel = mn->channel; @@ -2083,7 +2084,7 @@ static SPAMSERV_FUNC(cmd_addtrust) struct handle_info *hi; if (!(channel = GetChannel(argv[2]))) { - ss_reply("SSMSG_NOT_REGISTERED", channel->name); + ss_reply("SSMSG_NOT_REGISTERED", argv[2]); return 0; } @@ -2210,7 +2211,7 @@ static SPAMSERV_FUNC(cmd_deltrust) struct handle_info *hi; if (!(channel = GetChannel(argv[2]))) { - ss_reply("SSMSG_NOT_REGISTERED", channel->name); + ss_reply("SSMSG_NOT_REGISTERED", argv[2]); return 0; } @@ -3116,7 +3117,7 @@ static void spamserv_conf_read(void) { dict_t conf_node; - const char *str; + const char *str, *modes; if(!(conf_node = conf_get_data(SPAMSERV_CONF_NAME, RECDB_OBJECT))) { @@ -3128,7 +3129,9 @@ spamserv_conf_read(void) if(str) { - spamserv_conf.debug_channel = AddChannel(str, now, "+tinms", NULL, NULL); + modes = database_get_data(conf_node, KEY_DEBUG_CHANNEL_MODES, RECDB_QSTRING); + + spamserv_conf.debug_channel = AddChannel(str, now, (modes ? modes : "+tinms"), NULL, NULL); if(spamserv_conf.debug_channel) spamserv_join_channel(spamserv_conf.debug_channel); @@ -3186,7 +3189,7 @@ spamserv_conf_read(void) } static void -spamserv_db_cleanup(void) +spamserv_db_cleanup(UNUSED_ARG(void* extra)) { dict_iterator_t it; @@ -3218,7 +3221,7 @@ init_spamserv(const char *nick) return; const char *modes = conf_get_data("services/spamserv/modes", RECDB_QSTRING); - spamserv = AddService(nick, modes ? modes : NULL, "Anti Spam Services", NULL); + spamserv = AddLocalUser(nick, nick, NULL, "Anti Spam Services", modes); spamserv_service = service_register(spamserv); conf_register_reload(spamserv_conf_read); @@ -3241,11 +3244,11 @@ init_spamserv(const char *nick) saxdb_register("SpamServ", spamserv_saxdb_read, spamserv_saxdb_write); - reg_new_user_func(spamserv_new_user_func); - reg_del_user_func(spamserv_del_user_func); - reg_nick_change_func(spamserv_nick_change_func); - reg_join_func(spamserv_user_join); - reg_part_func(spamserv_user_part); + reg_new_user_func(spamserv_new_user_func, NULL); + reg_del_user_func(spamserv_del_user_func, NULL); + reg_nick_change_func(spamserv_nick_change_func, NULL); + reg_join_func(spamserv_user_join, NULL); + reg_part_func(spamserv_user_part, NULL); timeq_add(now + FLOOD_TIMEQ_FREQ, timeq_flood, NULL); timeq_add(now + JOINFLOOD_TIMEQ_FREQ, timeq_joinflood, NULL); @@ -3300,7 +3303,7 @@ init_spamserv(const char *nick) } } - reg_exit_func(spamserv_db_cleanup); + reg_exit_func(spamserv_db_cleanup, NULL); message_register_table(msgtab); crc32_init(); }