]> arthur.barton.de Git - ngircd-alex.git/blob - contrib/Anope/0007-ngircd-Fix-handling-of-JOIN-commands.patch
Merge branch 'bug109-CHARCONV'
[ngircd-alex.git] / contrib / Anope / 0007-ngircd-Fix-handling-of-JOIN-commands.patch
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 ---
7  modules/protocol/ngircd.cpp |   60 +++++++++++++++++++++++++++++++++++++++---
8  1 files changed, 55 insertions(+), 5 deletions(-)
9
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
15         {
16                 if (!params.empty())
17                 {
18 +                       Anope::string channel, mode;
19                         size_t pos = params[0].find('\7');
20                         if (pos != Anope::string::npos)
21                         {
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;
28                         }
29                         else
30 -                               do_join(source, params[0], "");
31 +                               channel = params[0];
32 +
33 +                       Channel *c = findchan(channel);
34 +
35 +                       if (!c)
36 +                       {
37 +                               c = new Channel(channel, Anope::CurTime);
38 +                               c->SetFlag(CH_SYNCING);
39 +                       }
40 +
41 +                       User *u = finduser(source);
42 +
43 +                       if (!u)
44 +                       {
45 +                               Log(LOG_DEBUG) << "JOIN for nonexistant user " << source << " on " << channel;
46 +                               return false;
47 +                       }
48 +
49 +                       EventReturn MOD_RESULT;
50 +                       FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c));
51 +
52 +                       /* Add the user to the channel */
53 +                       c->JoinUser(u);
54 +
55 +                       /* set the usermodes to the channel */
56 +                       do_cmode(source, channel, mode, "");
57 +
58 +                       /* Now set whatever modes this user is allowed to have on the channel */
59 +                       chan_set_correct_modes(u, c, 1);
60 +
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
64 +                        */
65 +                       if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u))
66 +                               return false;
67 +
68 +                       FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c));
69 +
70 +                       if (c->HasFlag(CH_SYNCING))
71 +                       {
72 +                               c->UnsetFlag(CH_SYNCING);
73 +                               c->Sync();
74 +                       }
75                 }
76                 return true;
77         }
78 @@ -491,7 +533,15 @@ class ProtongIRCd : public Module
79                 pmodule_ircd_message(&this->ircd_message);
80  
81                 this->AddModes();
82 +
83 +               ModuleManager::Attach(I_OnUserNickChange, this);
84         }
85 +
86 +       void OnUserNickChange(User *u, const Anope::string &)
87 +       {
88 +               u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED));
89 +       }
90 +
91  };
92  
93  MODULE_INIT(ProtongIRCd)
94 -- 
95 1.7.8.3
96