diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bots.cpp | 2 | ||||
-rw-r--r-- | src/command.cpp | 27 |
2 files changed, 27 insertions, 2 deletions
diff --git a/src/bots.cpp b/src/bots.cpp index fcbedeeb3..332bd151d 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -201,7 +201,7 @@ void BotInfo::OnMessage(User *u, const Anope::string &message) return; CommandSource source(u->nick, u, u->Account(), u, this); - RunCommand(source, message); + Command::Run(source, message); } CommandInfo& BotInfo::SetCommand(const Anope::string &cname, const Anope::string &sname, const Anope::string &permission) diff --git a/src/command.cpp b/src/command.cpp index b7289b848..421c90b93 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -194,7 +194,7 @@ void Command::OnSyntaxError(CommandSource &source, const Anope::string &subcomma source.Reply(MORE_INFO, Config->StrictPrivmsg.c_str(), source.service->nick.c_str(), source.command.c_str()); } -void RunCommand(CommandSource &source, const Anope::string &message) +void Command::Run(CommandSource &source, const Anope::string &message) { std::vector<Anope::string> params; spacesepstream(message).GetTokens(params); @@ -282,3 +282,28 @@ void RunCommand(CommandSource &source, const Anope::string &message) FOREACH_MOD(I_OnPostCommand, OnPostCommand(source, c, params)); } +bool Command::FindCommandFromService(const Anope::string &command_service, BotInfo* &bot, Anope::string &name) +{ + bot = NULL; + + for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) + { + BotInfo *bi = it->second; + + for (CommandInfo::map::const_iterator cit = bi->commands.begin(), cit_end = bi->commands.end(); cit != cit_end; ++cit) + { + const Anope::string &c_name = cit->first; + const CommandInfo &info = cit->second; + + if (info.name != command_service) + continue; + + bot = bi; + name = c_name; + return true; + } + } + + return false; +} + |