Advertisement
Mrmot

* usermode +D: makes it so you cannot receive private messa

Sep 14th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  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(privdeaf)
  9. = {
  10. "privdeaf",
  11. "v1.2",
  12. "Private Messages Deaf (+D) -- by Syzop",
  13. "3.2-b8-1",
  14. NULL
  15. };
  16.  
  17. static long UMODE_PRIVDEAF = 0;
  18. static Umode *UmodePrivdeaf = NULL;
  19.  
  20. char *privdeaf_checkmsg(aClient *, aClient *, char *, int);
  21.  
  22. MOD_INIT(privdeaf)
  23. {
  24. UmodePrivdeaf = UmodeAdd(modinfo->handle, 'D', UMODE_GLOBAL, 0, umode_allow_all, &UMODE_PRIVDEAF);
  25. if (!UmodePrivdeaf)
  26. {
  27. /* I use config_error() here because it's printed to stderr in case of a load
  28. * on cmd line, and to all opers in case of a /rehash.
  29. */
  30. config_error("privdeaf: Could not add usermode 'D': %s", ModuleGetErrorStr(modinfo->handle));
  31. return MOD_FAILED;
  32. }
  33.  
  34. HookAddPChar(modinfo->handle, HOOKTYPE_PRE_USERMSG, 0, privdeaf_checkmsg);
  35.  
  36. return MOD_SUCCESS;
  37. }
  38.  
  39. MOD_LOAD(privdeaf)
  40. {
  41. return MOD_SUCCESS;
  42. }
  43.  
  44. MOD_UNLOAD(privdeaf)
  45. {
  46. return MOD_SUCCESS;
  47. }
  48.  
  49. char *privdeaf_checkmsg(aClient *sptr, aClient *acptr, char *text, int notice)
  50. {
  51. if ((acptr->umodes & UMODE_PRIVDEAF) && !IsOper(sptr) &&
  52. !IsULine(sptr) && !IsServer(sptr) && (sptr != acptr))
  53. {
  54. sendnotice(sptr, "Message to '%s' not delivered: User does not accept private messages", acptr->name);
  55. return NULL;
  56. } else
  57. return text;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement