Created
November 9, 2009 08:18
-
-
Save tekkub/229779 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local RV = LibStub:NewLibrary("libRaidVoice-1.0", 1) | |
if not RV then return end -- No upgrade needed | |
----------------------------------------------------------------------------------------------------- | |
-- use RV.RegisterCallback(self, "eventName"[, method, [arg]]) | |
-- to register recieve voice events | |
-- example: | |
-- local RV = LibStub:GetLibrary("libRaidVoice-1.0") | |
-- RV.RegisterCallback(MyAddon, "RAIDVOICE_UPDATE") | |
-- function MyAddon:RAIDVOICE_UPDATE(event, unit) | |
-- ... | |
-- end | |
-------------------------------------------------------------------------------------------------------- | |
RV.talkers = RV.talkers or {} | |
RV.frame = RV.frame or CreateFrame("Frame") | |
RV.events = RV.events or LibStub:GetLibrary("CallbackHandler-1.0"):New(RV) | |
RV.frame:SetScript("OnEvent", function(self, event, prefix, msg) | |
if prefix ~= "RAIDVOICE" then return end | |
if not string.find(msg, "!") then | |
RV.talkers[msg] = true | |
RV.events:Fire("RAIDVOICE_UPDATE", msg) | |
elseif not msg or msg == "!CLEAR" or msg == "" then | |
wipe(RV.talkers) | |
RV.events:Fire("RAIDVOICE_UPDATE", nil) | |
end | |
end | |
RV.frame:RegisterEvent("CHAT_MSG_ADDON") | |
local o = UnitIsTalking | |
function UnitIsTalking(unit, ...) | |
if RV.talkers[unit] then return 1 end | |
return o(unit, ...) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment