0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-03 02:28:55 +02:00
construct/extensions/chm_operpeace.cc
Jason Volk 61b517ca3c Precompile and remove most include directives. Notes:
* To benefit from the precompiled-header (PCH) it MUST provide "the first C token."

Advantages:
Never worry about the include stack again. Remember, this means one less thing
for random module developers, community people learning C++, and new developers
to deal with. It should reduce the learning curve and barrier for participation.

Disadvantages:
Makes overall compilation a bit slower, especially without any additional
work to improve it again. There are several opportunities, places where the
PCH is probably being ignored, etc that can be addressed.
2016-08-20 19:30:33 -07:00

57 lines
1.2 KiB
C++

/*
* Do not allow operators to be kicked from +M channels.
* -- kaniini
*/
using namespace ircd;
static const char chm_operpeace_desc[] =
"Adds channel mode +M which prohibits operators from being kicked";
static void hdl_can_kick(hook_data_channel_approval *);
mapi_hfn_list_av1 chm_operpeace_hfnlist[] = {
{ "can_kick", (hookfn) hdl_can_kick },
{ NULL, NULL }
};
static unsigned int mymode;
static int
_modinit(void)
{
mymode = cflag_add('M', CHM_D, chm_hidden);
if (mymode == 0)
return -1;
return 0;
}
static void
_moddeinit(void)
{
cflag_orphan('M');
}
DECLARE_MODULE_AV2(chm_operpeace, _modinit, _moddeinit, NULL, NULL, chm_operpeace_hfnlist, NULL, NULL, chm_operpeace_desc);
static void
hdl_can_kick(hook_data_channel_approval *data)
{
struct Client *source_p = data->client;
struct Client *who = data->target;
struct Channel *chptr = data->chptr;
if(IsOper(source_p))
return;
if((chptr->mode.mode & mymode) && IsOper(who))
{
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s attempted to kick %s from %s (which is +M)",
source_p->name, who->name, chptr->chname);
sendto_one_numeric(source_p, ERR_ISCHANSERVICE, "%s %s :Cannot kick IRC operators from that channel.",
who->name, chptr->chname);
data->approved = 0;
}
}