]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_info/cmd_modules.cpp
Use CommandBase::Params instead of std::vector<std::string>.
[user/henk/code/inspircd.git] / src / coremods / core_info / cmd_modules.cpp
index cee3708704ed04d5d6355db9da96931d32684891..952b6bca25ca44f651df2599346550b1f4c88141 100644 (file)
 #include "inspircd.h"
 #include "core_info.h"
 
+enum
+{
+       // From ircd-ratbox with an InspIRCd-specific format.
+       RPL_MODLIST = 702,
+       RPL_ENDOFMODLIST = 703
+};
+
 CommandModules::CommandModules(Module* parent)
-       : Command(parent, "MODULES", 0, 0)
+       : ServerTargetCommand(parent, "MODULES")
 {
        Penalty = 4;
        syntax = "[<servername>]";
@@ -31,7 +38,7 @@ CommandModules::CommandModules(Module* parent)
 
 /** Handle /MODULES
  */
-CmdResult CommandModules::Handle (const std::vector<std::string>& parameters, User *user)
+CmdResult CommandModules::Handle(User* user, const Params& parameters)
 {
        // Don't ask remote servers about their modules unless the local user asking is an oper
        // 2.0 asks anyway, so let's handle that the same way
@@ -58,35 +65,25 @@ CmdResult CommandModules::Handle (const std::vector<std::string>& parameters, Us
 
                if (IS_LOCAL(user) && user->HasPrivPermission("servers/auspex"))
                {
-                       std::string flags("SvcC");
-                       int pos = 0;
-                       for (int mult = 1; mult <= VF_OPTCOMMON; mult *= 2, ++pos)
+                       std::string flags("VCO");
+                       size_t pos = 0;
+                       for (int mult = 2; mult <= VF_OPTCOMMON; mult *= 2, ++pos)
                                if (!(V.Flags & mult))
                                        flags[pos] = '-';
 
-#ifdef PURE_STATIC
-                       user->SendText(":%s 702 %s :%p %s %s :%s", ServerInstance->Config->ServerName.c_str(),
-                               user->nick.c_str(), (void*)m, m->ModuleSourceFile.c_str(), flags.c_str(), V.description.c_str());
+#ifdef INSPIRCD_STATIC
+                       user->WriteRemoteNumeric(RPL_MODLIST, m->ModuleSourceFile, INSPIRCD_VERSION, flags, V.description);
 #else
                        std::string srcrev = m->ModuleDLLManager->GetVersion();
-                       user->SendText(":%s 702 %s :%p %s %s :%s - %s", ServerInstance->Config->ServerName.c_str(),
-                               user->nick.c_str(), (void*)m, m->ModuleSourceFile.c_str(), flags.c_str(), V.description.c_str(), srcrev.c_str());
+                       user->WriteRemoteNumeric(RPL_MODLIST, m->ModuleSourceFile, srcrev.empty() ? "*" : srcrev, flags, V.description);
 #endif
                }
                else
                {
-                       user->SendText(":%s 702 %s :%s %s", ServerInstance->Config->ServerName.c_str(),
-                               user->nick.c_str(), m->ModuleSourceFile.c_str(), V.description.c_str());
+                       user->WriteRemoteNumeric(RPL_MODLIST, m->ModuleSourceFile, '*', '*', V.description);
                }
        }
-       user->SendText(":%s 703 %s :End of MODULES list", ServerInstance->Config->ServerName.c_str(), user->nick.c_str());
+       user->WriteRemoteNumeric(RPL_ENDOFMODLIST, "End of MODULES list");
 
        return CMD_SUCCESS;
 }
-
-RouteDescriptor CommandModules::GetRouting(User* user, const std::vector<std::string>& parameters)
-{
-       if (parameters.size() >= 1)
-               return ROUTE_UNICAST(parameters[0]);
-       return ROUTE_LOCALONLY;
-}