From 35588cc521cb0ea8c15b0bde3d2543ada9db3751 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 7 Aug 2011 16:04:40 -0400 Subject: [PATCH] Made botserv bots with no commands just ignore messages to them, and made bots only tell users to use HELP if they have a HELP command --- src/bots.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/bots.cpp b/src/bots.cpp index bff2adac8..2ebe4bb58 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -201,7 +201,11 @@ void BotInfo::Part(Channel *c, const Anope::string &reason) void BotInfo::OnMessage(User *u, const Anope::string &message) { + if (this->commands.empty()) + return; + std::vector params = BuildStringVector(message); + bool has_help = this->commands.find("HELP") != this->commands.end(); BotInfo::command_map::iterator it = this->commands.end(); unsigned count = 0; @@ -218,7 +222,10 @@ void BotInfo::OnMessage(User *u, const Anope::string &message) if (it == this->commands.end()) { - u->SendMessage(this, _("Unknown command \002%s\002. \"%s%s HELP\" for help."), message.c_str(), Config->UseStrictPrivMsgString.c_str(), this->nick.c_str()); + if (has_help) + u->SendMessage(this, _("Unknown command \002%s\002. \"%s%s HELP\" for help."), message.c_str(), Config->UseStrictPrivMsgString.c_str(), this->nick.c_str()); + else + u->SendMessage(this, _("Unknown command \002%s\002."), message.c_str()); return; } @@ -226,7 +233,10 @@ void BotInfo::OnMessage(User *u, const Anope::string &message) service_reference c(info.name); if (!c) { - u->SendMessage(this, _("Unknown command \002%s\002. \"%s%s HELP\" for help."), message.c_str(), Config->UseStrictPrivMsgString.c_str(), this->nick.c_str()); + if (has_help) + u->SendMessage(this, _("Unknown command \002%s\002. \"%s%s HELP\" for help."), message.c_str(), Config->UseStrictPrivMsgString.c_str(), this->nick.c_str()); + else + u->SendMessage(this, _("Unknown command \002%s\002."), message.c_str()); Log(this) << "Command " << it->first << " exists on me, but its service " << info.name << " was not found!"; return; }