summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-01-10 03:30:43 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-01-10 03:30:43 +0000
commitde69e28a4a1aea89e410b693bbbb67890ecb0bd3 (patch)
treeb9da19d1807977da003b710d97283bfd63766a9c /src/commands
parent3cd1a24a51b9560a6dd6590b4a384f6b6942370d (diff)
Remove spanningtree override of /LUSERS
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12247 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/cmd_lusers.cpp38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/commands/cmd_lusers.cpp b/src/commands/cmd_lusers.cpp
index a79466ae4..a8453fb66 100644
--- a/src/commands/cmd_lusers.cpp
+++ b/src/commands/cmd_lusers.cpp
@@ -28,10 +28,13 @@
*/
class CommandLusers : public Command
{
+ unsigned int max_local, max_global;
public:
/** Constructor for lusers.
*/
- CommandLusers ( Module* parent) : Command(parent,"LUSERS",0,0) { }
+ CommandLusers ( Module* parent) : Command(parent,"LUSERS",0,0),
+ max_local(0), max_global(0)
+ { }
/** Handle command.
* @param parameters The parameters to the comamnd
* @param pcnt The number of parameters passed to teh command
@@ -48,17 +51,40 @@ class CommandLusers : public Command
*/
CmdResult CommandLusers::Handle (const std::vector<std::string>&, User *user)
{
- // this lusers command shows one server at all times because
- // a protocol module must override it to show those stats.
- user->WriteNumeric(251, "%s :There are %d users and %d invisible on 1 server",user->nick.c_str(),ServerInstance->Users->UserCount()-ServerInstance->Users->ModeCount('i'),ServerInstance->Users->ModeCount('i'));
+ unsigned int n_users = ServerInstance->Users->UserCount();
+ unsigned int n_invis = ServerInstance->Users->ModeCount('i');
+ ProtoServerList serverlist;
+ ServerInstance->PI->GetServerList(serverlist);
+ int n_serv = 1;
+ int n_local_servs = 0;
+ for(ProtoServerList::iterator i = serverlist.begin(); i != serverlist.end(); ++i)
+ {
+ n_serv++;
+ if (i->parentname == ServerInstance->Config->ServerName)
+ n_local_servs++;
+ }
+
+ // these are updated on every connect (or /lusers invocation), which is good enough
+ if (ServerInstance->Users->LocalUserCount() > max_local)
+ max_local = ServerInstance->Users->LocalUserCount();
+ if (n_users > max_global)
+ max_global = n_users;
+
+ user->WriteNumeric(251, "%s :There are %d users and %d invisible on %d servers",user->nick.c_str(),
+ n_users, n_users-n_invis, n_serv);
+
if (ServerInstance->Users->OperCount())
user->WriteNumeric(252, "%s %d :operator(s) online",user->nick.c_str(),ServerInstance->Users->OperCount());
+
if (ServerInstance->Users->UnregisteredUserCount())
user->WriteNumeric(253, "%s %d :unknown connections",user->nick.c_str(),ServerInstance->Users->UnregisteredUserCount());
+
if (ServerInstance->ChannelCount())
user->WriteNumeric(254, "%s %ld :channels formed",user->nick.c_str(),ServerInstance->ChannelCount());
- if (ServerInstance->Users->LocalUserCount())
- user->WriteNumeric(255, "%s :I have %d clients and 0 servers",user->nick.c_str(),ServerInstance->Users->LocalUserCount());
+
+ user->WriteNumeric(255, "%s :I have %d clients and %d servers",user->nick.c_str(),ServerInstance->Users->LocalUserCount(),n_local_servs);
+ user->WriteNumeric(265, "%s :Current Local Users: %d Max: %d",user->nick.c_str(),ServerInstance->Users->LocalUserCount(),max_local);
+ user->WriteNumeric(266, "%s :Current Global Users: %d Max: %d",user->nick.c_str(),n_users,max_global);
return CMD_SUCCESS;
}