diff options
author | Adam <Adam@anope.org> | 2016-11-05 10:36:28 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2017-04-07 14:56:19 -0400 |
commit | 0276620f160b58a61e095bea1b4ff215d6de3891 (patch) | |
tree | be7880f4dd7e5ce2c6c400c21d44e3925b27d925 /modules | |
parent | c2c8f703b44f7712ea308d8f1f3a4e8c9bcb30c7 (diff) |
irc2sql: fix changing status modes to update ison modes
Diffstat (limited to 'modules')
-rw-r--r-- | modules/extra/stats/irc2sql/irc2sql.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/modules/extra/stats/irc2sql/irc2sql.cpp b/modules/extra/stats/irc2sql/irc2sql.cpp index 3596a4f4b..247364049 100644 --- a/modules/extra/stats/irc2sql/irc2sql.cpp +++ b/modules/extra/stats/irc2sql/irc2sql.cpp @@ -227,10 +227,32 @@ void IRC2SQL::OnJoinChannel(User *u, Channel *c) EventReturn IRC2SQL::OnChannelModeSet(Channel *c, const MessageSource &setter, ChannelMode *mode, const Anope::string ¶m) { - query = "UPDATE `" + prefix + "chan` SET modes=@modes@ WHERE channel=@channel@"; - query.SetValue("channel", c->name); - query.SetValue("modes", c->GetModes(true,true)); - this->RunQuery(query); + if (mode->type == MODE_STATUS) + { + User *u = User::Find(param); + if (u == NULL) + return EVENT_CONTINUE; + + ChanUserContainer *cc = u->FindChannel(c); + if (cc == NULL) + return EVENT_CONTINUE; + + query = "UPDATE `" + prefix + "user` AS u, `" + prefix + "ison` AS i, `" + prefix + "chan` AS c" + " SET i.modes=@modes@" + " WHERE u.nick=@nick@ AND c.channel=@channel@" + " AND u.nickid = i.nickid AND c.chanid = i.chanid"; + query.SetValue("nick", u->nick); + query.SetValue("modes", cc->status.Modes()); + query.SetValue("channel", c->name); + this->RunQuery(query); + } + else + { + query = "UPDATE `" + prefix + "chan` SET modes=@modes@ WHERE channel=@channel@"; + query.SetValue("channel", c->name); + query.SetValue("modes", c->GetModes(true,true)); + this->RunQuery(query); + } return EVENT_CONTINUE; } |