diff options
-rw-r--r-- | include/channels.h | 2 | ||||
-rw-r--r-- | include/modules.h | 5 | ||||
-rw-r--r-- | modules/commands/cs_topic.cpp | 4 | ||||
-rw-r--r-- | modules/extra/stats/irc2sql/irc2sql.cpp | 2 | ||||
-rw-r--r-- | modules/extra/stats/irc2sql/irc2sql.h | 2 | ||||
-rw-r--r-- | modules/extra/stats/m_chanstats.cpp | 7 | ||||
-rw-r--r-- | modules/protocol/bahamut.cpp | 4 | ||||
-rw-r--r-- | modules/protocol/hybrid.cpp | 2 | ||||
-rw-r--r-- | modules/protocol/inspircd12.cpp | 2 | ||||
-rw-r--r-- | modules/protocol/ngircd.cpp | 8 | ||||
-rw-r--r-- | modules/protocol/ratbox.cpp | 2 | ||||
-rw-r--r-- | modules/protocol/unreal.cpp | 2 | ||||
-rw-r--r-- | src/channels.cpp | 14 | ||||
-rw-r--r-- | src/messages.cpp | 2 |
14 files changed, 27 insertions, 31 deletions
diff --git a/include/channels.h b/include/channels.h index 9bc6c27c6..80459d357 100644 --- a/include/channels.h +++ b/include/channels.h @@ -258,7 +258,7 @@ class CoreExport Channel : public Base, public Extensible * @param newtopic The new topic * @param ts The time the new topic is being set */ - void ChangeTopicInternal(const Anope::string &user, const Anope::string &newtopic, time_t ts = Anope::CurTime); + void ChangeTopicInternal(User *u, const Anope::string &user, const Anope::string &newtopic, time_t ts = Anope::CurTime); /** Update the topic of the channel, and reset it if topiclock etc says to * @param user The user setting the topic diff --git a/include/modules.h b/include/modules.h index 0569fd33f..5ea35c888 100644 --- a/include/modules.h +++ b/include/modules.h @@ -474,11 +474,12 @@ class CoreExport Module : public Extensible virtual void OnJoinChannel(User *u, Channel *c) { throw NotImplementedException(); } /** Called when a new topic is set + * @param source The user changing the topic, if any * @param c The channel - * @param setter The user who set the new topic + * @param setter The user who set the new topic, if there is no source * @param topic The new topic */ - virtual void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) { throw NotImplementedException(); } + virtual void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) { throw NotImplementedException(); } /** Called before a channel expires * @param ci The channel diff --git a/modules/commands/cs_topic.cpp b/modules/commands/cs_topic.cpp index 1506bcc9c..353cf83a3 100644 --- a/modules/commands/cs_topic.cpp +++ b/modules/commands/cs_topic.cpp @@ -227,7 +227,7 @@ class CSTopic : public Module } } - void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) anope_override + void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) anope_override { if (!c->ci) return; @@ -237,7 +237,7 @@ class CSTopic : public Module * This desyncs what is really set with what we have stored, and we end up resetting the topic often when * it is not required */ - if (topiclock.HasExt(c->ci) && c->ci->last_topic != c->topic) + if (topiclock.HasExt(c->ci) && c->ci->last_topic != c->topic && (!source || !c->ci->AccessFor(source).HasPriv("TOPIC"))) { c->ChangeTopic(c->ci->last_topic_setter, c->ci->last_topic, c->ci->last_topic_time); } diff --git a/modules/extra/stats/irc2sql/irc2sql.cpp b/modules/extra/stats/irc2sql/irc2sql.cpp index fd0ca5890..87ede04fd 100644 --- a/modules/extra/stats/irc2sql/irc2sql.cpp +++ b/modules/extra/stats/irc2sql/irc2sql.cpp @@ -243,7 +243,7 @@ void IRC2SQL::OnLeaveChannel(User *u, Channel *c) this->RunQuery(query); } -void IRC2SQL::OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) +void IRC2SQL::OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) { query = "UPDATE `" + prefix + "chan` " "SET topic=@topic@, topicauthor=@author@, topictime=FROM_UNIXTIME(@time@) " diff --git a/modules/extra/stats/irc2sql/irc2sql.h b/modules/extra/stats/irc2sql/irc2sql.h index 0c516f5e3..1ed5790aa 100644 --- a/modules/extra/stats/irc2sql/irc2sql.h +++ b/modules/extra/stats/irc2sql/irc2sql.h @@ -69,7 +69,7 @@ class IRC2SQL : public Module EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string ¶m) anope_override; EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string ¶m) anope_override; - void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) anope_override; + void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) anope_override; void OnBotNotice(User *u, BotInfo *bi, Anope::string &message) anope_override; }; diff --git a/modules/extra/stats/m_chanstats.cpp b/modules/extra/stats/m_chanstats.cpp index 7a2fe0486..27b1b3eae 100644 --- a/modules/extra/stats/m_chanstats.cpp +++ b/modules/extra/stats/m_chanstats.cpp @@ -517,14 +517,13 @@ class MChanstats : public Module info.AddOption(_("Chanstats")); } - void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) anope_override + void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) anope_override { - User *u = User::Find(user); - if (!u || !u->Account() || !c->ci || !cs_stats.HasExt(c->ci)) + if (!source || !source->Account() || !c->ci || !cs_stats.HasExt(c->ci)) return; query = "CALL " + prefix + "chanstats_proc_update(@channel@, @nick@, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);"; query.SetValue("channel", c->name); - query.SetValue("nick", GetDisplay(u)); + query.SetValue("nick", GetDisplay(source)); this->RunQuery(query); } diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index a399ecece..4e193da01 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -461,11 +461,11 @@ struct IRCDMessageTopic : IRCDMessage { IRCDMessageTopic(Module *creator) : IRCDMessage(creator, "TOPIC", 4) { } - void Run(MessageSource &, const std::vector<Anope::string> ¶ms) anope_override + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { Channel *c = Channel::Find(params[0]); if (c) - c->ChangeTopicInternal(params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime); + c->ChangeTopicInternal(source.GetUser(), params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime); } }; diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index 52c442dc3..b6ee17d45 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -512,7 +512,7 @@ struct IRCDMessageTBurst : IRCDMessage Channel *c = Channel::Find(params[1]); if (c) - c->ChangeTopicInternal(setter, params[4], topic_time); + c->ChangeTopicInternal(NULL, setter, params[4], topic_time); } }; diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 5fb226d99..192a783fe 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -998,7 +998,7 @@ struct IRCDMessageFTopic : IRCDMessage Channel *c = Channel::Find(params[0]); if (c) - c->ChangeTopicInternal(params[2], params[3], Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime); + c->ChangeTopicInternal(NULL, params[2], params[3], Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime); } }; diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 61613423e..28f68007b 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -257,7 +257,7 @@ struct IRCDMessageChaninfo : IRCDMessage if (params.size() == 3) { - c->ChangeTopicInternal(source.GetName(), params[2], Anope::CurTime); + c->ChangeTopicInternal(NULL, source.GetName(), params[2], Anope::CurTime); } else if (params.size() == 5) { @@ -271,9 +271,9 @@ struct IRCDMessageChaninfo : IRCDMessage case 'l': modes += " " + params[3]; continue; + } } - } - c->ChangeTopicInternal(source.GetName(), params[4], Anope::CurTime); + c->ChangeTopicInternal(NULL, source.GetName(), params[4], Anope::CurTime); } c->SetModesInternal(source, modes); @@ -590,7 +590,7 @@ struct IRCDMessageTopic : IRCDMessage Log(LOG_DEBUG) << "TOPIC for nonexistant channel " << params[0]; return; } - c->ChangeTopicInternal(source.GetName(), params[1], Anope::CurTime); + c->ChangeTopicInternal(source.GetUser(), source.GetName(), params[1], Anope::CurTime); } }; diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index 8fd9a30cf..8ccabd604 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -185,7 +185,7 @@ struct IRCDMessageTBurst : IRCDMessage const Anope::string &setter = params.size() == 4 ? params[2] : "", topic = params.size() == 4 ? params[3] : params[2]; - c->ChangeTopicInternal(setter, topic, topic_time); + c->ChangeTopicInternal(NULL, setter, topic, topic_time); } }; diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 40cb1fe70..1bb0db657 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -1146,7 +1146,7 @@ struct IRCDMessageTopic : IRCDMessage { Channel *c = Channel::Find(params[0]); if (c) - c->ChangeTopicInternal(params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime); + c->ChangeTopicInternal(source.GetUser(), params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime); } }; diff --git a/src/channels.cpp b/src/channels.cpp index b1038f69e..7e7702d7e 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -789,26 +789,22 @@ bool Channel::Kick(BotInfo *bi, User *u, const char *reason, ...) return true; } -void Channel::ChangeTopicInternal(const Anope::string &user, const Anope::string &newtopic, time_t ts) +void Channel::ChangeTopicInternal(User *u, const Anope::string &user, const Anope::string &newtopic, time_t ts) { - User *u = User::Find(user); - this->topic = newtopic; this->topic_setter = u ? u->nick : user; this->topic_ts = ts; this->topic_time = Anope::CurTime; - Log(LOG_DEBUG) << "Topic of " << this->name << " changed by " << (u ? u->nick : user) << " to " << newtopic; + Log(LOG_DEBUG) << "Topic of " << this->name << " changed by " << this->topic_setter << " to " << newtopic; - FOREACH_MOD(OnTopicUpdated, (this, user, this->topic)); + FOREACH_MOD(OnTopicUpdated, (u, this, user, this->topic)); } void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtopic, time_t ts) { - User *u = User::Find(user); - this->topic = newtopic; - this->topic_setter = u ? u->nick : user; + this->topic_setter = user; this->topic_ts = ts; IRCD->SendTopic(this->ci->WhoSends(), this); @@ -816,7 +812,7 @@ void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtop /* Now that the topic is set update the time set. This is *after* we set it so the protocol modules are able to tell the old last set time */ this->topic_time = Anope::CurTime; - FOREACH_MOD(OnTopicUpdated, (this, user, this->topic)); + FOREACH_MOD(OnTopicUpdated, (NULL, this, user, this->topic)); } void Channel::SetCorrectModes(User *user, bool give_modes) diff --git a/src/messages.cpp b/src/messages.cpp index a771b2f1f..4e1bcd0db 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -472,7 +472,7 @@ void Topic::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Channel *c = Channel::Find(params[0]); if (c) - c->ChangeTopicInternal(source.GetSource(), params[1], Anope::CurTime); + c->ChangeTopicInternal(source.GetUser(), source.GetSource(), params[1], Anope::CurTime); return; } |