X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/deee7b4388d1068be531ce9053772ab67f14f592..81e41406f4027dfef50dcd5ef33403661bea5995:/extensions/m_remove.c diff --git a/extensions/m_remove.c b/extensions/m_remove.c index 2ce17925..be2c2458 100644 --- a/extensions/m_remove.c +++ b/extensions/m_remove.c @@ -20,8 +20,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA - * - * $Id: m_kick.c 3317 2007-03-28 23:17:06Z jilles $ */ #include "stdinc.h" @@ -39,37 +37,35 @@ #include "s_serv.h" #include "s_conf.h" #include "hook.h" +#include "messages.h" -unsigned int CAP_REMOVE; +static const char description[] = "Provides the REMOVE command, an alternative to KICK"; -static int m_remove(struct Client *, struct Client *, int, const char **); +static void m_remove(struct MsgBuf *, struct Client *, struct Client *, int, const char **); +static void remove_quote_part(hook_data_privmsg_channel *); + +unsigned int CAP_REMOVE; +static char part_buf[REASONLEN + 1]; struct Message remove_msgtab = { - "REMOVE", 0, 0, 0, MFLG_SLOW, + "REMOVE", 0, 0, 0, 0, {mg_unreg, {m_remove, 3}, {m_remove, 3}, {m_remove, 3}, mg_ignore, {m_remove, 3}} }; mapi_clist_av1 remove_clist[] = { &remove_msgtab, NULL }; +mapi_hfn_list_av1 remove_hfnlist[] = { + { "privmsg_channel", (hookfn) remove_quote_part }, + { NULL, NULL } +}; +mapi_cap_list_av2 remove_cap_list[] = { + { MAPI_CAP_SERVER, "REMOVE", NULL, &CAP_REMOVE }, + { 0, NULL, NULL, NULL } +}; -static int -modinit(void) -{ - CAP_REMOVE = capability_put(serv_capindex, "REMOVE"); - capability_require(serv_capindex, "REMOVE"); - - return 0; -} +DECLARE_MODULE_AV2(remove, NULL, NULL, remove_clist, NULL, remove_hfnlist, remove_cap_list, NULL, description); static void -moddeinit(void) -{ - capability_orphan(serv_capindex, "REMOVE"); -} - -DECLARE_MODULE_AV1(remove, modinit, moddeinit, remove_clist, NULL, NULL, "$Revision: 3317 $"); - -static int -m_remove(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) +m_remove(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct membership *msptr; struct Client *who; @@ -94,7 +90,7 @@ m_remove(struct Client *client_p, struct Client *source_p, int parc, const char if(chptr == NULL) { sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name); - return 0; + return; } if(!IsServer(source_p)) @@ -105,16 +101,16 @@ m_remove(struct Client *client_p, struct Client *source_p, int parc, const char { sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), name); - return 0; + return; } - 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)) { sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), me.name, source_p->name, name); - return 0; + return; } /* If its a TS 0 channel, do it the old way */ @@ -122,7 +118,7 @@ m_remove(struct Client *client_p, struct Client *source_p, int parc, const char { sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), get_id(&me, source_p), get_id(source_p, source_p), name); - return 0; + return; } } @@ -131,12 +127,12 @@ m_remove(struct Client *client_p, struct Client *source_p, int parc, const char * There are two cases we can get to this point then... * * 1) connect burst is happening, and for some reason a legit - * op has sent a KICK, but the SJOIN hasn't happened yet or + * op has sent a KICK, but the SJOIN hasn't happened yet or * been seen. (who knows.. due to lag...) * * 2) The channel is desynced. That can STILL happen with TS - * - * Now, the old code roger wrote, would allow the KICK to + * + * Now, the old code roger wrote, would allow the KICK to * go through. Thats quite legit, but lets weird things like * KICKS by users who appear not to be chanopped happen, * or even neater, they appear not to be on the channel. @@ -155,7 +151,7 @@ m_remove(struct Client *client_p, struct Client *source_p, int parc, const char if(!(who = find_chasing(source_p, user, &chasing))) { - return 0; + return; } msptr = find_channel_membership(chptr, who); @@ -166,7 +162,7 @@ m_remove(struct Client *client_p, struct Client *source_p, int parc, const char { sendto_one(source_p, form_str(ERR_ISCHANSERVICE), me.name, source_p->name, who->name, chptr->chname); - return 0; + return; } if(MyClient(source_p)) @@ -178,11 +174,12 @@ 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); if (!hookdata.approved) - return 0; + return; } comment = LOCAL_COPY((EmptyString(parv[3])) ? who->name : parv[3]); @@ -196,7 +193,7 @@ m_remove(struct Client *client_p, struct Client *source_p, int parc, const char * - Personally, flame and I believe that server kicks shouldn't * be sent anyways. Just waiting for some oper to abuse it... */ - sendto_channel_local(ALL_MEMBERS, chptr, + sendto_channel_local(who, ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :requested by %s (%s)", who->name, who->username, who->host, name, source_p->name, comment); @@ -213,7 +210,17 @@ m_remove(struct Client *client_p, struct Client *source_p, int parc, const char else if (MyClient(source_p)) sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL, form_str(ERR_USERNOTINCHANNEL), user, name); - - 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; +}