I've been going crazy trying to figure this out, lol.
I've checked
http://wowprogramming.com and
http://www.wowwiki.com, but I'm sure that doing this is probably going to be complicated as the only relevant functions I've found are UnitAura, Unitbuff, UnitDebuff.
I've also checked out a few addons, but I'm having trouble decoding it.
I'm still quite fresh as far as lua script goes, so any tips or ideas would help.