]> jfr.im git - irc/rqf/shadowircd.git/blob - extensions/chm_operonly.c
A very draft version of extensions, which are adding can_join hooks for custom channe...
[irc/rqf/shadowircd.git] / extensions / chm_operonly.c
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 /* gcc -fPIC -DPIC -shared -I. -I../include -I../libratbox/include -O0 -Wall -std=gnu99 -g -DIRCD_PREFIX=\"/home/dwr/build/charybdis\" chm_operonly.c -o chm_operonly.so */
14
15 static void h_can_join(hook_data_channel *);
16
17 mapi_hfn_list_av1 operonly_hfnlist[] = {
18 { "can_join", (hookfn) h_can_join },
19 { NULL, NULL }
20 };
21
22
23
24 /* This is a simple example of how to use dynamic channel modes.
25 * Not tested enough yet, use at own risk.
26 * -- dwr
27 */
28 static int
29 _modinit(void)
30 {
31 /* add the channel mode to the available slot */
32 chmode_table['O'].mode_type = find_cflag_slot();
33 chmode_table['O'].set_func = chm_simple;
34
35 construct_noparam_modes();
36
37 return 0;
38 }
39
40
41 /* Well, the first ugly thing is that we changle chmode_table in _modinit
42 * and chmode_flags in _moddeinit (different arrays) - must be fixed.
43 * -- dwr
44 */
45 static void
46 _moddeinit(void)
47 {
48 /* disable the channel mode and remove it from the available list */
49 chmode_table['O'].mode_type = 0;
50
51 construct_noparam_modes();
52 }
53
54 DECLARE_MODULE_AV1(chm_operonly, _modinit, _moddeinit, NULL, NULL, operonly_hfnlist, "$Revision$");
55
56 static void
57 h_can_join(hook_data_channel *data)
58 {
59 struct Client *source_p = data->client;
60 struct Channel *chptr = data->chptr;
61
62 if((chptr->mode.mode & chmode_flags['O']) && !IsOper(source_p)) {
63 sendto_one_notice(source_p, ":Only IRC Operators could join this channel!");
64 data->approved = ERR_CUSTOM;
65 }
66 }
67