Files
praxisandClaude Fable 5.2 cf9ad2ff3c Client interface: addons, login-screen adapters and launcher
66 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

82 lines
4.8 KiB
Lua

-- Temporary, bounded official-client social observer. Lua5.0 compatible.
-- API attempts and UI events are not raw packets or server acceptance.
local function initialize()
if WoWHybridSocialObserver then return end
pfUI_cache=pfUI_cache or {}
local capture={schema=1,rows={},bytes=0,dropped=0,started=GetTime()}
pfUI_cache.WoWHybridSocialCapture=capture
local O={active=true,capture=capture,maxRows=8192,maxBytes=8388608,hooks={}}
WoWHybridSocialObserver=O
local function record(direction,name,a,b,c,d,e,f,g,h,i)
if not O.active then return end
local values={};local bytes=string.len(name)
local function add(index,value)
if type(value)=="string" then
if string.len(value)>8192 then value=string.sub(value,1,8192) end
values[index]=value;bytes=bytes+string.len(value)
elseif type(value)=="number" or type(value)=="boolean" then values[index]=value end
end
add(1,a);add(2,b);add(3,c);add(4,d);add(5,e);add(6,f);add(7,g);add(8,h);add(9,i)
if table.getn(capture.rows)>=O.maxRows or capture.bytes+bytes>O.maxBytes then
capture.dropped=capture.dropped+1;return
end
table.insert(capture.rows,{time=GetTime(),direction=direction,name=name,args=values})
capture.bytes=capture.bytes+bytes
end
local function hook0(name)
local old=getglobal(name);if type(old)~="function" then return end
local fn=function()record("outgoing-api",name);return old()end
O.hooks[name]={old=old,fn=fn};setglobal(name,fn)
end
local function hook1(name)
local old=getglobal(name);if type(old)~="function" then return end
local fn=function(a)record("outgoing-api",name,a);return old(a)end
O.hooks[name]={old=old,fn=fn};setglobal(name,fn)
end
local function hook4(name)
local old=getglobal(name);if type(old)~="function" then return end
local fn=function(a,b,c,d)record("outgoing-api",name,a,b,c,d);return old(a,b,c,d)end
O.hooks[name]={old=old,fn=fn};setglobal(name,fn)
end
-- Known original signatures only. No generic vararg truncation or fabricated sends.
hook0("GuildRoster");hook0("ShowFriends");hook0("RequestFriendsList")
hook1("AddFriend");hook1("RemoveFriend");hook1("AddIgnore");hook1("DelIgnore")
hook1("SendWho");hook1("SetWhoToUI");hook1("ToggleFriendsFrame")
hook1("ShowFriendsFrame");hook1("GuildInvite");hook1("GuildUninvite")
hook4("SendChatMessage");hook4("SendAddonMessage")
local frame=CreateFrame("Frame");O.frame=frame
local events={"CHAT_MSG_ADDON","CHAT_MSG_WHISPER","CHAT_MSG_WHISPER_INFORM",
"CHAT_MSG_GUILD","CHAT_MSG_OFFICER","CHAT_MSG_SYSTEM","CHAT_MSG_SAY",
"CHAT_MSG_PARTY","CHAT_MSG_RAID","FRIENDLIST_UPDATE","IGNORELIST_UPDATE",
"GUILD_ROSTER_UPDATE","GUILD_MOTD","WHO_LIST_UPDATE","GUILD_INVITE_REQUEST",
"GUILD_INVITE_CANCEL","PLAYER_GUILD_UPDATE","PLAYER_LOGOUT","UI_ERROR_MESSAGE"}
for _,name in ipairs(events)do frame:RegisterEvent(name)end
frame:SetScript("OnEvent",function()
record("incoming-event",event,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
if event=="FRIENDLIST_UPDATE" and type(GetNumFriends)=="function" and type(GetFriendInfo)=="function" then
local n=GetNumFriends();record("state","friend-count",n)
for index=1,math.min(n,200)do record("state","friend",GetFriendInfo(index))end
elseif event=="GUILD_ROSTER_UPDATE" and type(GetNumGuildMembers)=="function" then
record("state","guild-member-count",GetNumGuildMembers())
end
end)
SLASH_WOWHYBRIDSOCIALCAPTURE1="/whsoccap"
SlashCmdList.WOWHYBRIDSOCIALCAPTURE=function(message)
if message=="stop" then
O.active=false;frame:UnregisterAllEvents()
for name,pair in pairs(O.hooks)do if getglobal(name)==pair.fn then setglobal(name,pair.old)end end
elseif type(message)=="string" and string.sub(message,1,5)=="mark " then
record("marker","user",string.sub(message,6,134))
end
DEFAULT_CHAT_FRAME:AddMessage("Social capture "..(O.active and "active"or"stopped")..": "..
table.getn(capture.rows).." rows, "..capture.dropped.." dropped. /reload or logout saves.")
end
if type(LoggingChat)=="function" then capture.chatLogging=LoggingChat(1)end
record("marker","observer-ready")
DEFAULT_CHAT_FRAME:AddMessage("WoW-Hybrid social capture ready: guild/friends/whispers/addon events. /whsoccap for status. /reload or logout saves. Private local recording; no raw packets.")
end
if not WoWHybridSocialObserver then
local bootstrap=CreateFrame("Frame");bootstrap:RegisterEvent("PLAYER_LOGIN")
bootstrap:SetScript("OnEvent",function()if event=="PLAYER_LOGIN" then bootstrap:UnregisterAllEvents();initialize()end end)
end