X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fchannels.cpp;h=7f2485a49903ebcf4ebe34b77432bc4da7bf555f;hb=1e09b2cb1e2a5989163fff02cad5498ad151bd00;hp=14b1ea54534b3559750e1e2594db4858ff338575;hpb=cee5a82d95fc3f5d3670ef483998bfc2d4a5a82e;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/channels.cpp b/src/channels.cpp index 14b1ea545..7f2485a49 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -46,12 +46,20 @@ void Channel::SetMode(ModeHandler* mh, bool on) modes[mh->GetId()] = on; } -void Channel::SetTopic(User* u, const std::string& ntopic) +void Channel::SetTopic(User* u, const std::string& ntopic, time_t topicts, const std::string* setter) { - this->topic.assign(ntopic, 0, ServerInstance->Config->Limits.MaxTopic); - this->setby.assign(ServerInstance->Config->FullHostInTopic ? u->GetFullHost() : u->nick, 0, 128); - this->WriteChannel(u, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str()); - this->topicset = ServerInstance->Time(); + // Send a TOPIC message to the channel only if the new topic text differs + if (this->topic != ntopic) + { + this->topic = ntopic; + this->WriteChannel(u, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str()); + } + + // Always update setter and set time + if (!setter) + setter = ServerInstance->Config->FullHostInTopic ? &u->GetFullHost() : &u->nick; + this->setby.assign(*setter, 0, ServerInstance->Config->Limits.GetMaxMask()); + this->topicset = topicts; FOREACH_MOD(OnPostTopicChange, (u, this, this->topic)); }