]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * Canjoin extban type: matches users who are or are not banned from a | |
3 | * specified channel. | |
4 | * -- nenolod/jilles | |
212380e3 AC |
5 | */ |
6 | ||
7 | #include "stdinc.h" | |
8 | #include "modules.h" | |
9 | #include "client.h" | |
10 | #include "channel.h" | |
11 | #include "hash.h" | |
12 | #include "ircd.h" | |
13 | ||
14 | static int _modinit(void); | |
15 | static void _moddeinit(void); | |
16 | static int eb_canjoin(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type); | |
c81afd15 | 17 | static const char extb_desc[] = "Can join ($j) extban type - matches users who are or are not banned from a specified channel"; |
212380e3 | 18 | |
c81afd15 | 19 | DECLARE_MODULE_AV2(extb_canjoin, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc); |
212380e3 AC |
20 | |
21 | static int | |
22 | _modinit(void) | |
23 | { | |
24 | extban_table['j'] = eb_canjoin; | |
25 | ||
26 | return 0; | |
27 | } | |
28 | ||
29 | static void | |
30 | _moddeinit(void) | |
31 | { | |
32 | extban_table['j'] = NULL; | |
33 | } | |
34 | ||
35 | static int eb_canjoin(const char *data, struct Client *client_p, | |
36 | struct Channel *chptr, long mode_type) | |
37 | { | |
38 | struct Channel *chptr2; | |
39 | int ret; | |
40 | static int recurse = 0; | |
41 | ||
42 | (void)mode_type; | |
43 | /* don't process a $j in a $j'ed list */ | |
44 | if (recurse) | |
45 | return EXTBAN_INVALID; | |
46 | if (data == NULL) | |
47 | return EXTBAN_INVALID; | |
48 | chptr2 = find_channel(data); | |
49 | /* must exist, and no point doing this with the same channel */ | |
50 | if (chptr2 == NULL || chptr2 == chptr) | |
51 | return EXTBAN_INVALID; | |
52 | /* require consistent target */ | |
53 | if (chptr->chname[0] == '#' && data[0] == '&') | |
54 | return EXTBAN_INVALID; | |
55 | /* this allows getting some information about ban exceptions | |
56 | * but +s/+p doesn't seem the right criterion */ | |
57 | #if 0 | |
58 | /* privacy! don't allow +s/+p channels to influence another channel */ | |
59 | if (!PubChannel(chptr2)) | |
60 | return EXTBAN_INVALID; | |
61 | #endif | |
62 | recurse = 1; | |
765d839d | 63 | ret = is_banned(chptr2, client_p, NULL, NULL, NULL, NULL) == CHFL_BAN ? EXTBAN_MATCH : EXTBAN_NOMATCH; |
212380e3 AC |
64 | recurse = 0; |
65 | return ret; | |
66 | } |