--[[ Author: Dennis Werner Garske (DWG) License: MIT License ]] -- Setup to wrap our stuff in a table so we don't pollute the global environment local _G = _G or getfenv(0); local Roids = _G.Roids or {}; _G.Roids = Roids; Roids.Hooks = Roids.Hooks or {}; Roids.mouseoverUnit = Roids.mouseoverUnit or nil; Roids.Extensions = Roids.Extensions or {}; -- Executes the given Macro's body -- body: The Macro's body function Roids.ExecuteMacroBody(body) local lines = Roids.splitString(body, "\n"); for k,v in pairs(lines) do ChatFrameEditBox:SetText(v); ChatEdit_SendText(ChatFrameEditBox); end end -- Gets the body of the Macro with the given name -- name: The name of the Macro -- returns: The body of the macro function Roids.GetMacroBody(name) local macroId = GetMacroIndexByName(name); if not macroId then return false; end local _,_, body = GetMacroInfo(macroId); if not body and SuperMacroFrame ~= nil then body = GetSuperMacroInfo(name, "body"); end return body; end -- Attempts to execute a macro by the given name -- name: The name of the macro -- returns: Whether the macro was executed or not function Roids.ExecuteMacroByName(name) local body = Roids.GetMacroBody(name); if not body then return false; end Roids.ExecuteMacroBody(body); return true; end -- Searches for a ':', '>' or '<' in the given word and returns its position -- word: The word to search in -- returns: The position of the delimeter or nil and 1 for '>' or 2 for '<' function Roids.FindDelimeter(word) local delimeter = string.find(word, ":"); local which = nil; if not delimeter then delimeter = string.find(word, ">"); which = 1; if not delimeter then delimeter = string.find(word, "<"); which = 0; end end if not delimeter then which = nil; end return delimeter, which; end -- Parses the given message and looks for any conditionals -- msg: The message to parse -- returns: A set of conditionals found inside the given string function Roids.parseMsg(msg) local modifier = ""; local modifierEnd = string.find(msg, "]"); local help = nil; -- If we find conditionals trim down the message to everything except the conditionals if string.sub(msg, 1, 1) == "[" and modifierEnd then modifier = string.sub(msg, 2, modifierEnd - 1); msg = string.sub(msg, modifierEnd + 1); -- No conditionals found. Just return the message as is elseif string.sub(msg, 1, 1) ~= "!" then return msg; end local target; local conditionals = {}; msg = Roids.Trim(msg) if string.sub(msg, 1, 1) == "!" then msg = string.sub(msg, 2); conditionals.checkchanneled = msg; end local pattern = "(@?%w+:?>?