]>
Commit | Line | Data |
---|---|---|
54d8925e MT |
1 | /* |
2 | * umode_noctcp.c: user mode +C which blocks CTCPs to the user | |
3 | * | |
4 | * Copyright (c) 2016 M. Teufel | |
5 | * | |
6 | * Permission to use, copy, modify, and/or distribute this software for any | |
7 | * purpose with or without fee is hereby granted, provided that the above | |
8 | * copyright notice and this permission notice is present in all copies. | |
9 | * | |
10 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
11 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
12 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
13 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
14 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
15 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
16 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
17 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
18 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
19 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
20 | * POSSIBILITY OF SUCH DAMAGE. | |
21 | */ | |
22 | ||
23 | #include "stdinc.h" | |
24 | #include "modules.h" | |
25 | #include "hook.h" | |
26 | #include "client.h" | |
27 | #include "ircd.h" | |
28 | #include "send.h" | |
29 | #include "s_user.h" | |
30 | #include "numeric.h" | |
31 | #include "inline/stringops.h" | |
32 | ||
33 | static const char umode_noctcp_desc[] = | |
34 | "Adds user mode +C which blocks CTCPs to the user."; | |
35 | ||
36 | static void umode_noctcp_process(hook_data_privmsg_user *); | |
37 | ||
38 | mapi_hfn_list_av1 umode_noctcp_hfnlist[] = { | |
39 | { "privmsg_user", (hookfn) umode_noctcp_process }, | |
40 | { NULL, NULL } | |
41 | }; | |
42 | ||
43 | static void | |
44 | umode_noctcp_process(hook_data_privmsg_user *data) { | |
45 | if (data->approved || data->msgtype == MESSAGE_TYPE_NOTICE) { | |
46 | return; | |
47 | } | |
48 | ||
49 | if (data->target_p->umodes & user_modes['C'] && *data->text == '\001' && strncasecmp(data->text + 1, "ACTION", 6)) { | |
50 | sendto_one_numeric(data->source_p, ERR_CANNOTSENDTOUSER, form_str(ERR_CANNOTSENDTOUSER), data->target_p->name, "+C set"); | |
51 | data->approved = ERR_CANNOTSENDTOUSER; | |
52 | return; | |
53 | } | |
54 | } | |
55 | ||
56 | static int | |
57 | _modinit(void) | |
58 | { | |
59 | user_modes['C'] = find_umode_slot(); | |
60 | construct_umodebuf(); | |
61 | ||
62 | return 0; | |
63 | } | |
64 | ||
65 | static void | |
66 | _moddeinit(void) | |
67 | { | |
68 | user_modes['C'] = 0; | |
69 | construct_umodebuf(); | |
70 | } | |
71 | ||
72 | DECLARE_MODULE_AV2(umode_noctcp, _modinit, _moddeinit, NULL, NULL, umode_noctcp_hfnlist, NULL, NULL, umode_noctcp_desc); |