1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
17 #include "m_spanningtree/treesocket.h"
18 #include "m_spanningtree/treeserver.h"
19 #include "m_spanningtree/utils.h"
21 /* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
25 bool TreeSocket::ForceTopic(const std::string &source, std::deque<std::string> ¶ms)
27 if (params.size() != 4)
29 time_t ts = atoi(params[1].c_str());
30 std::string nsource = source;
31 Channel* c = this->Instance->FindChan(params[0]);
34 if ((ts >= c->topicset) || (c->topic.empty()))
36 User* user = this->Instance->FindNick(source);
38 if (c->topic != params[3])
40 // Update topic only when it differs from current topic
41 c->topic.assign(params[3], 0, Instance->Config->Limits.MaxTopic);
44 c->WriteChannelWithServ(Instance->Config->ServerName, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str());
48 c->WriteChannel(user, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str());
52 // Always update setter and settime.
53 c->setby.assign(params[2], 0, 127);
57 * Take careful note of what happens here;
58 * Above, we display the topic change to the server IF the topic incoming is different to the topic already set.
59 * HERE, we find the server the user that sent this topic is on, so we *do not* send topics back to the link they just
60 * came from. This *cannot* be easily merged with the above check!
62 * Thanks to Anope and Namegduf for finally helping me isolate this
63 * -- w00t (5th/aug/2008)
67 nsource = user->server;
70 /* all done, send it on its way */
71 params[3] = ":" + params[3];
72 User* u = Instance->FindNick(nsource);
74 Utils->DoOneToAllButSender(u->uuid,"FTOPIC",params,u->server);
76 Utils->DoOneToAllButSender(source,"FTOPIC",params,nsource);