]> jfr.im git - irc/rqf/shadowircd.git/blob - extensions/chm_operonly.c
New custom channel mode API allowing reloading such modules.
[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 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 static unsigned int mymode;
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 mymode = cflag_add('O', chm_staff);
30 if (mymode == 0)
31 return -1;
32
33 return 0;
34 }
35
36
37 static void
38 _moddeinit(void)
39 {
40 cflag_orphan('O');
41 }
42
43 DECLARE_MODULE_AV1(chm_operonly, _modinit, _moddeinit, NULL, NULL, operonly_hfnlist, "$Revision$");
44
45 static void
46 h_can_join(hook_data_channel *data)
47 {
48 struct Client *source_p = data->client;
49 struct Channel *chptr = data->chptr;
50
51 if((chptr->mode.mode & mymode) && !IsOper(source_p)) {
52 sendto_one_numeric(source_p, 520, "%s :Cannot join channel (+O) - you are not an IRC operator", chptr->chname);
53 data->approved = ERR_CUSTOM;
54 }
55 }
56