]> jfr.im git - solanum.git/blame - extensions/chm_adminonly.c
modules: Add AV2 descriptions to all m_u* modules
[solanum.git] / extensions / chm_adminonly.c
CommitLineData
6538a4cb
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
13static void h_can_join(hook_data_channel *);
581dad19
EM
14static const char chm_adminonly_desc[] =
15 "Enables channel mode +A that blocks non-admins from joining a channel";
6538a4cb
VY
16
17mapi_hfn_list_av1 adminonly_hfnlist[] = {
18 { "can_join", (hookfn) h_can_join },
19 { NULL, NULL }
20};
21
19716b9f
JT
22static unsigned int mymode;
23
6538a4cb
VY
24static int
25_modinit(void)
26{
19716b9f
JT
27 mymode = cflag_add('A', chm_staff);
28 if (mymode == 0)
29 return -1;
6538a4cb
VY
30
31 return 0;
32}
33
34static void
35_moddeinit(void)
36{
19716b9f 37 cflag_orphan('A');
6538a4cb
VY
38}
39
581dad19 40DECLARE_MODULE_AV2(chm_adminonly, _modinit, _moddeinit, NULL, NULL, adminonly_hfnlist, NULL, NULL, chm_adminonly_desc);
6538a4cb
VY
41
42static void
43h_can_join(hook_data_channel *data)
44{
45 struct Client *source_p = data->client;
46 struct Channel *chptr = data->chptr;
47
19716b9f 48 if((chptr->mode.mode & mymode) && !IsAdmin(source_p)) {
6538a4cb
VY
49 sendto_one_numeric(source_p, 519, "%s :Cannot join channel (+A) - you are not an IRC server administrator", chptr->chname);
50 data->approved = ERR_CUSTOM;
51 }
52}
53