View Single Post
03/01/20, 11:56 AM   #1
Shadowfen
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 84
chat /reply /respond /r problem

The problem is that trying to use the /r in chat to respond to a whisper fails to do anything when LibChatMessage is in "hack-around" mode.

Proof of concept minimal addon src:
Code:
chatTest = {
    name = "chatTest",
}

-- Registering libraries
local LCM = LibChatMessage

-- ugly message formatter
local function FormatMessage(chanCode, from, text, isCS, fromDisplayName)
    local message = string.format("[%s/%s] %s",zo_strformat(SI_UNIT_NAME, from), fromDisplayName, text)
    return message
end

-- Registers the FormatMessage function with the LibChatMessage to handle chat formatting.
local function OnPlayerActivated()

    EVENT_MANAGER:UnregisterForEvent(chatTest.name, EVENT_PLAYER_ACTIVATED)

    -- set the chat event handlers for LibChatMessage to use
    LCM.formatRegularChat = true
    local evthdlrs = ZO_ChatSystem_GetEventHandlers()
    evthdlrs[EVENT_CHAT_MESSAGE_CHANNEL] = FormatMessage
end

--
local function OnAddonLoaded(_, addonName)
    if addonName ~= chatTest.name then return end
    EVENT_MANAGER:UnregisterForEvent(chatTest.name, EVENT_ADD_ON_LOADED)
 
	EVENT_MANAGER:RegisterForEvent(chatTest.name, EVENT_PLAYER_ACTIVATED, OnPlayerActivated)
end

EVENT_MANAGER:RegisterForEvent(chatTest.name, EVENT_ADD_ON_LOADED, OnAddonLoaded)
When the line
Code:
evthdlrs[EVENT_CHAT_MESSAGE_CHANNEL] = FormatMessage
is commented out, the /r works normally.

When the line is not commented, the /r chat command fails to work.

Anyone have any ideas?
  Reply With Quote