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
7 modules/protocol/ngircd.cpp | 60 +++++++++++++++++++++++++++++++++++++++---
8 1 files changed, 55 insertions(+), 5 deletions(-)
10 diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp
11 index 7f4186e..3024fdd 100644
12 --- a/modules/protocol/ngircd.cpp
13 +++ b/modules/protocol/ngircd.cpp
14 @@ -240,16 +240,58 @@ class ngIRCdIRCdMessage : public IRCdMessage
18 + Anope::string channel, mode;
19 size_t pos = params[0].find('\7');
20 if (pos != Anope::string::npos)
22 - Anope::string channel = params[0].substr(0, pos);
23 - Anope::string mode = '+' + params[0].substr(pos, params[0].length()) + " " + source;
24 - do_join(source, channel, "");
25 - do_cmode(source, channel, mode, "");
26 + channel = params[0].substr(0, pos);
27 + mode = '+' + params[0].substr(pos+1, params[0].length()) + " " + source;
30 - do_join(source, params[0], "");
31 + channel = params[0];
33 + Channel *c = findchan(channel);
37 + c = new Channel(channel, Anope::CurTime);
38 + c->SetFlag(CH_SYNCING);
41 + User *u = finduser(source);
45 + Log(LOG_DEBUG) << "JOIN for nonexistant user " << source << " on " << channel;
49 + EventReturn MOD_RESULT;
50 + FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c));
52 + /* Add the user to the channel */
55 + /* set the usermodes to the channel */
56 + do_cmode(source, channel, mode, "");
58 + /* Now set whatever modes this user is allowed to have on the channel */
59 + chan_set_correct_modes(u, c, 1);
61 + /* Check to see if modules want the user to join, if they do
62 + * check to see if they are allowed to join (CheckKick will kick/ban them)
63 + * Don't trigger OnJoinChannel event then as the user will be destroyed
65 + if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u))
68 + FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c));
70 + if (c->HasFlag(CH_SYNCING))
72 + c->UnsetFlag(CH_SYNCING);
78 @@ -491,7 +533,15 @@ class ProtongIRCd : public Module
79 pmodule_ircd_message(&this->ircd_message);
83 + ModuleManager::Attach(I_OnUserNickChange, this);
86 + void OnUserNickChange(User *u, const Anope::string &)
88 + u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED));
93 MODULE_INIT(ProtongIRCd)