]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/ftopic.cpp
First phase of conversion to dynamic limits on all the lengths, configured via the...
[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 "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         std::string nsource = source;
31         Channel* c = this->Instance->FindChan(params[0]);
32         if (c)
33         {
34                 if ((ts >= c->topicset) || (c->topic.empty()))
35                 {
36                         std::string oldtopic = c->topic;
37                         c->topic.assign(params[3], 0, Instance->Config->Limits.MaxTopic);
38                         c->setby.assign(params[2], 0, 127);
39                         c->topicset = ts;
40                         /* if the topic text is the same as the current topic,
41                          * dont bother to send the TOPIC command out, just silently
42                          * update the set time and set nick.
43                          */
44                         if (oldtopic != params[3])
45                         {
46                                 User* user = this->Instance->FindNick(source);
47                                 if (!user)
48                                 {
49                                         c->WriteChannelWithServ(Instance->Config->ServerName, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str());
50                                 }
51                                 else
52                                 {
53                                         c->WriteChannel(user, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str());
54                                         nsource = user->server;
55                                 }
56                         }
57
58                         /* all done, send it on its way */
59                         params[3] = ":" + params[3];
60                         User* u = Instance->FindNick(nsource);
61                         if (u)
62                                 Utils->DoOneToAllButSender(u->uuid,"FTOPIC",params,u->server);
63                         else
64                                 Utils->DoOneToAllButSender(source,"FTOPIC",params,nsource);
65                 }
66
67         }
68         return true;
69 }
70