mirror of
https://github.com/anope/anope.git
synced 2026-07-08 02:23:13 +02:00
Fixed some problems with m_alias and fantasy
This commit is contained in:
+10
-10
@@ -46,12 +46,12 @@ class CommandBSSet : public Command
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
bi->SetFlag(BI_PRIVATE);
|
||||
source.Reply(_("Private mode of bot %s is now \002\002."), bi->nick.c_str());
|
||||
source.Reply(_("Private mode of bot %s is now \002on\002."), bi->nick.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
bi->UnsetFlag(BI_PRIVATE);
|
||||
source.Reply(_("Private mode of bot %s is now \002\002."), bi->nick.c_str());
|
||||
source.Reply(_("Private mode of bot %s is now \002off\002."), bi->nick.c_str());
|
||||
}
|
||||
else
|
||||
SyntaxError(source, "SET PRIVATE", _("SET \037botname\037 PRIVATE {\037ON|\037}"));
|
||||
@@ -101,12 +101,12 @@ class CommandBSSet : public Command
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
ci->botflags.SetFlag(BS_FANTASY);
|
||||
source.Reply(_("Fantasy mode is now \002\002 on channel %s."), ci->name.c_str());
|
||||
source.Reply(_("Fantasy mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_FANTASY);
|
||||
source.Reply(_("Fantasy mode is now \002\002 on channel %s."), ci->name.c_str());
|
||||
source.Reply(_("Fantasy mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
SyntaxError(source, "SET FANTASY", _("SET \037channel\037 FANTASY {\037ON|\037}"));
|
||||
@@ -116,12 +116,12 @@ class CommandBSSet : public Command
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
ci->botflags.SetFlag(BS_GREET);
|
||||
source.Reply(_("Greet mode is now \002\002 on channel %s."), ci->name.c_str());
|
||||
source.Reply(_("Greet mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_GREET);
|
||||
source.Reply(_("Greet mode is now \002\002 on channel %s."), ci->name.c_str());
|
||||
source.Reply(_("Greet mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
SyntaxError(source, "SET GREET", _("SET \037channel\037 GREET {\037ON|\037}"));
|
||||
@@ -133,12 +133,12 @@ class CommandBSSet : public Command
|
||||
ci->botflags.SetFlag(BS_NOBOT);
|
||||
if (ci->bi)
|
||||
ci->bi->UnAssign(u, ci);
|
||||
source.Reply(_("No Bot mode is now \002\002 on channel %s."), ci->name.c_str());
|
||||
source.Reply(_("No Bot mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_NOBOT);
|
||||
source.Reply(_("No Bot mode is now \002\002 on channel %s."), ci->name.c_str());
|
||||
source.Reply(_("No Bot mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
SyntaxError(source, "SET NOBOT", _("SET \037botname\037 NOBOT {\037ON|\037}"));
|
||||
@@ -148,12 +148,12 @@ class CommandBSSet : public Command
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
ci->botflags.SetFlag(BS_SYMBIOSIS);
|
||||
source.Reply(_("Symbiosis mode is now \002\002 on channel %s."), ci->name.c_str());
|
||||
source.Reply(_("Symbiosis mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_SYMBIOSIS);
|
||||
source.Reply(_("Symbiosis mode is now \002\002 on channel %s."), ci->name.c_str());
|
||||
source.Reply(_("Symbiosis mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
SyntaxError(source, "SET SYMBIOSIS", _("SET \037channel\037 SYMBIOSIS {\037ON|\037}"));
|
||||
|
||||
@@ -160,7 +160,7 @@ class CommandOSConfig : public Command
|
||||
/* Blocks we should show */
|
||||
const Anope::string show_blocks[] = { "botserv", "chanserv", "defcon", "global", "memoserv", "nickserv", "networkinfo", "operserv", "options", "" };
|
||||
|
||||
Log(LOG_ADMIN, source.u, this);
|
||||
Log(LOG_ADMIN, source.u, this) << "VIEW";
|
||||
|
||||
for (ConfigDataHash::const_iterator it = Config->config_data.begin(), it_end = Config->config_data.end(); it != it_end; ++it)
|
||||
{
|
||||
|
||||
@@ -23,8 +23,8 @@ class ModuleAlias : public Module
|
||||
public:
|
||||
ModuleAlias(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
|
||||
{
|
||||
Implementation i[] = { I_OnReload, I_OnPreCommandRun };
|
||||
ModuleManager::Attach(i, this, 2);
|
||||
Implementation i[] = { I_OnReload, I_OnPreCommandRun, I_OnBotFantasy };
|
||||
ModuleManager::Attach(i, this, 3);
|
||||
|
||||
OnReload(false);
|
||||
}
|
||||
@@ -69,11 +69,13 @@ class ModuleAlias : public Module
|
||||
{
|
||||
const CommandAlias &alias = it->second;
|
||||
|
||||
if (!fantasy && !bi->nick.equals_ci(alias.source_client))
|
||||
if (!u->HasMode(UMODE_OPER) && alias.operonly)
|
||||
continue;
|
||||
else if (fantasy != alias.fantasy)
|
||||
continue;
|
||||
else if (!u->HasMode(UMODE_OPER) && alias.operonly)
|
||||
else if (fantasy && alias.fantasy) // OnBotFantasy gets this!
|
||||
return EVENT_STOP;
|
||||
else if (!bi->nick.equals_ci(alias.source_client))
|
||||
continue;
|
||||
|
||||
BotInfo *target = findbot(alias.target_client);
|
||||
@@ -85,6 +87,37 @@ class ModuleAlias : public Module
|
||||
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
|
||||
void OnBotFantasy(const Anope::string &command, User *u, ChannelInfo *ci, const Anope::string ¶ms)
|
||||
{
|
||||
std::multimap<Anope::string, CommandAlias, std::less<ci::string> >::const_iterator it = aliases.find(command), it_end = it;
|
||||
if (it_end != aliases.end())
|
||||
it_end = aliases.upper_bound(command);
|
||||
for (; it != it_end; ++it)
|
||||
{
|
||||
const CommandAlias &alias = it->second;
|
||||
|
||||
if (!u->HasMode(UMODE_OPER) && alias.operonly)
|
||||
continue;
|
||||
|
||||
BotInfo *target = findbot(alias.target_client);
|
||||
if (!target)
|
||||
target = ChanServ;
|
||||
|
||||
Anope::string full_message = alias.target_command;
|
||||
if (target == ChanServ || target == BotServ)
|
||||
{
|
||||
Command *target_c = FindCommand(target, alias.target_command);
|
||||
if (target_c && !target_c->HasFlag(CFLAG_STRIP_CHANNEL))
|
||||
full_message += " " + ci->name;
|
||||
}
|
||||
if (!params.empty())
|
||||
full_message += + " " + params;
|
||||
|
||||
mod_run_cmd(target, u, ci, full_message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(ModuleAlias)
|
||||
|
||||
+30
-29
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -809,7 +809,7 @@ void Channel::KickInternal(const Anope::string &source, const Anope::string &nic
|
||||
|
||||
/* Bots get rejoined */
|
||||
if (bi)
|
||||
bi->Join(chname);
|
||||
bi->Join(this, &Config->BotModeList);
|
||||
}
|
||||
|
||||
/** Kick a user from the channel
|
||||
|
||||
Reference in New Issue
Block a user