summaryrefslogtreecommitdiff
path: root/src/commands.cpp
diff options
context:
space:
mode:
authorAdam <Adam@drink-coca-cola.info>2010-06-03 23:09:22 -0400
committerAdam <Adam@anope.org>2010-06-18 21:04:09 -0400
commite6447fa2c40270d2e2435229127dd970194b47d9 (patch)
tree65778fc16c1789517595b2b4cbfcb2c9330b022e /src/commands.cpp
parent6cd88494662c5c4af2da891926dcc82367596cb9 (diff)
Added in a subcommand system and switched ns_set and ns_saset to use it
Diffstat (limited to 'src/commands.cpp')
-rw-r--r--src/commands.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/commands.cpp b/src/commands.cpp
index 3226bff59..f066b2885 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -29,22 +29,26 @@ Command *FindCommand(BotInfo *bi, const ci::string &name)
return NULL;
}
-void mod_run_cmd(BotInfo *bi, User *u, const ci::string &message)
+void mod_run_cmd(BotInfo *bi, User *u, const std::string &message)
{
- if (!bi || !u || message.empty())
- return;
-
- spacesepstream sep(message);
- ci::string command;
+ spacesepstream sep(ci::string(message.c_str()));
+ ci::string cmd;
- if (!sep.GetToken(command))
+ if (sep.GetToken(cmd))
+ {
+ mod_run_cmd(bi, u, FindCommand(bi, cmd), cmd, sep.GetRemaining().c_str());
+ }
+}
+
+void mod_run_cmd(BotInfo *bi, User *u, Command *c, const ci::string &command, const ci::string &message)
+{
+ if (!bi || !u)
return;
- Command *c = FindCommand(bi, command);
CommandReturn ret = MOD_CONT;
EventReturn MOD_RESULT;
- FOREACH_RESULT(I_OnPreCommandRun, OnPreCommandRun(u, bi, command, sep.GetRemaining().c_str(), c));
+ FOREACH_RESULT(I_OnPreCommandRun, OnPreCommandRun(u, bi, command, message, c));
if (MOD_RESULT == EVENT_STOP)
return;
@@ -67,6 +71,7 @@ void mod_run_cmd(BotInfo *bi, User *u, const ci::string &message)
std::vector<ci::string> params;
ci::string curparam, endparam;
+ spacesepstream sep(message);
while (sep.GetToken(curparam))
{
// - 1 because params[0] corresponds with a maxparam of 1.