1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 #ifndef __CMD_LUSERS_H__
17 #define __CMD_LUSERS_H__
19 // include the common header files
24 /** Handle /LUSERS. These command handlers can be reloaded by the core,
25 * and handle basic RFC1459 commands. Commands within modules work
26 * the same way, however, they can be fully unloaded, where these
29 class CommandLusers : public Command
31 unsigned int max_local, max_global;
33 /** Constructor for lusers.
35 CommandLusers ( Module* parent) : Command(parent,"LUSERS",0,0),
36 max_local(0), max_global(0)
39 * @param parameters The parameters to the comamnd
40 * @param pcnt The number of parameters passed to teh command
41 * @param user The user issuing the command
42 * @return A value from CmdResult to indicate command success or failure.
44 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
52 CmdResult CommandLusers::Handle (const std::vector<std::string>&, User *user)
54 unsigned int n_users = ServerInstance->Users->UserCount();
55 unsigned int n_invis = ServerInstance->Users->ModeCount('i');
56 ProtoServerList serverlist;
57 ServerInstance->PI->GetServerList(serverlist);
59 int n_local_servs = 0;
60 for(ProtoServerList::iterator i = serverlist.begin(); i != serverlist.end(); ++i)
63 if (i->parentname == ServerInstance->Config->ServerName)
67 // these are updated on every connect (or /lusers invocation), which is good enough
68 if (ServerInstance->Users->LocalUserCount() > max_local)
69 max_local = ServerInstance->Users->LocalUserCount();
70 if (n_users > max_global)
73 user->WriteNumeric(251, "%s :There are %d users and %d invisible on %d servers",user->nick.c_str(),
74 n_users, n_users-n_invis, n_serv);
76 if (ServerInstance->Users->OperCount())
77 user->WriteNumeric(252, "%s %d :operator(s) online",user->nick.c_str(),ServerInstance->Users->OperCount());
79 if (ServerInstance->Users->UnregisteredUserCount())
80 user->WriteNumeric(253, "%s %d :unknown connections",user->nick.c_str(),ServerInstance->Users->UnregisteredUserCount());
82 if (ServerInstance->ChannelCount())
83 user->WriteNumeric(254, "%s %ld :channels formed",user->nick.c_str(),ServerInstance->ChannelCount());
85 user->WriteNumeric(255, "%s :I have %d clients and %d servers",user->nick.c_str(),ServerInstance->Users->LocalUserCount(),n_local_servs);
86 user->WriteNumeric(265, "%s :Current Local Users: %d Max: %d",user->nick.c_str(),ServerInstance->Users->LocalUserCount(),max_local);
87 user->WriteNumeric(266, "%s :Current Global Users: %d Max: %d",user->nick.c_str(),n_users,max_global);
93 COMMAND_INIT(CommandLusers)