]> jfr.im git - solanum.git/blobdiff - extensions/m_remove.c
Add .travis.yml
[solanum.git] / extensions / m_remove.c
index 03ea99ad8a2583f6da4bd8eaceac3d63d5defa78..29c33b4033bcf0412e1161ec0d89a24933f15373 100644 (file)
 #include "messages.h"
 
 unsigned int CAP_REMOVE;
+static char part_buf[REASONLEN + 1];
 
 static int m_remove(struct Client *, struct Client *, int, const char **);
+static void remove_quote_part(hook_data_privmsg_channel *);
 
 struct Message remove_msgtab = {
        "REMOVE", 0, 0, 0, MFLG_SLOW,
@@ -51,6 +53,10 @@ struct Message remove_msgtab = {
 };
 
 mapi_clist_av1 remove_clist[] = { &remove_msgtab, NULL };
+mapi_hfn_list_av1 remove_hfnlist[] = {
+       { "privmsg_channel", (hookfn) remove_quote_part },
+       { NULL, NULL }
+};
 
 static int
 modinit(void)
@@ -66,7 +72,7 @@ moddeinit(void)
        capability_orphan(serv_capindex, "REMOVE");
 }
 
-DECLARE_MODULE_AV1(remove, modinit, moddeinit, remove_clist, NULL, NULL, "$Revision: 3317 $");
+DECLARE_MODULE_AV1(remove, modinit, moddeinit, remove_clist, NULL, remove_hfnlist, "$Revision: 3317 $");
 
 static int
 m_remove(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
@@ -108,7 +114,7 @@ m_remove(struct Client *client_p, struct Client *source_p, int parc, const char
                        return 0;
                }
 
-               if(get_channel_access(source_p, msptr) < CHFL_CHANOP)
+               if(get_channel_access(source_p, chptr, msptr, MODE_ADD, NULL) < CHFL_CHANOP)
                {
                        if(MyConnect(source_p))
                        {
@@ -178,6 +184,7 @@ m_remove(struct Client *client_p, struct Client *source_p, int parc, const char
                        hookdata.msptr = msptr;
                        hookdata.target = who;
                        hookdata.approved = 1;
+                       hookdata.dir = MODE_ADD;        /* ensure modules like override speak up */
 
                        call_hook(h_can_kick, &hookdata);
 
@@ -217,3 +224,15 @@ m_remove(struct Client *client_p, struct Client *source_p, int parc, const char
        return 0;
 }
 
+static void
+remove_quote_part(hook_data_privmsg_channel *data)
+{
+       if (data->approved || EmptyString(data->text) || data->msgtype != MESSAGE_TYPE_PART)
+               return;
+
+       rb_strlcpy(part_buf, "\"", sizeof(part_buf) - 1);
+       rb_strlcat(part_buf, data->text, sizeof(part_buf) - 1);
+       rb_strlcat(part_buf, "\"", sizeof(part_buf));
+
+       data->text = part_buf;
+}