X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/2f61d1d75ac52f239e760ecea02332eedc4682bd..35305a49c0973c0e29e4a607c2b507a2d8face43:/src/proto-common.c diff --git a/src/proto-common.c b/src/proto-common.c index 0254bbd..ae23a20 100644 --- a/src/proto-common.c +++ b/src/proto-common.c @@ -3,7 +3,7 @@ * * This file is part of x3. * - * srvx is free software; you can redistribute it and/or modify + * x3 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 * (at your option) any later version. @@ -23,6 +23,7 @@ #include "ioset.h" #include "log.h" #include "nickserv.h" +#include "spamserv.h" #include "shun.h" #include "timeq.h" #ifdef HAVE_SYS_SOCKET_H @@ -70,6 +71,7 @@ typedef void (*foreach_nonchan) (char *name, void *data); typedef void (*foreach_userfunc) (struct userNode *user, void *data); typedef void (*foreach_nonuser) (char *name, void *data); static void parse_foreach(char *target_list, foreach_chanfunc cf, foreach_nonchan nc, foreach_userfunc uf, foreach_nonuser nu, void *data); +static void call_channel_mode_funcs(struct userNode *who, struct chanNode *channel, char **modes, unsigned int argc); static void uplink_readable(struct io_fd *fd) { @@ -444,6 +446,8 @@ privmsg_chan_helper(struct chanNode *cn, void *data) if (!pd->is_notice && cf->func && ((cn->modes & MODE_REGISTERED) || GetUserMode(cn, cf->service))) cf->func(pd->user, cn, pd->text+1, cf->service); + else + spamserv_channel_message(cn, pd->user, pd->text); /* This catches *all* text sent to the channel that the services server sees */ for (x = 0; x < ALLCHANMSG_FUNCS_MAX; x++) { @@ -686,6 +690,9 @@ mod_chanmode(struct userNode *who, struct chanNode *channel, char **modes, unsig base_oplevel = MAXOPLEVEL; if (!(change = mod_chanmode_parse(channel, modes, argc, flags, base_oplevel))) return 0; + + call_channel_mode_funcs(who, channel, modes, argc); + if (flags & MC_ANNOUNCE) mod_chanmode_announce(who, channel, change); else @@ -710,6 +717,84 @@ irc_make_chanmode(struct chanNode *chan, char *out) return strlen(mod_chanmode_format(&change, out)); } +static user_mode_func_t *um_list; +static unsigned int um_size = 0, um_used = 0; + +void +reg_user_mode_func(user_mode_func_t handler) +{ + if (um_used == um_size) { + if (um_size) { + um_size <<= 1; + um_list = realloc(um_list, um_size*sizeof(user_mode_func_t)); + } else { + um_size = 8; + um_list = malloc(um_size*sizeof(user_mode_func_t)); + } + } + um_list[um_used++] = handler; +} + +void +unreg_user_mode_func(user_mode_func_t handler) +{ + unsigned int i; + for (i=0; i