]> jfr.im git - solanum.git/blame - extensions/chm_operonly.c
s_user: clean up return types and can YES/NO.
[solanum.git] / extensions / chm_operonly.c
CommitLineData
acdf71d9
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
acdf71d9 13static void h_can_join(hook_data_channel *);
581dad19
EM
14static const char chm_operonly_desc[] =
15 "Adds channel mode +O which makes a channel operator-only";
acdf71d9
VY
16
17mapi_hfn_list_av1 operonly_hfnlist[] = {
18 { "can_join", (hookfn) h_can_join },
19 { NULL, NULL }
20};
21
19716b9f 22static unsigned int mymode;
acdf71d9 23
acdf71d9
VY
24static int
25_modinit(void)
26{
19716b9f
JT
27 mymode = cflag_add('O', chm_staff);
28 if (mymode == 0)
29 return -1;
acdf71d9
VY
30
31 return 0;
32}
33
34
acdf71d9
VY
35static void
36_moddeinit(void)
37{
19716b9f 38 cflag_orphan('O');
acdf71d9
VY
39}
40
581dad19 41DECLARE_MODULE_AV2(chm_operonly, _modinit, _moddeinit, NULL, NULL, operonly_hfnlist, NULL, NULL, chm_operonly_desc);
acdf71d9
VY
42
43static void
44h_can_join(hook_data_channel *data)
45{
46 struct Client *source_p = data->client;
47 struct Channel *chptr = data->chptr;
48
19716b9f 49 if((chptr->mode.mode & mymode) && !IsOper(source_p)) {
eb463ef3 50 sendto_one_numeric(source_p, 520, "%s :Cannot join channel (+O) - you are not an IRC operator", chptr->chname);
acdf71d9
VY
51 data->approved = ERR_CUSTOM;
52 }
53}
54