]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/ftopic.cpp
Move lots of spanningtree items to commands
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / ftopic.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2010 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 "commands.h"
16
17 #include "treesocket.h"
18 #include "treeserver.h"
19 #include "utils.h"
20
21 /** FTOPIC command */
22 CmdResult CommandFTopic::Handle(const std::vector<std::string>& params, User *user)
23 {
24         time_t ts = atoi(params[1].c_str());
25         Channel* c = ServerInstance->FindChan(params[0]);
26         if (c)
27         {
28                 if ((ts >= c->topicset) || (c->topic.empty()))
29                 {
30                         if (c->topic != params[3])
31                         {
32                                 // Update topic only when it differs from current topic
33                                 c->topic.assign(params[3], 0, ServerInstance->Config->Limits.MaxTopic);
34                                 c->WriteChannel(user, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str());
35                         }
36
37                         // Always update setter and settime.
38                         c->setby.assign(params[2], 0, 127);
39                         c->topicset = ts;
40                 }
41         }
42         return CMD_SUCCESS;
43 }
44