]> jfr.im git - solanum.git/blob - extensions/extb_channel.c
modules: add origin field to V2
[solanum.git] / extensions / extb_channel.c
1 /*
2 * Channel extban type: matches users who are in a certain public channel
3 * -- jilles
4 */
5
6 #include "stdinc.h"
7 #include "modules.h"
8 #include "client.h"
9 #include "channel.h"
10 #include "hash.h"
11 #include "ircd.h"
12
13 static int _modinit(void);
14 static void _moddeinit(void);
15 static int eb_channel(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type);
16
17 DECLARE_MODULE_AV1(extb_channel, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision: 1723 $");
18
19 static int
20 _modinit(void)
21 {
22 extban_table['c'] = eb_channel;
23
24 return 0;
25 }
26
27 static void
28 _moddeinit(void)
29 {
30 extban_table['c'] = NULL;
31 }
32
33 static int eb_channel(const char *data, struct Client *client_p,
34 struct Channel *chptr, long mode_type)
35 {
36 struct Channel *chptr2;
37
38 (void)chptr;
39 (void)mode_type;
40 if (data == NULL)
41 return EXTBAN_INVALID;
42 chptr2 = find_channel(data);
43 if (chptr2 == NULL)
44 return EXTBAN_INVALID;
45 /* require consistent target */
46 if (chptr->chname[0] == '#' && data[0] == '&')
47 return EXTBAN_INVALID;
48 /* privacy! don't allow +s/+p channels to influence another channel */
49 if (!PubChannel(chptr2) && chptr2 != chptr)
50 return EXTBAN_INVALID;
51 return IsMember(client_p, chptr2) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
52 }