local function myChatFilter(self, event, msg, author, ...)
if msg:find("ginvite") then
I added the following code into a simple addon when other people whisper me "ginvite" nothing happens but strangely if I whisper myself "ginvite" it will attempt to invite me to the guild. I can run the script in the chat window as /script GuildInvite("some-other-playername") for example and it works fine but fails to execute when someone whispers me "ginvite". Seems to me on the surface there is a discrepancy going on with how author is being handled when I whisper myself verses when someone else whispers me. Any insight to why this might be happening?
CHAT_MSG_WHISPER is the correct event for incoming (received) whispers. However, GuildInvite is a protected function that requires a hardware event, so you cannot automate it. You will need, as Dridzt said, to make your addon pop up a box for you to click on, as clicks are hardware events which may be used to run protected functions.