]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/commands/cmd_stats.cpp
Resolve /STATS S conflict between SVSHOLD and SHUN
[user/henk/code/inspircd.git] / src / commands / cmd_stats.cpp
index e3961a9069165b8e3eb4895c6ae811075672292a..55279627ce1786a1af4bd59c038369b973f8f778 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
  * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
@@ -36,7 +36,7 @@ class CommandStats : public Command
  public:
        /** Constructor for stats.
         */
-       CommandStats (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"STATS",0,1) { syntax = "<stats-symbol> [<servername>]"; }
+       CommandStats ( Module* parent) : Command(parent,"STATS",1,2) { syntax = "<stats-symbol> [<servername>]"; }
        /** Handle command.
         * @param parameters The parameters to the comamnd
         * @param pcnt The number of parameters passed to teh command
@@ -44,23 +44,23 @@ class CommandStats : public Command
         * @return A value from CmdResult to indicate command success or failure.
         */
        CmdResult Handle(const std::vector<std::string>& parameters, User *user);
+       RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
+       {
+               if (parameters.size() > 1)
+                       return ROUTE_UNICAST(parameters[1]);
+               return ROUTE_LOCALONLY;
+       }
 };
 
 CmdResult CommandStats::Handle (const std::vector<std::string>& parameters, User *user)
 {
-       if (IS_LOCAL(user))
-       {
-               string_list values;
-               if (parameters[0].empty())
-               {
-                       user->WriteNumeric(ERR_NEEDMOREPARAMS, "%s STATS :Not enough parameters.", user->nick.c_str());
-                       return CMD_FAILURE;
-               }
-               char search = parameters[0][0];
-               ServerInstance->DoStats(search, user, values);
-               for (size_t i = 0; i < values.size(); i++)
-                       user->Write(":%s", values[i].c_str());
-       }
+       if (parameters.size() > 1 && parameters[1] != ServerInstance->Config->ServerName)
+               return CMD_SUCCESS;
+       string_list values;
+       char search = parameters[0][0];
+       ServerInstance->DoStats(search, user, values);
+       for (size_t i = 0; i < values.size(); i++)
+               user->SendText(":%s", values[i].c_str());
 
        return CMD_SUCCESS;
 }