unrealircd

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

noctcp.c (2102B)

      1 /*
      2  * Block CTCP UnrealIRCd Module (Channel Mode +C)
      3  * (C) Copyright 2000-.. Bram Matthys (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 CMD_FUNC(noctcp);
     23 
     24 ModuleHeader MOD_HEADER
     25   = {
     26 	"chanmodes/noctcp",
     27 	"4.2",
     28 	"Channel Mode +C",
     29 	"UnrealIRCd Team",
     30 	"unrealircd-6",
     31     };
     32 
     33 Cmode_t EXTCMODE_NOCTCP;
     34 
     35 #define IsNoCTCP(channel)    (channel->mode.mode & EXTCMODE_NOCTCP)
     36 
     37 int noctcp_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype);
     38 
     39 MOD_TEST()
     40 {
     41 	return MOD_SUCCESS;
     42 }
     43 
     44 MOD_INIT()
     45 {
     46 CmodeInfo req;
     47 
     48 	memset(&req, 0, sizeof(req));
     49 	req.paracount = 0;
     50 	req.letter = 'C';
     51 	req.is_ok = extcmode_default_requirehalfop;
     52 	CmodeAdd(modinfo->handle, req, &EXTCMODE_NOCTCP);
     53 	
     54 	HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_CHANNEL, 0, noctcp_can_send_to_channel);
     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 static int IsACTCP(const char *s)
     71 {
     72 	if (!s)
     73 		return 0;
     74 
     75 	if ((*s == '\001') && strncmp(&s[1], "ACTION ", 7))
     76 		return 1;
     77 
     78 	return 0;
     79 }
     80 
     81 int noctcp_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype)
     82 {
     83 	if (IsNoCTCP(channel) && IsACTCP(*msg))
     84 	{
     85 		*errmsg = "CTCPs are not permitted in this channel";
     86 		return HOOK_DENY;
     87 	}
     88 	return HOOK_CONTINUE;
     89 }