Quantcast

Fixed bug where the chat bubble message could not be mapped to a user because TotalRP3 changed the chat message (which doesn't get propogated to the chat bubble)

Christopher Tse [05-30-20 - 07:30]
Fixed bug where the chat bubble message could not be mapped to a user because TotalRP3 changed the chat message (which doesn't get propogated to the chat bubble)
Filename
BlizzChatIntegration.lua
TotalRP3.lua
diff --git a/BlizzChatIntegration.lua b/BlizzChatIntegration.lua
index 65bc0e7..154e76e 100644
--- a/BlizzChatIntegration.lua
+++ b/BlizzChatIntegration.lua
@@ -170,12 +170,13 @@ local function onChatMessage(_, event, message, sender, ...)
 	return false, message, sender, ...
 end

-local function resetChatHandler(self)
-	for _, channel in pairs(MANAGED_CHANNELS) do
-		ChatFrame_RemoveMessageEventFilter(channel, onChatMessage)
-		ChatFrame_AddMessageEventFilter(channel, onChatMessage);
-	end
-end
+--This will probably not be needed, but just in case...
+--local function resetChatHandler(self)
+--	for _, channel in pairs(MANAGED_CHANNELS) do
+--		ChatFrame_RemoveMessageEventFilter(channel, onChatMessage)
+--		ChatFrame_AddMessageEventFilter(channel, onChatMessage);
+--	end
+--end

 local function onStart(self)
 	for _, channel in pairs(MANAGED_CHANNELS) do
@@ -186,4 +187,4 @@ end
 Import.modules.BlizzChatIntegration = {};
 Import.modules.BlizzChatIntegration.name = "BlizzChatIntegration";
 Import.modules.BlizzChatIntegration.OnStart = onStart;
-Import.modules.BlizzChatIntegration.ResetChatHandler = resetChatHandler
\ No newline at end of file
+--Import.modules.BlizzChatIntegration.ResetChatHandler = resetChatHandler
\ No newline at end of file
diff --git a/TotalRP3.lua b/TotalRP3.lua
index 464d85e..186e4dd 100644
--- a/TotalRP3.lua
+++ b/TotalRP3.lua
@@ -77,7 +77,12 @@ function TotalRP3_onStart(self)
 			ChatFrame_RemoveMessageEventFilter(channel, makeBubbleForNPCChat);
 			ChatFrame_AddMessageEventFilter(channel, makeBubbleForNPCChat);
 		end
-		Import.modules.BlizzChatIntegration:ResetChatHandler()
+		--Don't re-order BCI's chat handler. It's important for BCI's handler to go first before
+		--  TotalRP3 as TotalRP3's modifications to the chat message (e.g. colouring)
+		--  are not propagated to the chat bubble, and BlizzChatIntegration.lua relies on
+		--  using the message as a common key between the chat message and chat bubble
+		--  to map the chat bubble to a character name.
+		--Import.modules.BlizzChatIntegration:ResetChatHandler()
 	end
 end