summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/botserv.cpp35
-rw-r--r--src/commands.cpp35
-rw-r--r--src/messages.cpp8
3 files changed, 44 insertions, 34 deletions
diff --git a/src/botserv.cpp b/src/botserv.cpp
index 3d25136da..af3b0ee4e 100644
--- a/src/botserv.cpp
+++ b/src/botserv.cpp
@@ -320,37 +320,40 @@ void botchanmsgs(User *u, ChannelInfo *ci, const Anope::string &buf)
if (ci->botflags.HasFlag(BS_FANTASY) && buf[0] == Config->BSFantasyCharacter[0] && !was_action)
{
spacesepstream sep(buf);
- Anope::string token;
+ Anope::string command;
- if (sep.GetToken(token) && token[0] == Config->BSFantasyCharacter[0])
+ if (sep.GetToken(command) && command[0] == Config->BSFantasyCharacter[0])
{
/* Strip off the fantasy character */
- token.erase(token.begin());
+ command.erase(command.begin());
if (check_access(u, ci, CA_FANTASIA))
{
- Command *command = FindCommand(ChanServ, token);
+ Anope::string message = sep.GetRemaining();
- /* Command exists and can not be called by fantasy */
- if (command && !command->HasFlag(CFLAG_DISABLE_FANTASY))
- {
- Anope::string bbuf = token;
+ EventReturn MOD_RESULT;
+ FOREACH_RESULT(I_OnPreCommandRun, OnPreCommandRun(u, ci->bi, command, message, true));
+ if (MOD_RESULT == EVENT_STOP)
+ return;
- /* Some commands don't need the channel name added.. eg !help */
- if (!command->HasFlag(CFLAG_STRIP_CHANNEL))
- bbuf += " " + ci->name;
+ Command *cmd = FindCommand(ChanServ, command);
- if (!sep.StreamEnd())
- bbuf += " " + sep.GetRemaining();
+ /* Command exists and can be called by fantasy */
+ if (cmd && !cmd->HasFlag(CFLAG_DISABLE_FANTASY))
+ {
+ /* Some commands don't need the channel name added.. eg !help */
+ if (!cmd->HasFlag(CFLAG_STRIP_CHANNEL))
+ message = ci->name + " " + message;
+ message = command + " " + message;
- mod_run_cmd(ChanServ, u, bbuf);
+ mod_run_cmd(ChanServ, u, message, true);
}
- FOREACH_MOD(I_OnBotFantasy, OnBotFantasy(token, u, ci, sep.GetRemaining()));
+ FOREACH_MOD(I_OnBotFantasy, OnBotFantasy(command, u, ci, sep.GetRemaining()));
}
else
{
- FOREACH_MOD(I_OnBotNoFantasyAccess, OnBotNoFantasyAccess(token, u, ci, sep.GetRemaining()));
+ FOREACH_MOD(I_OnBotNoFantasyAccess, OnBotNoFantasyAccess(command, u, ci, sep.GetRemaining()));
}
}
}
diff --git a/src/commands.cpp b/src/commands.cpp
index 3dc9ea177..e1f744954 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -26,26 +26,32 @@ Command *FindCommand(BotInfo *bi, const Anope::string &name)
return NULL;
}
-void mod_run_cmd(BotInfo *bi, User *u, const Anope::string &message)
-{
- spacesepstream sep(message);
- Anope::string cmd;
-
- if (sep.GetToken(cmd))
- mod_run_cmd(bi, u, FindCommand(bi, cmd), cmd, sep.GetRemaining());
-}
-
-void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command, const Anope::string &message)
+void mod_run_cmd(BotInfo *bi, User *u, const Anope::string &fullmessage, bool fantasy)
{
if (!bi || !u)
return;
+
+ spacesepstream sep(fullmessage);
+ Anope::string command, message;
- CommandReturn ret = MOD_CONT;
-
+ if (!sep.GetToken(command))
+ return;
+ message = sep.GetRemaining();
+
EventReturn MOD_RESULT;
- FOREACH_RESULT(I_OnPreCommandRun, OnPreCommandRun(u, bi, command, message, c));
+ FOREACH_RESULT(I_OnPreCommandRun, OnPreCommandRun(u, bi, command, message, fantasy));
if (MOD_RESULT == EVENT_STOP)
return;
+
+ Command *c = FindCommand(bi, command);
+
+ mod_run_cmd(bi, u, c, command, message, fantasy);
+}
+
+void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command, const Anope::string &message, bool fantasy)
+{
+ if (!bi || !u)
+ return;
if (!c)
{
@@ -88,6 +94,7 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command,
return;
}
+ EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnPreCommand, OnPreCommand(u, c->service, c->name, params));
if (MOD_RESULT == EVENT_STOP)
return;
@@ -134,7 +141,7 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command,
return;
}
- ret = c->Execute(u, params);
+ CommandReturn ret = c->Execute(u, params);
if (ret == MOD_CONT)
{
diff --git a/src/messages.cpp b/src/messages.cpp
index 6d93aeb13..945414f05 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -175,20 +175,20 @@ int m_privmsg(const Anope::string &source, const Anope::string &receiver, const
}
}
if (bi == NickServ || bi == MemoServ || bi == BotServ)
- mod_run_cmd(bi, u, message);
+ mod_run_cmd(bi, u, message, false);
else if (bi == ChanServ)
{
if (!is_oper(u) && Config->CSOpersOnly)
u->SendMessage(ChanServ, ACCESS_DENIED);
else
- mod_run_cmd(bi, u, message);
+ mod_run_cmd(bi, u, message, false);
}
else if (bi == HostServ)
{
if (!ircd->vhost)
u->SendMessage(HostServ, SERVICE_OFFLINE, Config->s_HostServ.c_str());
else
- mod_run_cmd(bi, u, message);
+ mod_run_cmd(bi, u, message, false);
}
else if (bi == OperServ)
{
@@ -201,7 +201,7 @@ int m_privmsg(const Anope::string &source, const Anope::string &receiver, const
else
{
Log(OperServ) << u->nick << ": " << message;
- mod_run_cmd(bi, u, message);
+ mod_run_cmd(bi, u, message, false);
}
}
}