Say you wanted to find out about someone who whispered you...
These are the values that that event will have in its arguments
https://wow.gamepedia.com/CHAT_MSG_WHISPER
"text", "playerName", "languageName", "channelName", "playerName2", "specialFlags", zoneChannelID, channelIndex, "channelBaseName", unused, lineID, "guid", bnSenderID, isMobile, isSubtitle, hideSenderInLetterbox, supressRaidIcons
The GUID value has it's own set of values if you know how to extract it ..
https://wow.gamepedia.com/GUID
The following is a quick code up and is not necessarily 100% working but should give you an idea of how you can use it.
Lua Code:
function OnChatEvent(self, event, ... )
local args = { ... }
local localizedClass, englishClass, localizedRace, englishRace, sex, name, realm = GetPlayerInfoByGUID(args[12])
-- Deal with PlayerInfo as needed
end
local frame = CreateFrame("EventWatcher")
frame:RegisterEvent("CHAT_MSG_WHISPER")
frame:SetScript("OnEvent", OnChatEvent)