From 32d5702869fbe90a890890171d67853735a83cff Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Tue, 5 Jan 2016 18:44:17 -0600 Subject: [PATCH] extensions: add the ability to hide uncommon channels in WHOIS, like in ircd-seven (closes #6) --- extensions/Makefile.in | 1 + extensions/hide_uncommon_channels.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 extensions/hide_uncommon_channels.c diff --git a/extensions/Makefile.in b/extensions/Makefile.in index defab61e9..83927d1aa 100644 --- a/extensions/Makefile.in +++ b/extensions/Makefile.in @@ -79,6 +79,7 @@ SRCS = \ m_webirc.c \ m_remove.c \ m_roleplay.c \ + hide_uncommon_channels.c \ no_kill_services.c \ no_locops.c \ no_oper_invis.c \ diff --git a/extensions/hide_uncommon_channels.c b/extensions/hide_uncommon_channels.c new file mode 100644 index 000000000..3ba6b3eea --- /dev/null +++ b/extensions/hide_uncommon_channels.c @@ -0,0 +1,28 @@ +/* + * Override WHOIS logic to hide channel memberships that are not common. + * -- kaniini + */ + +#include "stdinc.h" +#include "modules.h" +#include "client.h" +#include "hook.h" +#include "ircd.h" +#include "send.h" +#include "s_conf.h" +#include "s_newconf.h" + +static void h_huc_doing_whois_channel_visibility(hook_data_client *); + +mapi_hfn_list_av1 huc_hfnlist[] = { + { "doing_whois_channel_visibility", (hookfn) h_huc_doing_whois_channel_visibility }, + { NULL, NULL } +}; + +DECLARE_MODULE_AV1(hide_uncommon_channels, NULL, NULL, NULL, NULL, huc_hfnlist, ""); + +static void +h_huc_doing_whois_channel_visibility(hook_data_client *hdata) +{ + hdata->approved = ((PubChannel(hdata->chptr) && !IsInvisible(hdata->target)) || IsMember((hdata->client), (hdata->chptr))); +}