-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSTATUSCommand.cc
123 lines (108 loc) · 4.48 KB
/
STATUSCommand.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* STATUSCommand.cc
*
* 04/01/2004 - Reed Loden <[email protected]>
* Initial Version
*
* Display the status of chanfix
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id$
*/
#include <string>
#include <sys/resource.h>
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "chanfix.h"
#include "defs.h"
#include "responses.h"
#include "Network.h"
RCSTAG("$Id$");
namespace gnuworld
{
namespace cf
{
void STATUSCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
bot->SendTo(theClient, "[evilnet development's GNUWorld %s]",
VERSION);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_uptime,
std::string("Uptime: \002%s\002")).c_str(),
bot->prettyDuration(bot->getUplink()->getStartTime()).c_str());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_auto_fixing,
std::string("Automatic fixing is: \002%s\002")).c_str(),
bot->doAutoFix() ? "ON" : "OFF");
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_manual_fixing,
std::string("Manual fixing is: \002%s\002")).c_str(),
bot->doChanFix() ? "ON" : "OFF");
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_chan_blocking,
std::string("Channel blocking is: \002%s\002")).c_str(),
bot->doChanBlocking() ? "ON" : "OFF");
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_servers_amount,
std::string("Required amount of servers linked is %u%% of %u, which is a minimum of %u servers.")).c_str(),
bot->getMinServersPresent(), bot->getNumServers(),
((bot->getMinServersPresent() * bot->getNumServers()) / 100 + 1));
if (bot->getState() == chanfix::SPLIT)
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_splitmode_enabled,
std::string("Splitmode enabled: only %i servers linked.")).c_str(),
Network->serverList_size());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_splitmode_disabled,
std::string("Splitmode disabled. There are %i servers linked.")).c_str(),
Network->serverList_size());
if (bot->isChanServLinked())
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_channel_service_linked,
std::string("Channel service linked. New channels will be scored.")).c_str());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_channel_service_not_linked,
std::string("Channel service not linked. New channels will not be scored.")).c_str());
bot->SendTo(theClient,
std::string("Number of channels being autofixed: %i").c_str(),bot->countAutoFixes());
bot->SendTo(theClient,
std::string("Number of channels being manually fixed: %i").c_str(),bot->countManFixes());
int who = RUSAGE_SELF;
struct rusage usage;
int ret;
ret = getrusage(who, &usage);
bot->SendTo(theClient,
std::string("Memory Usage (kB): %ld").c_str(), usage.ru_maxrss);
bot->logAdminMessage("%s (%s) STATUS",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld