unrealircd

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

operonly.c (3123B)

      1 /*
      2  * Disallow knocks UnrealIRCd Module (Channel Mode +K)
      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(operonly);
     23 
     24 ModuleHeader MOD_HEADER
     25   = {
     26 	"chanmodes/operonly",
     27 	"4.2",
     28 	"Channel Mode +O",
     29 	"UnrealIRCd Team",
     30 	"unrealircd-6",
     31     };
     32 
     33 Cmode_t EXTCMODE_OPERONLY;
     34 
     35 int operonly_require_oper(Client *client, Channel *channel, char mode, const char *para, int checkt, int what);
     36 int operonly_can_join(Client *client, Channel *channel, const char *key, char **errmsg);
     37 int operonly_view_topic_outside_channel(Client *client, Channel *channel);
     38 int operonly_invite_bypass(Client *client, Channel *channel);
     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 = 'O';
     52 	req.is_ok = operonly_require_oper;
     53 	CmodeAdd(modinfo->handle, req, &EXTCMODE_OPERONLY);
     54 	
     55 	HookAdd(modinfo->handle, HOOKTYPE_CAN_JOIN, 0, operonly_can_join);
     56 	HookAdd(modinfo->handle, HOOKTYPE_INVITE_BYPASS, 0, operonly_invite_bypass);
     57 	HookAdd(modinfo->handle, HOOKTYPE_VIEW_TOPIC_OUTSIDE_CHANNEL, 0, operonly_view_topic_outside_channel);
     58 
     59 	
     60 	MARK_AS_OFFICIAL_MODULE(modinfo);
     61 	return MOD_SUCCESS;
     62 }
     63 
     64 MOD_LOAD()
     65 {
     66 	return MOD_SUCCESS;
     67 }
     68 
     69 MOD_UNLOAD()
     70 {
     71 	return MOD_SUCCESS;
     72 }
     73 
     74 int operonly_can_join(Client *client, Channel *channel, const char *key, char **errmsg)
     75 {
     76 	if ((channel->mode.mode & EXTCMODE_OPERONLY) && !ValidatePermissionsForPath("channel:operonly:join",client,NULL,channel,NULL))
     77 	{
     78 		*errmsg = STR_ERR_OPERONLY;
     79 		return ERR_OPERONLY;
     80 	}
     81 	return 0;
     82 }
     83 
     84 int operonly_invite_bypass(Client *client, Channel *channel)
     85 {
     86 	 if ((channel->mode.mode & EXTCMODE_OPERONLY) && !ValidatePermissionsForPath("channel:operonly:ban",client,NULL,NULL,NULL))
     87 		 return HOOK_DENY;
     88 
     89 	 return HOOK_CONTINUE;
     90 }
     91 
     92 int operonly_view_topic_outside_channel(Client *client, Channel *channel)
     93 {
     94 	if (channel->mode.mode & EXTCMODE_OPERONLY && !ValidatePermissionsForPath("channel:operonly:topic",client,NULL,channel,NULL))
     95 		return HOOK_DENY;
     96 
     97 	return HOOK_CONTINUE;
     98 }
     99 
    100 int operonly_require_oper(Client *client, Channel *channel, char mode, const char *para, int checkt, int what)
    101 {
    102 	if (!MyUser(client) || ValidatePermissionsForPath("channel:operonly:set",client,NULL,channel,NULL))
    103 		return EX_ALLOW;
    104 
    105 	if (checkt == EXCHK_ACCESS_ERR)
    106 		sendnumeric(client, ERR_CANNOTCHANGECHANMODE, 'O', "You are not an IRC operator");
    107 
    108 	return EX_DENY;
    109 }
    110