Our server pr0vider carried out maintenance on 15 January 2020 but it corrupted some files in the process. If you notice anything out of the ordinary (partial files, pages not loading, that kind of shit) then let us know at:

m_needauthjoin.c 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Copyright (C) All Rights Reserved
  2. ** Written by Gottem <support@gottem.nl>
  3. ** Website: https://gitgud.malvager.net/Wazakindjes/unrealircd_mods
  4. ** License: https://gitgud.malvager.net/Wazakindjes/unrealircd_mods/raw/master/LICENSE
  5. */
  6. // One include for all cross-platform compatibility thangs
  7. #include "unrealircd.h"
  8. #define MYHEWK HOOKTYPE_CAN_JOIN
  9. #define CHMODE_FLAG 'A' // tfw no relevant flags nemore kek
  10. // Quality fowod declarations
  11. int needauthjoin_canjoin(aClient *sptr, aChannel *chptr, char *key, char *parv[]);
  12. // Muh globals
  13. static ModuleInfo *needauthjoinMI = NULL; // Store ModuleInfo so we can use it to check for errors in MOD_LOAD
  14. Hook *needauthjoinHook = NULL;
  15. Cmode_t needauthjoin_extcmode = 0L; // Store bitwise value latur
  16. // Dat dere module header
  17. ModuleHeader MOD_HEADER(m_needauthjoin) = {
  18. "m_needauthjoin", // Module name
  19. "$Id: v1.0 2018/08/12 Gottem$", // Version
  20. "Require authentication with services before users are able to join channels (with exceptions)", // Description
  21. "3.2-b8-1", // Modversion, not sure wat do
  22. NULL
  23. };
  24. // Initialisation routine (register hooks, commands and modes or create structs etc)
  25. MOD_INIT(m_needauthjoin) {
  26. needauthjoinMI = modinfo; // Store module info yo
  27. // Make sure we run early lol
  28. needauthjoinHook = HookAdd(modinfo->handle, MYHEWK, -999, needauthjoin_canjoin);
  29. // Request the mode flag
  30. CmodeInfo cmodereq;
  31. memset(&cmodereq, 0, sizeof(cmodereq));
  32. cmodereq.flag = CHMODE_FLAG; // Flag yo
  33. cmodereq.paracount = 0; // How many params?
  34. cmodereq.is_ok = extcmode_default_requirechop; // For paramless modes that simply require +o/+a/+q etc
  35. CmodeAdd(modinfo->handle, cmodereq, &needauthjoin_extcmode); // Now finally add the mode lol
  36. return MOD_SUCCESS; // Let MOD_LOAD handle errors and shyte
  37. }
  38. // Actually load the module here
  39. MOD_LOAD(m_needauthjoin) {
  40. // Check if module handle is available, also check for commands/hooks/overrides that weren't added for some raisin
  41. if(ModuleGetError(needauthjoinMI->handle) != MODERR_NOERROR || !needauthjoinHook || !needauthjoin_extcmode) {
  42. // Display error string kek
  43. config_error("A critical error occurred when loading module %s: %s", MOD_HEADER(m_needauthjoin).name, ModuleGetErrorStr(needauthjoinMI->handle));
  44. return MOD_FAILED; // No good
  45. }
  46. return MOD_SUCCESS; // We good
  47. }
  48. // Called on unload/rehash obv
  49. MOD_UNLOAD(m_needauthjoin) {
  50. // Clean up any structs and other shit here
  51. return MOD_SUCCESS; // We good
  52. }
  53. // Actual hewk functions m8
  54. int needauthjoin_canjoin(aClient *sptr, aChannel *chptr, char *key, char *parv[]) {
  55. // Let's allow opers and U:Lines always y0, also check for channel having +A set
  56. if(!IsPerson(sptr) || IsULine(sptr) || IsOper(sptr) || (chptr && (chptr->mode.extmode & needauthjoin_extcmode)))
  57. return HOOK_CONTINUE;
  58. if(!chptr || !IsLoggedIn(sptr))
  59. return ERR_NEEDREGGEDNICK;
  60. return HOOK_CONTINUE;
  61. }