local DELAY_MIN = 2 local DELAY_MAX = 5 local messages = { "hi", "o/", "o7", "yo", "hello", } local is_in_group = false local has_greeted = false local frame = CreateFrame("Frame") frame:RegisterEvent("GROUP_ROSTER_UPDATE") local function send_message(msg) if IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then SendChatMessage(msg, "INSTANCE_CHAT") elseif IsInGroup() then SendChatMessage(msg, "PARTY") end end local function greet_group() local delay = math.random(DELAY_MIN, DELAY_MAX) C_Timer.After(delay, function() local msg = messages[ math.random(#messages) ] send_message(msg) end) end frame:SetScript("OnEvent", function() if IsInGroup() and not IsInRaid() then if not is_in_group then if not has_greeted then greet_group() has_greeted = true end is_in_group = true end else is_in_group = false has_greeted = false end end)