unrealircd

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

topiclimit.c (2062B)

      1 /*
      2  * Channel Mode +t
      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 
     23 ModuleHeader MOD_HEADER
     24   = {
     25 	"chanmodes/topiclimit",
     26 	"6.0",
     27 	"Channel Mode +t",
     28 	"UnrealIRCd Team",
     29 	"unrealircd-6",
     30     };
     31 
     32 /* Global variables */
     33 Cmode_t EXTCMODE_TOPIC_LIMIT;
     34 
     35 /* Forward declarations */
     36 int topiclimit_can_set_topic(Client *client, Channel *channel, const char *topic, const char **errmsg);
     37 
     38 /* Macros */
     39 #define IsTopicLimit(channel)    (channel->mode.mode & EXTCMODE_TOPIC_LIMIT)
     40 
     41 MOD_INIT()
     42 {
     43 	CmodeInfo req;
     44 
     45 	MARK_AS_OFFICIAL_MODULE(modinfo);
     46 
     47 	memset(&req, 0, sizeof(req));
     48 	req.paracount = 0;
     49 	req.letter = 't';
     50 	req.is_ok = extcmode_default_requirehalfop;
     51 	CmodeAdd(modinfo->handle, req, &EXTCMODE_TOPIC_LIMIT);
     52 
     53 	HookAdd(modinfo->handle, HOOKTYPE_CAN_SET_TOPIC, 0, topiclimit_can_set_topic);
     54 	return MOD_SUCCESS;
     55 }
     56 
     57 MOD_LOAD()
     58 {
     59 	return MOD_SUCCESS;
     60 }
     61 
     62 MOD_UNLOAD()
     63 {
     64 	return MOD_SUCCESS;
     65 }
     66 
     67 int topiclimit_can_set_topic(Client *client, Channel *channel, const char *topic, const char **errmsg)
     68 {
     69 	static char errmsg_buf[NICKLEN+256];
     70 
     71 	if (has_channel_mode(channel, 't') &&
     72 	    !check_channel_access(client, channel, "hoaq") &&
     73 	    !IsULine(client) &&
     74 	    !IsServer(client))
     75 	{
     76 		buildnumeric(errmsg_buf, sizeof(errmsg_buf), client, ERR_CHANOPRIVSNEEDED, channel->name);
     77 		*errmsg = errmsg_buf;
     78 		return EX_DENY;
     79 	}
     80 
     81 	return EX_ALLOW;
     82 }