unrealircd

- supernets unrealircd source & configuration
git clone git://git.acid.vegas/unrealircd.git
Log | Files | Refs | Archive | README | LICENSE

nokick.c (2218B)

      1 /*
      2  * No kicks in channel UnrealIRCd Module (Channel Mode +Q)
      3  * (C) Copyright 2014 Travis McArthur (Heero) and the UnrealIRCd team
      4  *
      5  * This program is free software; you can redistribute it and/or modify
      6  * it under the terms of the GNU General Public License as published by
      7  * the Free Software Foundation; either version 1, or (at your option)
      8  * any later version.
      9  *
     10  * This program is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  * GNU General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU General Public License
     16  * along with this program; if not, write to the Free Software
     17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18  */
     19 
     20 #include "unrealircd.h"
     21 
     22 
     23 ModuleHeader MOD_HEADER
     24   = {
     25 	"chanmodes/nokick",
     26 	"4.2",
     27 	"Channel Mode +Q",
     28 	"UnrealIRCd Team",
     29 	"unrealircd-6",
     30     };
     31 
     32 Cmode_t EXTCMODE_NOKICK;
     33 
     34 #define IsNoKick(channel)    (channel->mode.mode & EXTCMODE_NOKICK)
     35 
     36 int nokick_check (Client *client, Client *target, Channel *channel, const char *comment, const char *client_member_modes, const char *target_member_modes, const char **reject_reason);
     37 
     38 MOD_TEST()
     39 {
     40 	return MOD_SUCCESS;
     41 }
     42 
     43 MOD_INIT()
     44 {
     45 	CmodeInfo req;
     46 
     47 	memset(&req, 0, sizeof(req));
     48 	req.paracount = 0;
     49 	req.letter = 'Q';
     50 	req.is_ok = extcmode_default_requirechop;
     51 	CmodeAdd(modinfo->handle, req, &EXTCMODE_NOKICK);
     52 	
     53 	HookAdd(modinfo->handle, HOOKTYPE_CAN_KICK, 0, nokick_check);
     54 
     55 	
     56 	MARK_AS_OFFICIAL_MODULE(modinfo);
     57 	return MOD_SUCCESS;
     58 }
     59 
     60 MOD_LOAD()
     61 {
     62 	return MOD_SUCCESS;
     63 }
     64 
     65 MOD_UNLOAD()
     66 {
     67 	return MOD_SUCCESS;
     68 }
     69 
     70 int nokick_check (Client *client, Client *target, Channel *channel, const char *comment, const char *client_member_modes, const char *target_member_modes, const char **reject_reason)
     71 {
     72 	static char errmsg[256];
     73 
     74 	if (MyUser(client) && IsNoKick(channel))
     75 	{
     76 		ircsnprintf(errmsg, sizeof(errmsg), ":%s %d %s %s :%s",
     77 		            me.name, ERR_CANNOTDOCOMMAND, client->name,
     78 		            "KICK", "channel is +Q");
     79 		*reject_reason = errmsg;
     80 		return EX_DENY; /* Deny, but let opers override if necessary. */
     81 	}
     82 
     83 	return EX_ALLOW;
     84 }
     85