]>
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) { | |
b07445c6 AC |
45 | if (!MyClient(data->target_p)) |
46 | return; | |
47 | ||
54d8925e MT |
48 | if (data->approved || data->msgtype == MESSAGE_TYPE_NOTICE) { |
49 | return; | |
50 | } | |
51 | ||
f956cb0f | 52 | if (data->target_p->umodes & user_modes['C'] && *data->text == '\001' && rb_strncasecmp(data->text + 1, "ACTION", 6)) { |
54d8925e MT |
53 | sendto_one_numeric(data->source_p, ERR_CANNOTSENDTOUSER, form_str(ERR_CANNOTSENDTOUSER), data->target_p->name, "+C set"); |
54 | data->approved = ERR_CANNOTSENDTOUSER; | |
55 | return; | |
56 | } | |
57 | } | |
58 | ||
59 | static int | |
60 | _modinit(void) | |
61 | { | |
62 | user_modes['C'] = find_umode_slot(); | |
63 | construct_umodebuf(); | |
64 | ||
65 | return 0; | |
66 | } | |
67 | ||
68 | static void | |
69 | _moddeinit(void) | |
70 | { | |
71 | user_modes['C'] = 0; | |
72 | construct_umodebuf(); | |
73 | } | |
74 | ||
75 | DECLARE_MODULE_AV2(umode_noctcp, _modinit, _moddeinit, NULL, NULL, umode_noctcp_hfnlist, NULL, NULL, umode_noctcp_desc); |