From: William Pitcock Date: Mon, 20 Apr 2009 14:20:11 +0000 (-0500) Subject: can_kick hook, based on the ircd-seven one. X-Git-Tag: proposed-charybdis-3.2.0~123 X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/commitdiff_plain/16d8d9fc6d5131eebc8fd10b4a025c0f8eda06f7?hp=ab45668d6a80c475818e929175ef19da4e0bf63e can_kick hook, based on the ircd-seven one. --- diff --git a/include/hook.h b/include/hook.h index b1bad11..120fe7c 100644 --- a/include/hook.h +++ b/include/hook.h @@ -29,6 +29,7 @@ extern int h_umode_changed; extern int h_new_local_user; extern int h_new_remote_user; extern int h_introduce_client; +extern int h_can_kick; void init_hook(void); int register_hook(const char *name); @@ -70,6 +71,14 @@ typedef struct char *key; } hook_data_channel_activity; +typedef struct +{ + struct Client *client; + struct Channel *chptr; + struct Client *target; + int approved; +} hook_data_channel_approval; + typedef struct { struct Client *client; diff --git a/modules/core/m_kick.c b/modules/core/m_kick.c index c87a1a5..88befac 100644 --- a/modules/core/m_kick.c +++ b/modules/core/m_kick.c @@ -37,6 +37,7 @@ #include "hash.h" #include "packet.h" #include "s_serv.h" +#include "hook.h" static int m_kick(struct Client *, struct Client *, int, const char **); #define mg_kick { m_kick, 3 } @@ -157,6 +158,21 @@ m_kick(struct Client *client_p, struct Client *source_p, int parc, const char *p return 0; } + if(MyClient(source_p)) + { + hook_data_channel_approval hookdata; + + hookdata.client = source_p; + hookdata.chptr = chptr; + hookdata.target = who; + hookdata.approved = 1; + + call_hook(h_can_kick, &hookdata); + + if (!hookdata.approved) + return 0; + } + comment = LOCAL_COPY((EmptyString(parv[3])) ? who->name : parv[3]); if(strlen(comment) > (size_t) REASONLEN) comment[REASONLEN] = '\0'; diff --git a/src/hook.c b/src/hook.c index 79a9a10..91b6413 100644 --- a/src/hook.c +++ b/src/hook.c @@ -63,6 +63,7 @@ int h_umode_changed; int h_new_local_user; int h_new_remote_user; int h_introduce_client; +int h_can_kick; void init_hook(void) @@ -85,6 +86,7 @@ init_hook(void) h_new_local_user = register_hook("new_local_user"); h_new_remote_user = register_hook("new_remote_user"); h_introduce_client = register_hook("introduce_client"); + h_can_kick = register_hook("can_kick"); } /* grow_hooktable()