]> jfr.im git - solanum.git/blame - extensions/umode_noctcp.c
m_stats: z: remove unnecessary casting and fix format strings
[solanum.git] / extensions / umode_noctcp.c
CommitLineData
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
33static const char umode_noctcp_desc[] =
34 "Adds user mode +C which blocks CTCPs to the user.";
35
82436efb 36static void umode_noctcp_process(void *);
54d8925e
MT
37
38mapi_hfn_list_av1 umode_noctcp_hfnlist[] = {
82436efb 39 { "privmsg_user", umode_noctcp_process },
54d8925e
MT
40 { NULL, NULL }
41};
42
43static void
82436efb
EM
44umode_noctcp_process(void *data_)
45{
46 hook_data_privmsg_user *data = data_;
b07445c6
AC
47 if (!MyClient(data->target_p))
48 return;
49
54d8925e
MT
50 if (data->approved || data->msgtype == MESSAGE_TYPE_NOTICE) {
51 return;
52 }
53
f956cb0f 54 if (data->target_p->umodes & user_modes['C'] && *data->text == '\001' && rb_strncasecmp(data->text + 1, "ACTION", 6)) {
54d8925e
MT
55 sendto_one_numeric(data->source_p, ERR_CANNOTSENDTOUSER, form_str(ERR_CANNOTSENDTOUSER), data->target_p->name, "+C set");
56 data->approved = ERR_CANNOTSENDTOUSER;
57 return;
58 }
59}
60
61static int
62_modinit(void)
63{
64 user_modes['C'] = find_umode_slot();
65 construct_umodebuf();
66
67 return 0;
68}
69
70static void
71_moddeinit(void)
72{
73 user_modes['C'] = 0;
74 construct_umodebuf();
75}
76
77DECLARE_MODULE_AV2(umode_noctcp, _modinit, _moddeinit, NULL, NULL, umode_noctcp_hfnlist, NULL, NULL, umode_noctcp_desc);