66 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
80 lines
4.0 KiB
Lua
80 lines
4.0 KiB
Lua
-- Temporary official-client observer. No sends, purchases or bank operations.
|
|
-- Embedded in an already loaded addon for this session; its SavedVariables
|
|
-- persist the capture. Keep Lua5.0 syntax for the actual 1.12-based client.
|
|
local function initialize()
|
|
if WoWHybridBankObserver then return end
|
|
local O={active=true,maxRows=8192,maxBytes=8388608,maxPayload=8192}
|
|
WoWHybridBankObserver=O
|
|
pfUI_cache=pfUI_cache or {}
|
|
local capture=pfUI_cache.WoWHybridGuildBankCapture
|
|
if type(capture)~="table" or capture.schema~=1 then
|
|
capture={schema=1,rows={},bytes=0,dropped=0}
|
|
pfUI_cache.WoWHybridGuildBankCapture=capture
|
|
end
|
|
O.capture=capture
|
|
local function bankPrefix(prefix)
|
|
return type(prefix)=="string" and string.len(prefix)<=64 and
|
|
string.find(string.lower(prefix),"bank",1,true)~=nil
|
|
end
|
|
local function record(direction,prefix,payload,channel)
|
|
if not O.active or not bankPrefix(prefix) then return end
|
|
if type(payload)~="string" or string.len(payload)>O.maxPayload or
|
|
table.getn(capture.rows)>=O.maxRows or capture.bytes+string.len(payload)>O.maxBytes then
|
|
capture.dropped=capture.dropped+1;return
|
|
end
|
|
table.insert(capture.rows,{time=GetTime(),direction=direction,prefix=prefix,
|
|
payload=payload,channel=type(channel)=="string" and channel or ""})
|
|
capture.bytes=capture.bytes+string.len(payload)
|
|
end
|
|
local original=SendAddonMessage
|
|
if type(original)=="function" then
|
|
O.send=function(prefix,payload,channel,target)
|
|
record("outgoing-api",prefix,payload,channel)
|
|
-- Preserve all original return values and errors. An API call is
|
|
-- an attempted send, not proof of server acceptance or wire receipt.
|
|
return original(prefix,payload,channel,target)
|
|
end
|
|
SendAddonMessage=O.send
|
|
end
|
|
local chat=SendChatMessage
|
|
if type(chat)=="function" then
|
|
O.chat=function(message,kind,language,target)
|
|
if type(message)=="string" and type(language)=="string" and string.lower(language)=="addon" then
|
|
local _,_,prefix,payload=string.find(message,"^([^\t ]+)[\t ](.*)$")
|
|
record("outgoing-chat-api",prefix,payload,kind)
|
|
end
|
|
return chat(message,kind,language,target)
|
|
end
|
|
SendChatMessage=O.chat
|
|
end
|
|
local frame=CreateFrame("Frame")
|
|
O.frame=frame;frame:RegisterEvent("CHAT_MSG_ADDON")
|
|
frame:SetScript("OnEvent",function()
|
|
-- Intentionally omit sender/account identifiers and all normal chat.
|
|
if event=="CHAT_MSG_ADDON" then record("incoming-event",arg1,arg2,arg3) end
|
|
end)
|
|
SLASH_WOWHYBRIDBANKCAPTURE1="/whgbcap"
|
|
SlashCmdList.WOWHYBRIDBANKCAPTURE=function(message)
|
|
if message=="stop" then
|
|
O.active=false;frame:UnregisterAllEvents()
|
|
if SendAddonMessage==O.send then SendAddonMessage=original end
|
|
if SendChatMessage==O.chat then SendChatMessage=chat end
|
|
elseif message=="start" then
|
|
-- Reload initializes hooks safely; do not steal hooks installed later.
|
|
DEFAULT_CHAT_FRAME:AddMessage("Bank capture: /reload to start a new observation session.")
|
|
elseif type(message)=="string" and string.sub(message,1,5)=="mark " then
|
|
record("marker","TW_GUILDBANK",string.sub(message,6,134),"")
|
|
end
|
|
DEFAULT_CHAT_FRAME:AddMessage("Bank capture: "..(O.active and "active" or "stopped")..
|
|
", "..table.getn(capture.rows).." rows, "..capture.dropped.." dropped. /reload saves the capture.")
|
|
end
|
|
DEFAULT_CHAT_FRAME:AddMessage("WoW-Hybrid bank capture ready. /whgbcap for status; /whgbcap stop to detach.")
|
|
end
|
|
-- SavedVariables are restored after addon files execute. Bind the capture only
|
|
-- after login, otherwise a restored table could replace the table we record in.
|
|
local bootstrap=CreateFrame("Frame")
|
|
bootstrap:RegisterEvent("PLAYER_LOGIN")
|
|
bootstrap:SetScript("OnEvent",function()
|
|
if event=="PLAYER_LOGIN" then bootstrap:UnregisterAllEvents();initialize() end
|
|
end)
|