Right, now you've got that part correct. Now you just need to clean up your extra function (which was probably accidentally left there).
After that, there's only one more problem with this code:
lua Code:
local frame = CreateFrame("FRAME", "RFFrame");
frame:RegisterEvent("UNIT_AURA");
--deleted duplicate function definition that was here
local active = UnitBuff('player', 'Righteous Fury')
local hasrf
local function eventHandler(self, event, ...)
if not hasrf and active then
hasrf = true
print('Rigtheous Fury has been activated')
elseif hasrf and not active then
hasrf = false
end
end
frame:SetScript("OnEvent", eventHandler);
...and that is that "active" is declared in the wrong place. You need to check whether the player has the buff every time the function runs, not just when your addon loads. Is that enough information for you to figure out what to change?