local HW = { ["START"] = 1, ["STOP"] = 2, ["UPDATE"] = 3, ["HEAL"] = 4, ["VERSQUEST"] = 5, ['VERSRESP'] = 6, } local _msg,_spellIndex local _,_amt,_grp,_prio if (not HealWatch) then HealWatch = {} end function HealWatch.EnableComs() HealWatch.frame:RegisterEvent('CHAT_MSG_ADDON') HealWatch.enableComs = true end function HealWatch.DisableComs() HealWatch.frame:UnregisterEvent('CHAT_MSG_ADDON') HealWatch.enableComs = false end -- provided as the default message in HealWatch function HealWatch.SendHWMessage(target,spell,status,time,rank) -- only send if we are enabled and stuff if (not (target and spell and HealWatch.enableComs)) then return end if (not (status == HW['VERSRESP'] or status == HW['VERSQUEST'])) then end if (HealWatch.customSend) then HealWatch.customSend(status or HW["START"],target,spell) return end _spellIndex = HealWatch.spells[spell] if (status == HW['VERSRESP']) then _msg = string.format("%d",status or 0) elseif (status == HW['VERSQUEST']) then _msg = string.format("%d%s",status or 0,HealWatch.version) else _msg = string.format("%d%d%s",status or 0,_spellIndex or 0,target or '-') end _grp = (HealWatch.isRaid and 'RAID') or 'PARTY' if (ChatThrottleLib) then _prio = 'ALERT' -- don't prioritize version stuff if (status == HW['VERSRESP'] or status == HW['VERSQUEST']) then _prio='BULK' end ChatThrottleLib:SendAddonMessage(_prio,"HW",_msg,_grp) else SendAddonMessage('HW',_msg,_grp) end end function HealWatch.CHAT_MSG_ADDON(prefix,msg,dest,player) -- ignore self messages if (player == HealWatch._playerName) then return end -- jump out if not in the right 'channel' if (not (dest == 'RAID' or dest == 'PARTY')) then return end -- see if we have a registered function for this prefix local module = HealWatch.comModules[(prefix or '')] -- if so, and it is valid, call it if (module and module.enabled) then local func = module['recv'] if (func and type(func) == 'function') then func(player,msg) end end end -- here we provide a basic plugin module local function ProcessHWMessage(nick,message) -- we checked to see if we are enabled if (HealWatch.debugComs) then HealWatch.dframe:AddMessage("Received HW message: ["..nick.."]: "..message) end -- Break message apart into spellname, target,etc. -- Assume for now that properly formatted message looks like this: -- e.g., []: HW