From 318dbb9975f5c522a4b6fc0c1322f5df3d40c41c Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 28 Jul 2024 10:43:20 +0800 Subject: [PATCH] [Command] Command filter for multiple players --- src/PlayerbotAI.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 6a4c7b3f..fa59ff11 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -350,7 +350,7 @@ void PlayerbotAI::UpdateAIInternal([[maybe_unused]] uint32 elapsed, bool minimal std::string const command = holder.GetCommand(); Player* owner = holder.GetOwner(); - if (owner == master && !helper.ParseChatCommand(command, owner) && holder.GetType() == CHAT_MSG_WHISPER) + if (!helper.ParseChatCommand(command, owner) && holder.GetType() == CHAT_MSG_WHISPER) { // To prevent spam caused by WIM if (!(command.rfind("WIM", 0) == 0) && @@ -625,10 +625,15 @@ void PlayerbotAI::HandleCommand(uint32 type, std::string const text, Player* fro return; } - if (!IsAllowedCommand(filtered) && !GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_ALLOW_ALL, type != CHAT_MSG_WHISPER, fromPlayer)) + if (!IsAllowedCommand(filtered) && + (master != fromPlayer || !GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_ALLOW_ALL, type != CHAT_MSG_WHISPER, fromPlayer))) return; - if (type == CHAT_MSG_RAID_WARNING && filtered.find(bot->GetName()) != std::string::npos && filtered.find("award") == std::string::npos) + if (!IsAllowedCommand(filtered) && master != fromPlayer) + return; + + if (type == CHAT_MSG_RAID_WARNING && filtered.find(bot->GetName()) != std::string::npos && + filtered.find("award") == std::string::npos) { ChatCommandHolder cmd("warning", fromPlayer, type); chatCommands.push(cmd);