]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/whois.cpp
Remove spanningtree override of /LUSERS
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / whois.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 "socket.h"
16 #include "xline.h"
17 #include "socketengine.h"
18
19 #include "main.h"
20 #include "utils.h"
21 #include "treeserver.h"
22 #include "treesocket.h"
23
24 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
25
26 bool TreeSocket::Whois(const std::string &prefix, parameterlist &params)
27 {
28         if (params.size() < 1)
29                 return true;
30         User* u = ServerInstance->FindNick(prefix);
31         if (u)
32         {
33                 // an incoming request
34                 if (params.size() == 1)
35                 {
36                         User* x = ServerInstance->FindNick(params[0]);
37                         if ((x) && (IS_LOCAL(x)))
38                         {
39                                 char signon[MAXBUF];
40                                 char idle[MAXBUF];
41                                 snprintf(signon, MAXBUF, "%lu", (unsigned long)x->signon);
42                                 snprintf(idle, MAXBUF, "%lu", (unsigned long)abs((long)((x->idle_lastmsg) - ServerInstance->Time())));
43                                 parameterlist par;
44                                 par.push_back(prefix);
45                                 par.push_back(signon);
46                                 par.push_back(idle);
47                                 // ours, we're done, pass it BACK
48                                 Utils->DoOneToOne(params[0], "IDLE", par, u->server);
49                         }
50                         else
51                         {
52                                 // not ours pass it on
53                                 if (x)
54                                         Utils->DoOneToOne(prefix, "IDLE", params, x->server);
55                         }
56                 }
57                 else if (params.size() == 3)
58                 {
59                         std::string who_did_the_whois = params[0];
60                         User* who_to_send_to = ServerInstance->FindNick(who_did_the_whois);
61                         if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
62                         {
63                                 // an incoming reply to a whois we sent out
64                                 std::string nick_whoised = prefix;
65                                 unsigned long signon = atoi(params[1].c_str());
66                                 unsigned long idle = atoi(params[2].c_str());
67                                 if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
68                                 {
69                                         ServerInstance->DoWhois(who_to_send_to, u, signon, idle, nick_whoised.c_str());
70                                 }
71                         }
72                         else
73                         {
74                                 // not ours, pass it on
75                                 if (who_to_send_to)
76                                         Utils->DoOneToOne(prefix, "IDLE", params, who_to_send_to->server);
77                         }
78                 }
79         }
80         return true;
81 }
82
83