diff options
-rw-r--r-- | modules/core/bs_set.cpp | 20 | ||||
-rw-r--r-- | modules/core/os_config.cpp | 2 | ||||
-rw-r--r-- | modules/extra/m_alias.cpp | 41 | ||||
-rw-r--r-- | src/botserv.cpp | 59 | ||||
-rw-r--r-- | src/channels.cpp | 2 |
5 files changed, 79 insertions, 45 deletions
diff --git a/modules/core/bs_set.cpp b/modules/core/bs_set.cpp index 8439ef9e7..b31a56316 100644 --- a/modules/core/bs_set.cpp +++ b/modules/core/bs_set.cpp @@ -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}")); diff --git a/modules/core/os_config.cpp b/modules/core/os_config.cpp index b7335527c..ce0bc0a56 100644 --- a/modules/core/os_config.cpp +++ b/modules/core/os_config.cpp @@ -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) { diff --git a/modules/extra/m_alias.cpp b/modules/extra/m_alias.cpp index a145e3c50..c5f52bef2 100644 --- a/modules/extra/m_alias.cpp +++ b/modules/extra/m_alias.cpp @@ -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) diff --git a/src/botserv.cpp b/src/botserv.cpp index c1b7fde56..a7076bcf5 100644 --- a/src/botserv.cpp +++ b/src/botserv.cpp @@ -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; - - if (sep.GetToken(command) && command[0] == Config->BSFantasyCharacter[0]) + Anope::string message = buf; + /* Strip off the fantasy character */ + message.erase(message.begin()); + + 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()); - - if (check_access(u, ci, CA_FANTASIA)) - { - Anope::string message = sep.GetRemaining(); - - FOREACH_RESULT(I_OnPreCommandRun, OnPreCommandRun(u, ci->bi, command, message, ci)); - if (MOD_RESULT == EVENT_STOP) - return; - - Command *cmd = FindCommand(ChanServ, command); + command = message.substr(0, space); + rest = message.substr(space + 1); + } - /* 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; + if (check_access(u, ci, CA_FANTASIA)) + { - mod_run_cmd(ChanServ, u, ci, message); - } + Command *cmd = FindCommand(ChanServ, command); - FOREACH_MOD(I_OnBotFantasy, OnBotFantasy(command, u, ci, sep.GetRemaining())); - } - else + /* Command exists and can be called by fantasy */ + if (cmd && !cmd->HasFlag(CFLAG_DISABLE_FANTASY)) { - FOREACH_MOD(I_OnBotNoFantasyAccess, OnBotNoFantasyAccess(command, u, ci, 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; + + 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)); } } } diff --git a/src/channels.cpp b/src/channels.cpp index 089b3831b..2fe4e037d 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -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 |