diff --git a/Modules/Macroer.lua b/Modules/Macroer.lua index d48bb0b..df9b2e8 100644 --- a/Modules/Macroer.lua +++ b/Modules/Macroer.lua @@ -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 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 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 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