--[[ ChatAliasLite is an update version of ChatAlias by Jooky. Changes were made to allow this to work with WoW 2.0. Some functionallity has been lost. ]] --[[ Hacked version by Stew for compatibility with WIM3, hooks ChatThrottleLib if present ]] CAL_Aliases = {} CAL_Dynamic_Aliases = {} CAL_Config = {} local ChatAliasLite_Saved_SendChatMessage local ChatAliasLite_Saved_CTL_SendChatMessage local ChatAliasLite_CTL_hookedversion=0 local addonmonitor function ChatAliasLite_FormatMessage(msg, chattype, channel) local WordList, newSentence, changedSentence, changedWord = {}, msg, false, false if chattype == "WHISPER" then newSentence = channel.." "..newSentence end repeat changedSentence = false WordList = CAL_SentenceToList(newSentence) newSentence = "" for index,word in pairs(WordList) do repeat word,changedWord = CAL_ReplaceAWord(word) changedSentence = changedSentence or changedWord until not changedWord newSentence = newSentence..word end until not changedSentence if chattype == "WHISPER" then channel,newSentence = string.match(newSentence,"^(%S+)%s(.+)") end return newSentence, channel end --Function: CAL_ReplaceAWord(word) function CAL_ReplaceAWord(thisWord) local newWord,changed = thisWord, false -- DEFAULT_CHAT_FRAME:AddMessage("ChatAliasLite: newWord ='"..(newWord or "nil").."'") -- DEFAULT_CHAT_FRAME:AddMessage("ChatAliasLite: type(CAL_Aliases[newWord] ='"..(CAL_Aliases[newWord] or "nil").."'") if type(CAL_Aliases[newWord])=="string" or type(CAL_Aliases[newWord])=="number" then newWord = CAL_Aliases[newWord] changed = true elseif type(CAL_Dynamic_Aliases[newWord])=="string" then RunScript(CAL_Dynamic_Aliases[newWord]) if (type(ALIASVAL)=="function") then ALIASVAL = ALIASVAL(); end if (ALIASVAL==nil) then newWord = "" else newWord = ALIASVAL end changed = true end return newWord, changed end --Function: CAL_SentenceToList --Puts each word of a string into a separate table index --returns the table function CAL_SentenceToList(whatSentence) local originalSentenceList = {}; local finalSentenceList = {}; for word in string.gmatch(whatSentence,"%S+") do table.insert(originalSentenceList, word); end for i=1,table.getn(originalSentenceList) do local thisChunkList = CAL_WordToList(originalSentenceList[i]); for j=1,table.getn(thisChunkList) do table.insert(finalSentenceList,thisChunkList[j]); end if (i