mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-14 00:23:50 +00:00
fix: tighten addon message detection to avoid suppressing regular chat
The tab-based addon message detection was too aggressive — any chat message containing a tab character was treated as an addon message and silently dropped from regular chat display. This could suppress legitimate player messages containing tabs (from copy-paste). Now only matches as addon message when: - Chat type is PARTY/RAID/GUILD/WHISPER/etc. (not SAY/YELL/EMOTE) - Prefix before tab is <=16 chars (WoW addon prefix limit) - Prefix contains no spaces (addon prefixes are identifiers) This prevents false positives while still correctly detecting addon messages formatted as "DBM4\ttimer:start:10".
This commit is contained in:
parent
40907757b0
commit
2365091266
1 changed files with 16 additions and 11 deletions
|
|
@ -13528,19 +13528,24 @@ void GameHandler::handleMessageChat(network::Packet& packet) {
|
|||
LOG_DEBUG("[", getChatTypeString(data.type), "] ", channelInfo, senderInfo, ": ", data.message);
|
||||
|
||||
// Detect addon messages: format is "prefix\ttext" in the message body.
|
||||
// Fire CHAT_MSG_ADDON instead of the regular chat event for these.
|
||||
if (addonEventCallback_) {
|
||||
// Only treat as addon message if prefix is short (<=16 chars, WoW limit),
|
||||
// contains no spaces (real prefixes are identifiers like "DBM4" or "BigWigs"),
|
||||
// and the message isn't a SAY/YELL/EMOTE (those are always player chat).
|
||||
if (addonEventCallback_ &&
|
||||
data.type != ChatType::SAY && data.type != ChatType::YELL &&
|
||||
data.type != ChatType::EMOTE && data.type != ChatType::TEXT_EMOTE &&
|
||||
data.type != ChatType::MONSTER_SAY && data.type != ChatType::MONSTER_YELL) {
|
||||
auto tabPos = data.message.find('\t');
|
||||
if (tabPos != std::string::npos && tabPos > 0 && tabPos < data.message.size() - 1) {
|
||||
if (tabPos != std::string::npos && tabPos > 0 && tabPos <= 16 &&
|
||||
tabPos < data.message.size() - 1) {
|
||||
std::string prefix = data.message.substr(0, tabPos);
|
||||
std::string body = data.message.substr(tabPos + 1);
|
||||
std::string channel = getChatTypeString(data.type);
|
||||
char guidBuf2[32];
|
||||
snprintf(guidBuf2, sizeof(guidBuf2), "0x%016llX", (unsigned long long)data.senderGuid);
|
||||
// Fire CHAT_MSG_ADDON: prefix, message, channel, sender
|
||||
addonEventCallback_("CHAT_MSG_ADDON", {prefix, body, channel, data.senderName});
|
||||
// Also add to chat history but don't show the raw addon message in chat
|
||||
return;
|
||||
// Addon prefixes are identifier-like: no spaces
|
||||
if (prefix.find(' ') == std::string::npos) {
|
||||
std::string body = data.message.substr(tabPos + 1);
|
||||
std::string channel = getChatTypeString(data.type);
|
||||
addonEventCallback_("CHAT_MSG_ADDON", {prefix, body, channel, data.senderName});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue