unrealircd

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

noinvite.c (2459B)

      1 /*
      2  * Disallow invites UnrealIRCd Module (Channel Mode +V)
      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 CMD_FUNC(noinvite);
     23 
     24 ModuleHeader MOD_HEADER
     25   = {
     26 	"chanmodes/noinvite",
     27 	"4.2",
     28 	"Channel Mode +V",
     29 	"UnrealIRCd Team",
     30 	"unrealircd-6",
     31     };
     32 
     33 Cmode_t EXTCMODE_NOINVITE;
     34 
     35 #define IsNoInvite(channel)    (channel->mode.mode & EXTCMODE_NOINVITE)
     36 
     37 int noinvite_pre_knock(Client *client, Channel *channel, const char **reason);
     38 int noinvite_pre_invite(Client *client, Client *target, Channel *channel, int *override);
     39 
     40 MOD_TEST()
     41 {
     42 	return MOD_SUCCESS;
     43 }
     44 
     45 MOD_INIT()
     46 {
     47 	CmodeInfo req;
     48 
     49 	memset(&req, 0, sizeof(req));
     50 	req.paracount = 0;
     51 	req.letter = 'V';
     52 	req.is_ok = extcmode_default_requirechop;
     53 	CmodeAdd(modinfo->handle, req, &EXTCMODE_NOINVITE);
     54 	
     55 	HookAdd(modinfo->handle, HOOKTYPE_PRE_KNOCK, 0, noinvite_pre_knock);
     56 	HookAdd(modinfo->handle, HOOKTYPE_PRE_INVITE, 0, noinvite_pre_invite);
     57 	
     58 	MARK_AS_OFFICIAL_MODULE(modinfo);
     59 	return MOD_SUCCESS;
     60 }
     61 
     62 MOD_LOAD()
     63 {
     64 	return MOD_SUCCESS;
     65 }
     66 
     67 MOD_UNLOAD()
     68 {
     69 	return MOD_SUCCESS;
     70 }
     71 
     72 
     73 int noinvite_pre_knock(Client *client, Channel *channel, const char **reason)
     74 {
     75 	if (MyUser(client) && IsNoInvite(channel))
     76 	{
     77 		sendnumeric(client, ERR_CANNOTKNOCK, channel->name,
     78 		            "The channel does not allow invites (+V)");
     79 		return HOOK_DENY;
     80 	}
     81 
     82 	return HOOK_CONTINUE;
     83 }
     84 
     85 int noinvite_pre_invite(Client *client, Client *target, Channel *channel, int *override)
     86 {
     87 	if (MyUser(client) && IsNoInvite(channel))
     88 	{
     89 		if (ValidatePermissionsForPath("channel:override:invite:noinvite",client,NULL,channel,NULL) && client == target)
     90 		{
     91 			*override = 1;
     92 		} else {
     93 			sendnumeric(client, ERR_NOINVITE, channel->name);
     94 			return HOOK_DENY;
     95 		}
     96 	}
     97 
     98 	return HOOK_CONTINUE;
     99 }