0007-ngircd-Fix-handling-of-JOIN-commands.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. From 4c9300ede35310ee5642f34e5ac227bd96fc7384 Mon Sep 17 00:00:00 2001
  2. From: DukePyrolator <DukePyrolator@anope.org>
  3. Date: Sun, 4 Sep 2011 15:08:55 +0200
  4. Subject: [PATCH 07/16] ngircd: Fix handling of JOIN commands
  5. ---
  6. modules/protocol/ngircd.cpp | 60 +++++++++++++++++++++++++++++++++++++++---
  7. 1 files changed, 55 insertions(+), 5 deletions(-)
  8. diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp
  9. index 7f4186e..3024fdd 100644
  10. --- a/modules/protocol/ngircd.cpp
  11. +++ b/modules/protocol/ngircd.cpp
  12. @@ -240,16 +240,58 @@ class ngIRCdIRCdMessage : public IRCdMessage
  13. {
  14. if (!params.empty())
  15. {
  16. + Anope::string channel, mode;
  17. size_t pos = params[0].find('\7');
  18. if (pos != Anope::string::npos)
  19. {
  20. - Anope::string channel = params[0].substr(0, pos);
  21. - Anope::string mode = '+' + params[0].substr(pos, params[0].length()) + " " + source;
  22. - do_join(source, channel, "");
  23. - do_cmode(source, channel, mode, "");
  24. + channel = params[0].substr(0, pos);
  25. + mode = '+' + params[0].substr(pos+1, params[0].length()) + " " + source;
  26. }
  27. else
  28. - do_join(source, params[0], "");
  29. + channel = params[0];
  30. +
  31. + Channel *c = findchan(channel);
  32. +
  33. + if (!c)
  34. + {
  35. + c = new Channel(channel, Anope::CurTime);
  36. + c->SetFlag(CH_SYNCING);
  37. + }
  38. +
  39. + User *u = finduser(source);
  40. +
  41. + if (!u)
  42. + {
  43. + Log(LOG_DEBUG) << "JOIN for nonexistant user " << source << " on " << channel;
  44. + return false;
  45. + }
  46. +
  47. + EventReturn MOD_RESULT;
  48. + FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c));
  49. +
  50. + /* Add the user to the channel */
  51. + c->JoinUser(u);
  52. +
  53. + /* set the usermodes to the channel */
  54. + do_cmode(source, channel, mode, "");
  55. +
  56. + /* Now set whatever modes this user is allowed to have on the channel */
  57. + chan_set_correct_modes(u, c, 1);
  58. +
  59. + /* Check to see if modules want the user to join, if they do
  60. + * check to see if they are allowed to join (CheckKick will kick/ban them)
  61. + * Don't trigger OnJoinChannel event then as the user will be destroyed
  62. + */
  63. + if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u))
  64. + return false;
  65. +
  66. + FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c));
  67. +
  68. + if (c->HasFlag(CH_SYNCING))
  69. + {
  70. + c->UnsetFlag(CH_SYNCING);
  71. + c->Sync();
  72. + }
  73. }
  74. return true;
  75. }
  76. @@ -491,7 +533,15 @@ class ProtongIRCd : public Module
  77. pmodule_ircd_message(&this->ircd_message);
  78. this->AddModes();
  79. +
  80. + ModuleManager::Attach(I_OnUserNickChange, this);
  81. }
  82. +
  83. + void OnUserNickChange(User *u, const Anope::string &)
  84. + {
  85. + u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED));
  86. + }
  87. +
  88. };
  89. MODULE_INIT(ProtongIRCd)
  90. --
  91. 1.7.8.3