]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/ftopic.cpp
f246d65c3bca748f1560da384079b192a1dc2b76
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / ftopic.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/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/cmd_whois.h"
16 #include "commands/cmd_stats.h"
17 #include "socket.h"
18 #include "wildcard.h"
19 #include "xline.h"
20 #include "transport.h"
21 #include "m_hash.h"
22 #include "socketengine.h"
23
24 #include "m_spanningtree/main.h"
25 #include "m_spanningtree/utils.h"
26 #include "m_spanningtree/treeserver.h"
27 #include "m_spanningtree/link.h"
28 #include "m_spanningtree/treesocket.h"
29 #include "m_spanningtree/resolvers.h"
30 #include "m_spanningtree/handshaketimer.h"
31
32 /* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_hash.h */
33
34 /** FTOPIC command */
35 bool TreeSocket::ForceTopic(const std::string &source, std::deque<std::string> &params)
36 {
37         if (params.size() != 4)
38                 return true;
39         time_t ts = atoi(params[1].c_str());
40         std::string nsource = source;
41         Channel* c = this->Instance->FindChan(params[0]);
42         if (c)
43         {
44                 if ((ts >= c->topicset) || (!*c->topic))
45                 {
46                         std::string oldtopic = c->topic;
47                         strlcpy(c->topic,params[3].c_str(),MAXTOPIC);
48                         strlcpy(c->setby,params[2].c_str(),127);
49                         c->topicset = ts;
50                         /* if the topic text is the same as the current topic,
51                          * dont bother to send the TOPIC command out, just silently
52                          * update the set time and set nick.
53                          */
54                         if (oldtopic != params[3])
55                         {
56                                 User* user = this->Instance->FindNick(source);
57                                 if (!user)
58                                 {
59                                         c->WriteChannelWithServ(Instance->Config->ServerName, "TOPIC %s :%s", c->name, c->topic);
60                                 }
61                                 else
62                                 {
63                                         c->WriteChannel(user, "TOPIC %s :%s", c->name, c->topic);
64                                         nsource = user->server;
65                                 }
66                         }
67
68                         /* all done, send it on its way */
69                         params[3] = ":" + params[3];
70                         Utils->DoOneToAllButSender(source,"FTOPIC",params,nsource);
71                 }
72
73         }
74         return true;
75 }
76