unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
nonotice.c (2384B)
1 /* 2 * Disallow notices in channel UnrealIRCd Module (Channel Mode +T) 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 ModuleHeader MOD_HEADER 23 = { 24 "chanmodes/nonotice", 25 "4.2", 26 "Channel Mode +T", 27 "UnrealIRCd Team", 28 "unrealircd-6", 29 }; 30 31 Cmode_t EXTCMODE_NONOTICE; 32 33 #define IsNoNotice(channel) (channel->mode.mode & EXTCMODE_NONOTICE) 34 35 int nonotice_check_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype); 36 37 MOD_TEST() 38 { 39 return MOD_SUCCESS; 40 } 41 42 MOD_INIT() 43 { 44 CmodeInfo req; 45 46 memset(&req, 0, sizeof(req)); 47 req.paracount = 0; 48 req.letter = 'T'; 49 req.is_ok = extcmode_default_requirechop; 50 CmodeAdd(modinfo->handle, req, &EXTCMODE_NONOTICE); 51 52 HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_CHANNEL, 0, nonotice_check_can_send_to_channel); 53 54 MARK_AS_OFFICIAL_MODULE(modinfo); 55 return MOD_SUCCESS; 56 } 57 58 MOD_LOAD() 59 { 60 return MOD_SUCCESS; 61 } 62 63 MOD_UNLOAD() 64 { 65 return MOD_SUCCESS; 66 } 67 68 int nonotice_check_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype) 69 { 70 Hook *h; 71 int i; 72 73 if ((sendtype == SEND_TYPE_NOTICE) && 74 IsNoNotice(channel) && 75 !check_channel_access_membership(lp, "oaq")) 76 { 77 for (h = Hooks[HOOKTYPE_CAN_BYPASS_CHANNEL_MESSAGE_RESTRICTION]; h; h = h->next) 78 { 79 i = (*(h->func.intfunc))(client, channel, BYPASS_CHANMSG_NOTICE); 80 if (i == HOOK_ALLOW) 81 return HOOK_CONTINUE; /* bypass restriction */ 82 if (i != HOOK_CONTINUE) 83 break; 84 } 85 *errmsg = "NOTICEs are not permitted in this channel"; 86 return HOOK_DENY; /* block notice */ 87 } 88 89 return HOOK_CONTINUE; 90 }