]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/ftopic.cpp
Update all wiki links to point to the new wiki. This was done automatically with...
[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 "m_spanningtree/treesocket.h"
18 #include "m_spanningtree/treeserver.h"
19 #include "m_spanningtree/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                                         c->WriteChannelWithServ(ServerInstance->Config->ServerName, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str());
43                                 }
44                                 else
45                                 {
46                                         c->WriteChannel(user, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str());
47                                 }
48                         }
49
50                         // Always update setter and settime.
51                         c->setby.assign(params[2], 0, 127);
52                         c->topicset = ts;
53
54                         /* all done, send it on its way */
55                         params[3] = ":" + params[3];
56                         Utils->DoOneToAllButSender(source,"FTOPIC",params,source);
57                 }
58
59         }
60         return true;
61 }
62