]> jfr.im git - irc/freenode/solanum.git/commitdiff
extensions: add umode_noctcp extension
authorMax Teufel <redacted>
Mon, 7 Mar 2016 17:48:14 +0000 (18:48 +0100)
committerMax Teufel <redacted>
Mon, 7 Mar 2016 17:48:14 +0000 (18:48 +0100)
extensions/Makefile.am
extensions/umode_noctcp.c [new file with mode: 0644]
help/opers/umode
help/users/umode
include/messages.h
include/numeric.h

index 6a4963adbc68ac7a9ade7b5d7738c25f99b213f8..f3a5ecbb5203d2c1b11e4a2f4da3329143427c63 100644 (file)
@@ -43,6 +43,7 @@ extension_LTLIBRARIES =               \
   sno_globalnickchange.la      \
   sno_globaloper.la            \
   sno_whois.la                 \
+  umode_noctcp.la              \
   m_adminwall.la                       \
   m_echotags.la                        \
   m_extendchans.la             \
diff --git a/extensions/umode_noctcp.c b/extensions/umode_noctcp.c
new file mode 100644 (file)
index 0000000..1285136
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * umode_noctcp.c: user mode +C which blocks CTCPs to the user
+ *
+ * Copyright (c) 2016 M. Teufel
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "stdinc.h"
+#include "modules.h"
+#include "hook.h"
+#include "client.h"
+#include "ircd.h"
+#include "send.h"
+#include "s_user.h"
+#include "numeric.h"
+#include "inline/stringops.h"
+
+static const char umode_noctcp_desc[] =
+       "Adds user mode +C which blocks CTCPs to the user.";
+
+static void umode_noctcp_process(hook_data_privmsg_user *);
+
+mapi_hfn_list_av1 umode_noctcp_hfnlist[] = {
+       { "privmsg_user", (hookfn) umode_noctcp_process },
+       { NULL, NULL }
+};
+
+static void
+umode_noctcp_process(hook_data_privmsg_user *data) {
+       if (data->approved || data->msgtype == MESSAGE_TYPE_NOTICE) {
+               return;
+       }
+
+       if (data->target_p->umodes & user_modes['C'] && *data->text == '\001' && strncasecmp(data->text + 1, "ACTION", 6)) {
+               sendto_one_numeric(data->source_p, ERR_CANNOTSENDTOUSER, form_str(ERR_CANNOTSENDTOUSER), data->target_p->name, "+C set");
+               data->approved = ERR_CANNOTSENDTOUSER;
+               return;
+       }
+}
+
+static int
+_modinit(void)
+{
+       user_modes['C'] = find_umode_slot();
+       construct_umodebuf();
+
+       return 0;
+}
+
+static void
+_moddeinit(void)
+{
+       user_modes['C'] = 0;
+       construct_umodebuf();
+}
+
+DECLARE_MODULE_AV2(umode_noctcp, _modinit, _moddeinit, NULL, NULL, umode_noctcp_hfnlist, NULL, NULL, umode_noctcp_desc);
index c02da9d0f5b724bdd534ab5b38e1fa7223931b03..e961a73860ea03752d68b5d385502085e4a61820 100644 (file)
@@ -16,6 +16,7 @@ User modes: (* designates that the umode is oper only)
        * +l     - Can see oper locops (local wallops).
        * +s     - Can see server notices (see /quote help snomask).
        * +z     - Can see operwalls.
+       ? +C     - Prevents you from receiving CTCPs other than ACTION.
          +D     - Deaf - ignores all channel messages.
          +Q     - Prevents you from being affected by channel forwarding.
          +R     - Prevents unidentified users that you have not accepted from
index 736735a82a1139ee17d4b135b01a218ecf23edfd..71b01305b26a2dfcc70971d8b2171c2eb450a6d9 100644 (file)
@@ -11,6 +11,7 @@ User modes: (? designates that the umode is provided by an extension
        ? +h     - Has a cloaked host. May be +x depending on cloaking module
          +g     - "caller id" mode only allow accept clients to message you
          +w     - Can see oper wallops.
+       ? +C     - Prevents you from receiving CTCPs other than ACTION.
          +D     - Deaf - ignores all channel messages.
          +Q     - Prevents you from being affected by channel forwarding.
          +R     - Prevents unidentified users that you have not accepted from
index d656f8dcda4545a7bd2b938da55a509845f581a7..4d0c201d989fd81b5f52be6e4c80773d3de1b463 100644 (file)
 #define NUMERIC_STR_486      "%s :You must log in with services to message this user"
 #define NUMERIC_STR_489      ":%s 489 %s %s :You're neither voiced nor channel operator"
 #define NUMERIC_STR_491      ":No appropriate operator blocks were found for your host"
+#define NUMERIC_STR_492      ":Cannot send to user %s (%s)"
 #define NUMERIC_STR_494      "%s :cannot answer you while you are %s, your message was not sent"
 #define NUMERIC_STR_501      ":%s 501 %s :Unknown MODE flag"
 #define NUMERIC_STR_502      ":%s 502 %s :Can't change mode for other users"
index 56d86b2889e75e6bfc8a4e439e650550d7363c05..465cee154baba8768c39ca1041a7084682eb52db 100644 (file)
 
 #define ERR_NOOPERHOST       491
 
+#define ERR_CANNOTSENDTOUSER 492
+
 #define ERR_OWNMODE          494 /* from bahamut -- jilles */
 
 #define ERR_UMODEUNKNOWNFLAG 501