]>
Commit | Line | Data |
---|---|---|
6538a4cb VY |
1 | #include "stdinc.h" |
2 | #include "modules.h" | |
3 | #include "hook.h" | |
4 | #include "client.h" | |
5 | #include "ircd.h" | |
6 | #include "send.h" | |
7 | #include "s_conf.h" | |
8 | #include "s_user.h" | |
9 | #include "s_serv.h" | |
10 | #include "numeric.h" | |
11 | #include "chmode.h" | |
12 | ||
581dad19 EM |
13 | static const char chm_adminonly_desc[] = |
14 | "Enables channel mode +A that blocks non-admins from joining a channel"; | |
6538a4cb | 15 | |
82436efb | 16 | static void h_can_join(void *); |
eeabf33a | 17 | |
6538a4cb | 18 | mapi_hfn_list_av1 adminonly_hfnlist[] = { |
82436efb | 19 | { "can_join", h_can_join }, |
6538a4cb VY |
20 | { NULL, NULL } |
21 | }; | |
22 | ||
19716b9f JT |
23 | static unsigned int mymode; |
24 | ||
6538a4cb VY |
25 | static int |
26 | _modinit(void) | |
27 | { | |
19716b9f JT |
28 | mymode = cflag_add('A', chm_staff); |
29 | if (mymode == 0) | |
30 | return -1; | |
6538a4cb VY |
31 | |
32 | return 0; | |
33 | } | |
34 | ||
35 | static void | |
36 | _moddeinit(void) | |
37 | { | |
19716b9f | 38 | cflag_orphan('A'); |
6538a4cb VY |
39 | } |
40 | ||
581dad19 | 41 | DECLARE_MODULE_AV2(chm_adminonly, _modinit, _moddeinit, NULL, NULL, adminonly_hfnlist, NULL, NULL, chm_adminonly_desc); |
6538a4cb VY |
42 | |
43 | static void | |
82436efb | 44 | h_can_join(void *data_) |
6538a4cb | 45 | { |
82436efb | 46 | hook_data_channel *data = data_; |
6538a4cb VY |
47 | struct Client *source_p = data->client; |
48 | struct Channel *chptr = data->chptr; | |
49 | ||
19716b9f | 50 | if((chptr->mode.mode & mymode) && !IsAdmin(source_p)) { |
6538a4cb VY |
51 | sendto_one_numeric(source_p, 519, "%s :Cannot join channel (+A) - you are not an IRC server administrator", chptr->chname); |
52 | data->approved = ERR_CUSTOM; | |
53 | } | |
54 | } | |
55 |