]> jfr.im git - irc/rqf/shadowircd.git/blame - extensions/chm_operonly.c
Update comment for me_svsjoin explaining the sort of morality of it.
[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
20
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{
29 /* add the channel mode to the available slot */
30 chmode_table['O'].mode_type = find_cflag_slot();
c870fa9f 31 chmode_table['O'].set_func = chm_staff;
7608ef49
VY
32
33 construct_noparam_modes();
34
35 return 0;
36}
37
38
39/* Well, the first ugly thing is that we changle chmode_table in _modinit
40 * and chmode_flags in _moddeinit (different arrays) - must be fixed.
41 * -- dwr
42 */
43static void
44_moddeinit(void)
45{
46 /* disable the channel mode and remove it from the available list */
47 chmode_table['O'].mode_type = 0;
48
49 construct_noparam_modes();
50}
51
52DECLARE_MODULE_AV1(chm_operonly, _modinit, _moddeinit, NULL, NULL, operonly_hfnlist, "$Revision$");
53
54static void
55h_can_join(hook_data_channel *data)
56{
57 struct Client *source_p = data->client;
58 struct Channel *chptr = data->chptr;
59
60 if((chptr->mode.mode & chmode_flags['O']) && !IsOper(source_p)) {
4d94f914 61 sendto_one_numeric(source_p, 520, "%s :Cannot join channel (+O) - you are not an IRC operator", chptr->chname);
7608ef49
VY
62 data->approved = ERR_CUSTOM;
63 }
64}
65