]>
Commit | Line | Data |
---|---|---|
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 | ||
13 | static void h_can_join(hook_data_channel *); | |
14 | ||
15 | mapi_hfn_list_av1 operonly_hfnlist[] = { | |
16 | { "can_join", (hookfn) h_can_join }, | |
17 | { NULL, NULL } | |
18 | }; | |
19 | ||
20 | ||
21 | ||
22 | /* This is a simple example of how to use dynamic channel modes. | |
23 | * Not tested enough yet, use at own risk. | |
24 | * -- dwr | |
25 | */ | |
26 | static int | |
27 | _modinit(void) | |
28 | { | |
29 | /* add the channel mode to the available slot */ | |
30 | chmode_table['O'].mode_type = find_cflag_slot(); | |
31 | chmode_table['O'].set_func = chm_simple; | |
32 | ||
33 | construct_noparam_modes(); | |
34 | ||
35 | return 0; | |
36 | } | |
37 | ||
38 | ||
39 | /* Well, the first ugly thing is that we changle chmode_table in _modinit | |
40 | * and chmode_flags in _moddeinit (different arrays) - must be fixed. | |
41 | * -- dwr | |
42 | */ | |
43 | static void | |
44 | _moddeinit(void) | |
45 | { | |
46 | /* disable the channel mode and remove it from the available list */ | |
47 | chmode_table['O'].mode_type = 0; | |
48 | ||
49 | construct_noparam_modes(); | |
50 | } | |
51 | ||
52 | DECLARE_MODULE_AV1(chm_operonly, _modinit, _moddeinit, NULL, NULL, operonly_hfnlist, "$Revision$"); | |
53 | ||
54 | static void | |
55 | h_can_join(hook_data_channel *data) | |
56 | { | |
57 | struct Client *source_p = data->client; | |
58 | struct Channel *chptr = data->chptr; | |
59 | ||
60 | if((chptr->mode.mode & chmode_flags['O']) && !IsOper(source_p)) { | |
61 | sendto_one_notice(source_p, ":Only IRC Operators could join this channel!"); | |
62 | data->approved = ERR_CUSTOM; | |
63 | } | |
64 | } | |
65 |