]> jfr.im git - irc/rqf/shadowircd.git/blame - extensions/chm_operonly.c
Added tag shadowircd-6.3.0 for changeset 031bedf7e340
[irc/rqf/shadowircd.git] / extensions / chm_operonly.c
CommitLineData
7608ef49
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
7608ef49
VY
13static void h_can_join(hook_data_channel *);
14
15mapi_hfn_list_av1 operonly_hfnlist[] = {
16 { "can_join", (hookfn) h_can_join },
17 { NULL, NULL }
18};
19
6795400d 20static unsigned int mymode;
7608ef49
VY
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 */
26static int
27_modinit(void)
28{
6795400d
JT
29 mymode = cflag_add('O', chm_staff);
30 if (mymode == 0)
31 return -1;
7608ef49
VY
32
33 return 0;
34}
35
36
7608ef49
VY
37static void
38_moddeinit(void)
39{
6795400d 40 cflag_orphan('O');
7608ef49
VY
41}
42
43DECLARE_MODULE_AV1(chm_operonly, _modinit, _moddeinit, NULL, NULL, operonly_hfnlist, "$Revision$");
44
45static void
46h_can_join(hook_data_channel *data)
47{
48 struct Client *source_p = data->client;
49 struct Channel *chptr = data->chptr;
50
6795400d 51 if((chptr->mode.mode & mymode) && !IsOper(source_p)) {
4d94f914 52 sendto_one_numeric(source_p, 520, "%s :Cannot join channel (+O) - you are not an IRC operator", chptr->chname);
7608ef49
VY
53 data->approved = ERR_CUSTOM;
54 }
55}
56