unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
noexternalmsgs.c (2413B)
1 /* 2 * Channel Mode +n 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/noexternalmsgs", 26 "6.0", 27 "Channel Mode +n", 28 "UnrealIRCd Team", 29 "unrealircd-6", 30 }; 31 32 Cmode_t EXTCMODE_NO_EXTERNAL_MESSAGES; 33 34 #define IsNoExternalMessages(channel) (channel->mode.mode & EXTCMODE_NO_EXTERNAL_MESSAGES) 35 36 int noexternalmsgs_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype); 37 38 MOD_INIT() 39 { 40 CmodeInfo req; 41 42 MARK_AS_OFFICIAL_MODULE(modinfo); 43 44 memset(&req, 0, sizeof(req)); 45 req.paracount = 0; 46 req.letter = 'n'; 47 req.is_ok = extcmode_default_requirehalfop; 48 CmodeAdd(modinfo->handle, req, &EXTCMODE_NO_EXTERNAL_MESSAGES); 49 50 HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_CHANNEL, 0, noexternalmsgs_can_send_to_channel); 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 noexternalmsgs_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype) 66 { 67 if (IsNoExternalMessages(channel) && !IsMember(client,channel)) 68 { 69 /* Channel does not accept external messages (+n). 70 * Reject, unless HOOKTYPE_CAN_BYPASS_NO_EXTERNAL_MSGS tells otherwise. 71 */ 72 Hook *h; 73 int i; 74 75 for (h = Hooks[HOOKTYPE_CAN_BYPASS_CHANNEL_MESSAGE_RESTRICTION]; h; h = h->next) 76 { 77 i = (*(h->func.intfunc))(client, channel, BYPASS_CHANMSG_EXTERNAL); 78 if (i == HOOK_ALLOW) 79 return HOOK_CONTINUE; /* bypass +n restriction */ 80 if (i != HOOK_CONTINUE) 81 break; 82 } 83 84 *errmsg = "No external channel messages"; 85 return HOOK_DENY; /* BLOCK message */ 86 } 87 88 return HOOK_CONTINUE; 89 }