]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/motd.cpp
Fix m_chanlog crashing.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / motd.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 "socketengine.h"
22
23 #include "m_spanningtree/main.h"
24 #include "m_spanningtree/utils.h"
25 #include "m_spanningtree/treeserver.h"
26 #include "m_spanningtree/link.h"
27 #include "m_spanningtree/treesocket.h"
28 #include "m_spanningtree/resolvers.h"
29 #include "m_spanningtree/handshaketimer.h"
30
31 /* $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 */
32
33 /** remote MOTD. leet, huh? */
34 bool TreeSocket::Motd(const std::string &prefix, std::deque<std::string> &params)
35 {
36         if (params.size() > 0)
37         {
38                 if (this->Instance->MatchText(this->Instance->Config->ServerName, params[0]))
39                 {
40                         /* It's for our server */
41                         string_list results;
42                         User* source = this->Instance->FindNick(prefix);
43
44                         if (source)
45                         {
46                                 std::deque<std::string> par;
47                                 par.push_back(prefix);
48                                 par.push_back("");
49
50                                 if (!Instance->Config->MOTD.size())
51                                 {
52                                         par[1] = std::string("::")+Instance->Config->ServerName+" 422 "+source->nick+" :Message of the day file is missing.";
53                                         Utils->DoOneToOne(this->Instance->Config->GetSID(), "PUSH",par, source->server);
54                                         return true;
55                                 }
56
57                                 par[1] = std::string("::")+Instance->Config->ServerName+" 375 "+source->nick+" :"+Instance->Config->ServerName+" message of the day";
58                                 Utils->DoOneToOne(this->Instance->Config->GetSID(), "PUSH",par, source->server);
59
60                                 for (unsigned int i = 0; i < Instance->Config->MOTD.size(); i++)
61                                 {
62                                         par[1] = std::string("::")+Instance->Config->ServerName+" 372 "+source->nick+" :- "+Instance->Config->MOTD[i];
63                                         Utils->DoOneToOne(this->Instance->Config->GetSID(), "PUSH",par, source->server);
64                                 }
65
66                                 par[1] = std::string("::")+Instance->Config->ServerName+" 376 "+source->nick+" :End of message of the day.";
67                                 Utils->DoOneToOne(this->Instance->Config->GetSID(), "PUSH",par, source->server);
68                         }
69                 }
70                 else
71                 {
72                         /* Pass it on */
73                         User* source = this->Instance->FindNick(prefix);
74                         if (source)
75                                 Utils->DoOneToOne(prefix, "MOTD", params, params[0]);
76                 }
77         }
78         return true;
79 }
80