]> jfr.im git - solanum.git/blame - modules/chm_nocolour.c
Add umode +I to allow users to hide their idle time (#220)
[solanum.git] / modules / chm_nocolour.c
CommitLineData
67aeaba5 1/*
a6f63a82 2 * Solanum: a slightly advanced ircd
67aeaba5
AC
3 * chm_nocolour: strip colours (+c mode).
4 *
3fc0499e 5 * Copyright (c) 2012 Ariadne Conill <ariadne@dereferenced.org>
67aeaba5
AC
6 *
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice is present in all copies.
10 *
11 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
12 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
13 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
14 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
15 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
16 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
17 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
19 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
20 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21 * POSSIBILITY OF SUCH DAMAGE.
22 */
23
24#include "stdinc.h"
25#include "modules.h"
26#include "hook.h"
27#include "client.h"
28#include "ircd.h"
29#include "send.h"
30#include "s_conf.h"
31#include "s_user.h"
32#include "s_serv.h"
33#include "numeric.h"
34#include "chmode.h"
35#include "inline/stringops.h"
36
eeabf33a
EM
37static const char chm_nocolour_desc[] =
38 "Enables channel mode +c that filters colours and formatting from a channel";
39
67aeaba5
AC
40static char buf[BUFSIZE];
41static unsigned int mode_nocolour;
42
82436efb 43static void chm_nocolour_process(void *);
67aeaba5
AC
44
45mapi_hfn_list_av1 chm_nocolour_hfnlist[] = {
82436efb 46 { "privmsg_channel", chm_nocolour_process },
67aeaba5
AC
47 { NULL, NULL }
48};
49
50static void
82436efb 51chm_nocolour_process(void *data_)
67aeaba5 52{
82436efb 53 hook_data_privmsg_channel *data = data_;
67aeaba5
AC
54 /* don't waste CPU if message is already blocked */
55 if (data->approved)
56 return;
57
58 if (data->chptr->mode.mode & mode_nocolour)
59 {
60 rb_strlcpy(buf, data->text, sizeof buf);
61 strip_colour(buf);
62
63 data->text = buf;
64 }
65}
66
67static int
68_modinit(void)
69{
70 mode_nocolour = cflag_add('c', chm_simple);
71 if (mode_nocolour == 0)
72 return -1;
73
74 return 0;
75}
76
77static void
78_moddeinit(void)
79{
80 cflag_orphan('c');
81}
82
4a094473 83DECLARE_MODULE_AV2(chm_nocolour, _modinit, _moddeinit, NULL, NULL, chm_nocolour_hfnlist, NULL, NULL, chm_nocolour_desc);