unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
regonlymsg.c (2134B)
1 /* 2 * Recieve private messages only from registered users (User mode +R) 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 #define IsRegOnlyMsg(client) (client->umodes & UMODE_REGONLYMSG) 23 24 /* Module header */ 25 ModuleHeader MOD_HEADER 26 = { 27 "usermodes/regonlymsg", 28 "4.2", 29 "User Mode +R", 30 "UnrealIRCd Team", 31 "unrealircd-6", 32 }; 33 34 /* Global variables */ 35 long UMODE_REGONLYMSG = 0L; 36 37 /* Forward declarations */ 38 int regonlymsg_can_send_to_user(Client *client, Client *target, const char **text, const char **errmsg, SendType sendtype); 39 40 MOD_INIT() 41 { 42 UmodeAdd(modinfo->handle, 'R', UMODE_GLOBAL, 0, umode_allow_all, &UMODE_REGONLYMSG); 43 44 HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_USER, 0, regonlymsg_can_send_to_user); 45 46 MARK_AS_OFFICIAL_MODULE(modinfo); 47 return MOD_SUCCESS; 48 } 49 50 MOD_LOAD() 51 { 52 return MOD_SUCCESS; 53 } 54 55 MOD_UNLOAD() 56 { 57 return MOD_SUCCESS; 58 } 59 60 int regonlymsg_can_send_to_user(Client *client, Client *target, const char **text, const char **errmsg, SendType sendtype) 61 { 62 if (IsRegOnlyMsg(target) && !IsServer(client) && !IsULine(client) && !IsLoggedIn(client)) 63 { 64 if (ValidatePermissionsForPath("client:override:message:regonlymsg",client,target,NULL,text?*text:NULL)) 65 return HOOK_CONTINUE; /* bypass this restriction */ 66 67 *errmsg = "You must identify to a registered nick to private message this user"; 68 return HOOK_DENY; 69 } 70 71 return HOOK_CONTINUE; 72 }