forked from atheme/atheme-contrib-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcs_regmode.c
50 lines (40 loc) · 1.04 KB
/
cs_regmode.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Copyright (c) 2011 William Pitcock <[email protected]>
* Rights to this code are as documented in doc/LICENSE.
*
* Set/unset DALnet channel mode +r on registration/deregistration.
*/
#include "atheme-compat.h"
DECLARE_MODULE_V1
(
"contrib/cs_regmode", false, _modinit, _moddeinit,
PACKAGE_STRING,
"Atheme Development Group <http://www.atheme.org>"
);
static void register_hook(hook_channel_req_t *hdata)
{
mychan_t *mc = hdata->mc;
if (mc == NULL || mc->chan == NULL)
return;
modestack_mode_simple(chansvs.nick, mc->chan, MTYPE_ADD, CMODE_CHANREG);
}
static void drop_hook(mychan_t *mc)
{
if (mc == NULL || mc->chan == NULL)
return;
modestack_mode_simple(chansvs.nick, mc->chan, MTYPE_DEL, CMODE_CHANREG);
}
void
_modinit(module_t *m)
{
hook_add_event("channel_register");
hook_add_channel_register(register_hook);
hook_add_event("channel_drop");
hook_add_channel_drop(drop_hook);
}
void
_moddeinit(module_unload_intent_t intent)
{
hook_del_channel_register(register_hook);
hook_del_channel_drop(drop_hook);
}