1
0
mirror of https://github.com/anope/anope.git synced 2026-06-29 06:36:41 +02:00

Fixed some problems with m_alias and fantasy

This commit is contained in:
Adam
2011-03-11 15:10:30 -05:00
parent bb3b421385
commit 1b2f3bf369
5 changed files with 79 additions and 45 deletions
+30 -29
View File
@@ -317,41 +317,42 @@ void botchanmsgs(User *u, ChannelInfo *ci, const Anope::string &buf)
/* Fantaisist commands */
if (ci->botflags.HasFlag(BS_FANTASY) && buf[0] == Config->BSFantasyCharacter[0] && !was_action)
{
spacesepstream sep(buf);
Anope::string command;
Anope::string message = buf;
/* Strip off the fantasy character */
message.erase(message.begin());
if (sep.GetToken(command) && command[0] == Config->BSFantasyCharacter[0])
size_t space = message.find(' ');
Anope::string command, rest;
if (space == Anope::string::npos)
command = message;
else
{
/* Strip off the fantasy character */
command.erase(command.begin());
command = message.substr(0, space);
rest = message.substr(space + 1);
}
if (check_access(u, ci, CA_FANTASIA))
if (check_access(u, ci, CA_FANTASIA))
{
Command *cmd = FindCommand(ChanServ, command);
/* Command exists and can be called by fantasy */
if (cmd && !cmd->HasFlag(CFLAG_DISABLE_FANTASY))
{
Anope::string message = sep.GetRemaining();
Anope::string params = rest;
/* Some commands don't need the channel name added.. eg !help */
if (!cmd->HasFlag(CFLAG_STRIP_CHANNEL))
params = ci->name + " " + params;
params = command + " " + params;
FOREACH_RESULT(I_OnPreCommandRun, OnPreCommandRun(u, ci->bi, command, message, ci));
if (MOD_RESULT == EVENT_STOP)
return;
Command *cmd = FindCommand(ChanServ, command);
/* 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, ci, message);
}
FOREACH_MOD(I_OnBotFantasy, OnBotFantasy(command, u, ci, sep.GetRemaining()));
}
else
{
FOREACH_MOD(I_OnBotNoFantasyAccess, OnBotNoFantasyAccess(command, u, ci, sep.GetRemaining()));
mod_run_cmd(ChanServ, u, ci, params);
}
FOREACH_MOD(I_OnBotFantasy, OnBotFantasy(command, u, ci, rest));
}
else
{
FOREACH_MOD(I_OnBotNoFantasyAccess, OnBotNoFantasyAccess(command, u, ci, rest));
}
}
}