]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
m_monitor Add inline keyword to IRCv3::Monitor::Manager::ExtItem::unserialize to...
[user/henk/code/inspircd.git] / src / channels.cpp
index a2d5c4a30f1831c8a72fcc63ff83c51c78ce330e..7f2485a49903ebcf4ebe34b77432bc4da7bf555f 100644 (file)
@@ -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));
 }
@@ -562,6 +570,13 @@ const char* Channel::ChanModes(bool showkey)
        return scratch.c_str();
 }
 
+void Channel::WriteNotice(const std::string& text)
+{
+       std::string rawmsg = "NOTICE ";
+       rawmsg.append(this->name).append(" :").append(text);
+       WriteChannelWithServ(ServerInstance->Config->ServerName, rawmsg);
+}
+
 /* returns the status character for a given user on a channel, e.g. @ for op,
  * % for halfop etc. If the user has several modes set, the highest mode
  * the user has must be returned.