]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/ftopic.cpp
8ba5f90ab177e43f47850b694d60684adad1eb84
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / ftopic.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "xline.h"
16
17 #include "treesocket.h"
18 #include "treeserver.h"
19 #include "utils.h"
20
21 /* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
22
23
24 /** FTOPIC command */
25 bool TreeSocket::ForceTopic(const std::string &source, std::deque<std::string> &params)
26 {
27         if (params.size() != 4)
28                 return true;
29         time_t ts = atoi(params[1].c_str());
30         Channel* c = this->ServerInstance->FindChan(params[0]);
31         if (c)
32         {
33                 if ((ts >= c->topicset) || (c->topic.empty()))
34                 {
35                         if (c->topic != params[3])
36                         {
37                                 User* user = this->ServerInstance->FindNick(source);
38                                 // Update topic only when it differs from current topic
39                                 c->topic.assign(params[3], 0, ServerInstance->Config->Limits.MaxTopic);
40                                 if (!user)
41                                 {
42                                         std::string sourceserv = Utils->FindServer(source)->GetName();
43                                         c->WriteChannelWithServ(sourceserv.c_str(), "TOPIC %s :%s", c->name.c_str(), c->topic.c_str());
44                                 }
45                                 else
46                                 {
47                                         c->WriteChannel(user, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str());
48                                 }
49                         }
50
51                         // Always update setter and settime.
52                         c->setby.assign(params[2], 0, 127);
53                         c->topicset = ts;
54
55                         /* all done, send it on its way */
56                         params[3] = ":" + params[3];
57                         Utils->DoOneToAllButSender(source,"FTOPIC",params,source);
58                 }
59
60         }
61         return true;
62 }
63