summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/cmd_admin.cpp30
-rw-r--r--src/commands/cmd_stats.cpp26
-rw-r--r--src/commands/cmd_time.cpp25
3 files changed, 39 insertions, 42 deletions
diff --git a/src/commands/cmd_admin.cpp b/src/commands/cmd_admin.cpp
index 16e2c0ddd..7141ca14e 100644
--- a/src/commands/cmd_admin.cpp
+++ b/src/commands/cmd_admin.cpp
@@ -13,12 +13,6 @@
#include "inspircd.h"
-#ifndef __CMD_ADMIN_H__
-#define __CMD_ADMIN_H__
-
-#include "users.h"
-#include "channels.h"
-
/** Handle /ADMIN. These command handlers can be reloaded by the core,
* and handle basic RFC1459 commands. Commands within modules work
* the same way, however, they can be fully unloaded, where these
@@ -37,21 +31,29 @@ class CommandAdmin : 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() > 0)
+ return ROUTE_UNICAST(parameters[0]);
+ return ROUTE_LOCALONLY;
+ }
};
-#endif
-
-
-
/** Handle /ADMIN
*/
CmdResult CommandAdmin::Handle (const std::vector<std::string>& parameters, User *user)
{
- user->WriteNumeric(RPL_ADMINME, "%s :Administrative info for %s",user->nick.c_str(),ServerInstance->Config->ServerName.c_str());
+ if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName)
+ return CMD_SUCCESS;
+ user->SendText(":%s %03d %s :Administrative info for %s", ServerInstance->Config->ServerName.c_str(),
+ RPL_ADMINME, user->nick.c_str(),ServerInstance->Config->ServerName.c_str());
if (!ServerInstance->Config->AdminName.empty())
- user->WriteNumeric(RPL_ADMINLOC1, "%s :Name - %s",user->nick.c_str(),ServerInstance->Config->AdminName.c_str());
- user->WriteNumeric(RPL_ADMINLOC2, "%s :Nickname - %s",user->nick.c_str(),ServerInstance->Config->AdminNick.c_str());
- user->WriteNumeric(RPL_ADMINEMAIL, "%s :E-Mail - %s",user->nick.c_str(),ServerInstance->Config->AdminEmail.c_str());
+ user->SendText(":%s %03d %s :Name - %s", ServerInstance->Config->ServerName.c_str(),
+ RPL_ADMINLOC1, user->nick.c_str(), ServerInstance->Config->AdminName.c_str());
+ user->SendText(":%s %03d %s :Nickname - %s", ServerInstance->Config->ServerName.c_str(),
+ RPL_ADMINLOC2, user->nick.c_str(), ServerInstance->Config->AdminNick.c_str());
+ user->SendText(":%s %03d %s :E-Mail - %s", ServerInstance->Config->ServerName.c_str(),
+ RPL_ADMINEMAIL, user->nick.c_str(), ServerInstance->Config->AdminEmail.c_str());
return CMD_SUCCESS;
}
diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp
index 6180709a7..55279627c 100644
--- a/src/commands/cmd_stats.cpp
+++ b/src/commands/cmd_stats.cpp
@@ -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;
}
diff --git a/src/commands/cmd_time.cpp b/src/commands/cmd_time.cpp
index 43f4b6bd1..01b9b28a1 100644
--- a/src/commands/cmd_time.cpp
+++ b/src/commands/cmd_time.cpp
@@ -13,14 +13,6 @@
#include "inspircd.h"
-#ifndef __CMD_TIME_H__
-#define __CMD_TIME_H__
-
-// include the common header files
-
-#include "users.h"
-#include "channels.h"
-
/** Handle /TIME. These command handlers can be reloaded by the core,
* and handle basic RFC1459 commands. Commands within modules work
* the same way, however, they can be fully unloaded, where these
@@ -39,15 +31,18 @@ class CommandTime : 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() > 0)
+ return ROUTE_UNICAST(parameters[0]);
+ return ROUTE_LOCALONLY;
+ }
};
-#endif
-
-
-
-
-CmdResult CommandTime::Handle (const std::vector<std::string>&, User *user)
+CmdResult CommandTime::Handle (const std::vector<std::string>& parameters, User *user)
{
+ if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName)
+ return CMD_SUCCESS;
struct tm* timeinfo;
time_t local = ServerInstance->Time();
@@ -57,7 +52,7 @@ CmdResult CommandTime::Handle (const std::vector<std::string>&, User *user)
snprintf(tms,26,"%s",asctime(timeinfo));
tms[24] = 0;
- user->WriteNumeric(RPL_TIME, "%s %s :%s",user->nick.c_str(),ServerInstance->Config->ServerName.c_str(),tms);
+ user->SendText(":%s %03d %s %s :%s", ServerInstance->Config->ServerName.c_str(), RPL_TIME, user->nick.c_str(),ServerInstance->Config->ServerName.c_str(),tms);
return CMD_SUCCESS;
}