Fix up macroer to work with the arrival and movement messages

This commit is contained in:
2025-01-05 19:49:06 +01:00
parent bb1acd5003
commit 2d2cf621bd

View File

@@ -55,11 +55,12 @@ function shared.Macroer.Init()
EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body)
end
local whoRegex = "([^ -/]+)-?%w*/(%w+)"
---@param msg string
---@return table<string, stinky>
local function ParseWho(msg)
local stinkies = {}
for name, class in string.gmatch(msg, "([^ -/]+)-?%w*/(%w+)") do
for name, class in string.gmatch(msg, whoRegex) do
stinkies[name] = {
name = name,
class = class,
@@ -69,11 +70,15 @@ function shared.Macroer.Init()
end
return stinkies
end
local seeRegex = "I see %((%w+)%) ([^ -/]+)-?%w*/(%w+)"
---@param msg string
---@return table<string, stinky>
local function ParseSee(msg)
local stinkies = {}
local aggression, name, class = string.match(msg, "I see %((%w+)%) ([^ -/]+)-?%w*/(%w+)")
local aggression, name, class = string.match(msg, seeRegex)
if not name or not class then
return stinkies
end
local stinky = {
name = name,
class = class,
@@ -83,10 +88,25 @@ function shared.Macroer.Init()
stinkies[name] = stinky
return stinkies
end
local arrivedRegex = "([^ -/]+)-?%w* of class (%w+)"
local arrivedRegexAlt = "([^ -/]+)-?%w* %(!!!!%) of class (%w+)"
---@param msg string
---@return table<string, stinky>
local function ParseArrived(msg)
local stinkies = {}
local name, class = string.match(msg, arrivedRegex)
if not name or not class then
name, class = string.match(msg, arrivedRegexAlt)
end
if not name or not class then
return stinkies
end
local stinky = {
name = name,
class = class,
seenAt = GetTime(),
hostile = true
}
return stinkies
end
@@ -119,6 +139,13 @@ function shared.Macroer.Init()
end
end
end
if string.find(msg, " and guild ") then
local arrivedStinkies = ParseArrived(msg)
for name, stinky in pairs(arrivedStinkies) do
recentStinkies[name] = stinky
doUpdate = true
end
end
if doUpdate then
FixMacro(recentStinkies)
end