unrealircd

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

chanowner.c (2155B)

      1 /*
      2  * Channel Mode +q
      3  * (C) Copyright 2021 Syzop 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 ModuleHeader MOD_HEADER
     23   = {
     24 	"chanmodes/chanowner",
     25 	"6.0",
     26 	"Channel Mode +q",
     27 	"UnrealIRCd Team",
     28 	"unrealircd-6",
     29     };
     30 
     31 /* Forward declarations */
     32 int cmode_chanowner_is_ok(Client *client, Channel *channel, char mode, const char *para, int type, int what);
     33 
     34 MOD_INIT()
     35 {
     36 	CmodeInfo creq;
     37 	ModDataInfo mreq;
     38 
     39 	MARK_AS_OFFICIAL_MODULE(modinfo);
     40 
     41 	memset(&creq, 0, sizeof(creq));
     42 	creq.paracount = 1;
     43 	creq.is_ok = cmode_chanowner_is_ok;
     44 	creq.letter = 'q';
     45 	creq.prefix = '~';
     46 	creq.sjoin_prefix = '*';
     47 	creq.rank = RANK_CHANOWNER;
     48 	creq.unset_with_param = 1;
     49 	creq.type = CMODE_MEMBER;
     50 	CmodeAdd(modinfo->handle, creq, NULL);
     51 
     52 	return MOD_SUCCESS;
     53 }
     54 
     55 MOD_LOAD()
     56 {
     57 	return MOD_SUCCESS;
     58 }
     59 
     60 MOD_UNLOAD()
     61 {
     62 	return MOD_SUCCESS;
     63 }
     64 
     65 int cmode_chanowner_is_ok(Client *client, Channel *channel, char mode, const char *param, int type, int what)
     66 {
     67 	if ((type == EXCHK_ACCESS) || (type == EXCHK_ACCESS_ERR))
     68 	{
     69 		Client *target = find_user(param, NULL);
     70 
     71 		if ((what == MODE_DEL) && (client == target))
     72 		{
     73 			/* User may always remove their own modes */
     74 			return EX_ALLOW;
     75 		}
     76 		if (check_channel_access(client, channel, "q"))
     77 		{
     78 			/* only +q people may do +q/-q */
     79 			return EX_ALLOW;
     80 		}
     81 		if (type == EXCHK_ACCESS_ERR)
     82 			sendnumeric(client, ERR_CHANOWNPRIVNEEDED, channel->name);
     83 		return EX_DENY;
     84 	}
     85 
     86 	/* fallthrough -- should not be used */
     87 	return EX_DENY;
     88 }