unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
privdeaf.c (1469B)
1 /* 2 * usermode +D: makes it so you cannot receive private messages/notices 3 * except from opers, U-lines and servers. -- Syzop 4 */ 5 6 #include "unrealircd.h" 7 8 ModuleHeader MOD_HEADER 9 = { 10 "usermodes/privdeaf", 11 "1.2", 12 "Private Messages Deaf (+D) -- by Syzop", 13 "UnrealIRCd Team", 14 "unrealircd-6", 15 }; 16 17 static long UMODE_PRIVDEAF = 0; 18 static Umode *UmodePrivdeaf = NULL; 19 20 int privdeaf_can_send_to_user(Client *client, Client *target, const char **text, const char **errmsg, SendType sendtype); 21 22 MOD_INIT() 23 { 24 MARK_AS_OFFICIAL_MODULE(modinfo); 25 UmodePrivdeaf = UmodeAdd(modinfo->handle, 'D', UMODE_GLOBAL, 0, umode_allow_all, &UMODE_PRIVDEAF); 26 if (!UmodePrivdeaf) 27 { 28 /* I use config_error() here because it's printed to stderr in case of a load 29 * on cmd line, and to all opers in case of a /rehash. 30 */ 31 config_error("privdeaf: Could not add usermode 'D': %s", ModuleGetErrorStr(modinfo->handle)); 32 return MOD_FAILED; 33 } 34 35 HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_USER, 0, privdeaf_can_send_to_user); 36 37 return MOD_SUCCESS; 38 } 39 40 MOD_LOAD() 41 { 42 return MOD_SUCCESS; 43 } 44 45 MOD_UNLOAD() 46 { 47 return MOD_SUCCESS; 48 } 49 50 int privdeaf_can_send_to_user(Client *client, Client *target, const char **text, const char **errmsg, SendType sendtype) 51 { 52 if ((target->umodes & UMODE_PRIVDEAF) && !IsOper(client) && 53 !IsULine(client) && !IsServer(client) && (client != target)) 54 { 55 *errmsg = "User does not accept private messages"; 56 return HOOK_DENY; 57 } 58 return HOOK_CONTINUE; 59 }