View Single Post
10-24-18, 10:27 AM   #9
Terenna
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 105
This is nowhere near completed, but I wanted to provide anyone who was interested in this a sort of template that you may use to write your own code. As you can see at the bottom of the code, I've still got a vast majority of the events to handle, but believe I have most of the framework in place to make it pretty straightforward. I've tried to comment my code as much as possible and as plainly as possible.

Lua Code:
  1. --------------------------
  2. --Create Functions Section
  3. --------------------------
  4. local function rgbPercToHex(r, g, b) --converts decimal rgb to a hexcode
  5.     r = r <= 1 and r >= 0 and r or 0
  6.     g = g <= 1 and g >= 0 and g or 0
  7.     b = b <= 1 and b >= 0 and b or 0
  8.     return string.format('|cff%02x%02x%02x', r*255, g*255, b*255)
  9. end
  10.  
  11. local DefaultSetItemRef = SetItemRef --this lets us alt click invite and click on url links, it also probably causes taint
  12. function SetItemRef(link, ...)
  13.     local type, value = link:match('(%a+):(.+)')
  14.     if IsAltKeyDown() and type == 'player' then
  15.         InviteUnit(value:match('([^:]+)'))
  16.     elseif (type == 'url') then
  17.         local eb = LAST_ACTIVE_CHAT_EDIT_BOX or ChatFrame1EditBox
  18.         if not eb then return end
  19.         eb:Show()
  20.         eb:SetText(value)
  21.         eb:SetFocus()
  22.         eb:HighlightText()
  23.     else
  24.         return DefaultSetItemRef(link, ...)
  25.     end
  26. end
  27.  
  28. local function createPlayerLinks(event, chatType, ...) --this creates the clickable hyperlink found for the names of players in chat
  29.     local senderLinkDisplay = GetColoredName(event, ...) --blizzard function
  30.     local _, sender, _, _, _, _, _, channelNumber, _, _, chatLineID, _ = ...
  31.     local playerLink = GetPlayerLink(sender, senderLinkDisplay, chatLineID, Chat_GetChatCategory(chatType), tostring(channelNumber) or nil) --blizzard function, have to pass the channel number as a string, some events won't have a channel number (says, whispers, yells etc) so blizzard code doesn't need this argument and accepts nil, too
  32.     return playerLink
  33. end
  34.  
  35. local function hexColorNames(chatMessage, modChatColor) --this will churn through a message and find names that match players and color it by their class color
  36.     local test = chatMessage:gsub('[^a-zA-Z%s]', '')
  37.     local words = {strsplit(' ', test)}
  38.     for i = 1, #words do
  39.         --since we technically just changed our sentence or word to ff000000wordr or ff000000this is my sentencer,
  40.         --we need to truncate the last word's trailing r and first word's hexcode
  41.         if i == 1 then
  42.             words[i] = strsub(words[i], 8) --cut off the opening timestamp color hexcode
  43.             if i == #words then
  44.                 words[i] = words[i]:sub(1, -1) --a one word message with a player name was said, now cut off the closing r, too
  45.             end
  46.         elseif i == #words then
  47.             words[i] = words[i]:sub(1, -1) --cut off the closing r
  48.         end
  49.  
  50.         local w = words[i]
  51.         if (w and not (w == 'player' or w == 'target') and UnitName(w) and UnitIsPlayer(w)) then
  52.             local _, class = UnitClass(w)
  53.             local colors = RAID_CLASS_COLORS[class]
  54.             if (colors) then --color the words that match player names with class colors, return back to the channel color for the next word(s)
  55.                 chatMessage = gsub(chatMessage, w, rgbPercToHex(colors.r, colors.g, colors.b)..w..modChatColor)
  56.             end
  57.         end
  58.     end
  59.     return chatMessage
  60. end
  61.  
  62. local function handleJoinLeaveChannel(...)
  63.     local _, playerName, _, _, _, _, _, _, channelName = ...
  64.     local _, class = UnitClass(playerName)
  65.     local colors = RAID_CLASS_COLORS[class]
  66.     local playerClassColorHex = rgbPercToHex(colors.r, colors.g, colors.b)..playerName
  67.     return playerClassColorHex, channelName
  68. end
  69.  
  70. local function getNameColors(name)
  71.     if strfind(name, '-') then
  72.         name = strsub(name, 1, strfind(name, '-') - 1)
  73.     end
  74.  
  75.     local _, class = UnitClass(name)
  76.     colors = RAID_CLASS_COLORS[class]
  77.     return colors, name
  78. end
  79.  
  80. local function colorAndFormatChatString(text, modChatColor)
  81.     text = text:gsub('([wWhH][wWtT][wWtT][%.pP]%S+[^%p%s])', '|cffffffff|Hurl:%1|h[%1]|h|r') --find any URLs and make them white hyperlinks
  82.     text = modChatColor..text --color our message so it matches whatever channel we're in
  83.     text = text:gsub('|h|r', '|h|r'..modChatColor) --this is a shitty hack so if someone puts a hyperlink in chat, the text afterwards will go back to the default chat color
  84.     text = hexColorNames(text, modChatColor) --color any player names in chat by their class color
  85.     return text
  86. end
  87. -----------------------------------------------------
  88. --Create Frames, Event Handler, and Filters Section--
  89. -----------------------------------------------------
  90. local channelColorHolderTable = {} --this is used to hold the color of custom chat channels, this is important when you leave the channel
  91. --ToDo: make a for k,v in pairs(table) do /n AddMessageFilter and RegisterEvent to save lines of code
  92. ChatFrame_AddMessageEventFilter('CHAT_MSG_CHANNEL', function() return true end)
  93. ChatFrame_AddMessageEventFilter('CHAT_MSG_CHANNEL_JOIN', function() return true end)
  94. ChatFrame_AddMessageEventFilter('CHAT_MSG_CHANNEL_LEAVE', function() return true end)
  95. ChatFrame_AddMessageEventFilter('CHAT_MSG_CHANNEL_LIST', function() return true end)
  96. ChatFrame_AddMessageEventFilter('CHAT_MSG_CHANNEL_NOTICE', function() return true end)
  97. ChatFrame_AddMessageEventFilter('CHAT_MSG_CHANNEL_NOTICE_USER', function() return true end)
  98.  
  99. ChatFrame_AddMessageEventFilter('CHAT_MSG_AFK', function() return true end)
  100. ChatFrame_AddMessageEventFilter('CHAT_MSG_DND', function() return true end)
  101. --ChatFrame_AddMessageEventFilter('CHAT_MSG_BN_WHISPER', function() return true end)
  102. --ChatFrame_AddMessageEventFilter('CHAT_MSG_BN_WHISPER_INFORM', function() return true end)
  103. --ChatFrame_AddMessageEventFilter('CHAT_MSG_BN_WHISPER_PLAYER_OFFLINE', function() return true end)
  104. --ChatFrame_AddMessageEventFilter('CHAT_MSG_EMOTE', function() return true end)
  105. --ChatFrame_AddMessageEventFilter('CHAT_MSG_IGNORED', function() return true end)
  106. --ChatFrame_AddMessageEventFilter('CHAT_MSG_SAY', function() return true end)
  107. --ChatFrame_AddMessageEventFilter('CHAT_MSG_TEXT_EMOTE', function() return true end)
  108. --ChatFrame_AddMessageEventFilter('CHAT_MSG_WHISPER', function() return true end)
  109. --ChatFrame_AddMessageEventFilter('CHAT_MSG_WHISPER_INFORM', function() return true end)
  110. --ChatFrame_AddMessageEventFilter('CHAT_MSG_YELL', function() return true end)
  111.  
  112. local f = CreateFrame('frame')
  113. f:RegisterEvent('CHAT_MSG_CHANNEL')
  114. f:RegisterEvent('CHAT_MSG_CHANNEL_JOIN')
  115. f:RegisterEvent('CHAT_MSG_CHANNEL_LEAVE')
  116. f:RegisterEvent('CHAT_MSG_CHANNEL_LIST')
  117. f:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE')
  118. f:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE_USER')
  119.  
  120. f:RegisterEvent('CHAT_MSG_AFK')
  121. f:RegisterEvent('CHAT_MSG_DND')
  122. --f:RegisterEvent('CHAT_MSG_BN_WHISPER')
  123. --f:RegisterEvent('CHAT_MSG_BN_WHISPER_INFORM')
  124. --f:RegisterEvent('CHAT_MSG_BN_WHISPER_PLAYER_OFFLINE')
  125. --f:RegisterEvent('CHAT_MSG_EMOTE')
  126. --f:RegisterEvent('CHAT_MSG_IGNORED')
  127. --f:RegisterEvent('CHAT_MSG_SAY')
  128. --f:RegisterEvent('CHAT_MSG_TEXT_EMOTE')
  129. --f:RegisterEvent(' ')
  130. --f:RegisterEvent('CHAT_MSG_WHISPER_INFORM')
  131. --f:RegisterEvent('CHAT_MSG_YELL')
  132.  
  133. f:SetScript('OnEvent', function(self, event, ...) --this is the main handler that creates timeStamp, gets the chat color and passes it along as a hexcode
  134.     local message, player, _, fullChannelName, truncatedPlayer, _, _, channelNumber, channelName, _, _, playerGUID = ...
  135.     local chatType = strsub(event, 10) --chop off first 'CHAT_MSG_' to get the event
  136.     local chatColor = {}
  137.     if strsub(event, 10, 16) == 'CHANNEL' then --this will color chats by their proper color since they're user editable
  138.         chatColor = channelColorHolderTable[channelNumber]
  139.     else
  140.         chatColor = ChatTypeInfo[chatType]
  141.     end
  142.     local timeStamp --this will be used to make our own time stamp for each line
  143.     timeStamp = BetterDate(CHAT_TIMESTAMP_FORMAT, time())
  144.     timeStamp = rgbPercToHex(0.5, 0.5, 0.5)..'['..timeStamp..']|r' --this colors the brackets and text grey and adds them around the text
  145.     timeStamp = gsub(timeStamp, ' ', '') --this removes the random space that gets added between the end of the time string and the ]
  146.     local modChatColor = rgbPercToHex(chatColor.r, chatColor.g, chatColor.b)
  147.  
  148.     if self[event] then --handle our event
  149.         self[event](self, event, chatType, modChatColor, timeStamp, ...)
  150.     end
  151. end)
  152.  
  153. local g = CreateFrame('frame')
  154. g:RegisterEvent('UPDATE_CHAT_COLOR')
  155. --this will find any channels that are associated with numbers, that is custom channels
  156. --it does this by first removing the 'CHANNEL' before the number, and converting the string to a number
  157. --since there are many strings that don't get converted, we find only the ones that are numbers by our if check
  158. --we then make a table entry for the color rgb so when a player leaves that channel, and no color is associated anymore,
  159. --the leaving text still matches the color they left
  160. g:SetScript('OnEvent', function(self, event, ...)
  161.     local channelNumber, r, g, b = ...
  162.     channelNumber = channelNumber:gsub('CHANNEL', '')
  163.     channelNumber = tonumber(channelNumber)
  164.     if channelNumber then
  165.         channelColorHolderTable[channelNumber] = {}
  166.         channelColorHolderTable[channelNumber].r, channelColorHolderTable[channelNumber].g, channelColorHolderTable[channelNumber].b = r, g, b
  167.     end
  168. end)
  169. ----------------------------------------------
  170. --Modified GlobalStrings.lua strings Section--
  171. ----------------------------------------------
  172. CHAT_ANNOUNCEMENTS_OFF_NOTICE       = '%s disabled channel announcements in %s.|r' --playerName..modChatColor, channelName
  173. CHAT_ANNOUNCEMENTS_ON_NOTICE        = '%s enabled channel announcements in %s.|r' --playerName..modChatColor, channelName
  174. CHAT_CHANNEL_OWNER_NOTICE           = '%s is the owner of %s.|r' --playerName..modChatColor, channelName
  175. CHAT_MODERATION_OFF_NOTICE          = '%s disabled channel moderation in %s.|r' --playerName..modChatColor, channelName
  176. CHAT_MODERATION_ON_NOTICE           = '%s enabled channel moderation in %s.|r' --playerName..modChatColor, channelName
  177. CHAT_VOICE_OFF_NOTICE               = '%s disabled channel voice in %s.|r' --playerName..modChatColor, channelName
  178. CHAT_VOICE_ON_NOTICE                = '%s enabled channel voice in %s.|r' --playerName..modChatColor, channelName
  179. CHAT_SET_MODERATOR_NOTICE           = '%s received moderator privileges in %s.|r' --playerName..modChatColor, channelName
  180. CHAT_UNSET_MODERATOR_NOTICE         = '%s lost moderator privileges in %s.|r' --playerName..modChatColor, channelName
  181. CHAT_SET_SPEAK_NOTICE               = '%s received voice chat privileges in %s.|r' --playerName..modChatColor, channelName
  182. CHAT_UNSET_SPEAK_NOTICE             = '%s lost voice chat privileges in %s.|r' --playerName..modChatColor, channelName
  183. CHAT_SET_VOICE_NOTICE               = '%s received chat privileges in %s.|r' --playerName..modChatColor, channelName
  184. CHAT_UNSET_VOICE_NOTICE             = '%s lost chat privileges in %s.|r' --playerName..modChatColor, channelName
  185. CHAT_PASSWORD_CHANGED_NOTICE        = '%s changed the password of %s.|r' --playerName..modChatColor, channelName
  186. CHAT_PLAYER_ALREADY_MEMBER_NOTICE   = '%s is already a member of %s.|r' --playerName..modChatColor, channelName
  187. CHAT_OWNER_CHANGED_NOTICE           = '%s is now the owner of %s.|r' --playerName..modChatColor, channelName
  188. CHAT_INVITE_NOTICE                  = '%s%s invited you to join %s.|r' --playerName..modchatColor, channelName
  189.  
  190. CHAT_BANNED_NOTICE                  = '%sYou are banned from %s.|r' --modChatColor, channelName
  191. CHAT_INVALID_NAME_NOTICE            = '%sThe channel you tried to join, %s, does not exist.|r' --modChatColor, channelName
  192. CHAT_INVITE_WRONG_FACTION_NOTICE    = '%sThat player cannot join %s because they are the wrong faction.|r' --modChatColor, channelName
  193. CHAT_MUTED_NOTICE                   = '%sYou do not have permission to speak in %s.|r' --modChatColor, channelName
  194. CHAT_NOT_ALLOWED_IN_CHANNEL_NOTICE  = '%sYou attempted an action that is not allowed in %s.|r' --modChatColor, channelName
  195. CHAT_NOT_IN_AREA_NOTICE             = '%sYou are not in the correct area for %s.|r' --modChatColor, channelName
  196. CHAT_NOT_MEMBER_NOTICE              = '%sYou are not a member of %s.|r' --modChatColor, channelName
  197. CHAT_NOT_MODERATED_NOTICE           = '%s%s is not moderated.|r' --modChatColor, channelName
  198. CHAT_NOT_MODERATOR_NOTICE           = '%sYou are not a moderator of %s.|r' --modChatColor, channelName
  199. CHAT_NOT_OWNER_NOTICE               = '%sYou are not the owner of %s.|r' --modChatColor, channelName
  200. CHAT_YOU_JOINED_NOTICE              = '%sYou joined %s.|r' --modChatColor, channelName
  201.  
  202. CHAT_PLAYER_BANNED_NOTICE           = '%s banned %s from %s.|r' --playerName..modChatColor, actionTarget, channelName
  203. CHAT_PLAYER_KICKED_NOTICE           = '%s kicked %s from %s.|r' --playerName..modChatColor, actionTarget, channelName
  204. CHAT_PLAYER_UNBANNED_NOTICE         = '%s unbanned %s from %s.|r' --playerName..modChatColor, actionTarget, channelName
  205.  
  206. CHAT_PLAYER_INVITED_NOTICE          = 'You invited %s to join %s.|r' --actionTarget, channelName
  207. CHAT_PLAYER_INVITE_BANNED_NOTICE    = 'You cannot invite %s to %s because they are banned.|r' --actionTarget, channelName
  208.  
  209. CHAT_PLAYER_NOT_BANNED_NOTICE       = '%s is not banned from %s.|r' --actionTarget..modChatColor, channelName
  210. CHAT_PLAYER_NOT_FOUND_NOTICE        = '%s is not in %s.|r' --actionTarget..modChatColor, channelName
  211. --------------------------------------
  212. --Chat Channel Modifications Section--
  213. --------------------------------------
  214. local noticeUserStrings = {
  215.     ['ANNOUNCEMENTS_OFF']   = true,
  216.     ['ANNOUNCEMENTS_ON']    = true,
  217.     ['CHANNEL_OWNER']       = true,
  218.     ['MODERATION_OFF']      = true,
  219.     ['MODERATION_ON']       = true,
  220.     ['VOICE_OFF']           = true,
  221.     ['VOICE_ON']            = true,
  222.     ['SET_MODERATOR']       = true,
  223.     ['UNSET_MODERATOR']     = true,
  224.     ['SET_SPEAK']           = true,
  225.     ['UNSET_SPEAK']         = true,
  226.     ['SET_VOICE']           = true,
  227.     ['UNSET_VOICE']         = true,
  228.     ['PASSWORD_CHANGED']    = true,
  229.     ['PLAYER_ALREADY_MEMBER']   = true,
  230.     ['OWNER_CHANGED']       = true,
  231.     ['INVITE_NOTICE']       = true
  232. }
  233.  
  234. local channelNoticeStrings = {
  235.     ['BANNED']              = true,
  236.     ['INVALID_NAME']        = true,
  237.     ['INVITE_WRONG_FACTION']= true,
  238.     ['MUTED']               = true,
  239.     ['NOT_ALLOWED_IN_CHANNEL']  = true,
  240.     ['NOT_IN_AREA']         = true,
  241.     ['NOT_MEMBER']          = true,
  242.     ['NOT_MODERATED']       = true,
  243.     ['NOT_MODERATOR']       = true,
  244.     ['NOT_OWNER']           = true,
  245.     ['YOU_JOINED']          = true
  246. }
  247.  
  248. local targetActionNoticeStrings = {
  249.     ['PLAYER_BANNED']       = true,
  250.     ['PLAYER_KICKED']       = true,
  251.     ['PLAYER_UNBANNED']     = true
  252. }
  253.  
  254. local yourInviteNoticeStrings = {
  255.     ['PLAYER_INVITED']      = true,
  256.     ['PLAYER_INVITE_BANNED']= true
  257. }
  258.  
  259. local targetErrorNoticeStrings = {
  260.     ['PLAYER_NOT_BANNED']   = true,
  261.     ['PLAYER_NOT_FOUND']    = true
  262. }
  263.  
  264. function f:CHAT_MSG_CHANNEL(event, chatType, modChatColor, timeStamp, ...) --anytime a message is added by you or another player
  265.     local chatMessage, sender, senderLanguage, fullChannelName, arg5, senderFlags, arg7, channelNumber, arg9, arg10, chatLineID, senderGUID = ...
  266.  
  267.     channelNumber = modChatColor..channelNumber..'.|r' --properly color and skin the channel number to appear as '#.'
  268.  
  269.     chatMessage = colorAndFormatChatString(chatMessage, modChatColor) --handle url hyperlinking, channel coloring, and coloring names that may appear in chat
  270.  
  271.     if senderGUID then --hack for local defense 'x zone is under attack' messages trying to make player links when no one was making the phrase
  272.         local playerLink = createPlayerLinks(event, chatType, ...) --generate our hyperlinks for players in chat
  273.         chatMessage = timeStamp.. ' '..channelNumber..' '..playerLink..modChatColor..': |r'..chatMessage --put it all together
  274.     else
  275.         chatMessage = timeStamp..' '..channelNumber..modChatColor..': |r'..chatMessage --put it all together
  276.     end
  277.  
  278.     ChatFrame1:AddMessage(chatMessage)
  279. end
  280.  
  281. function f:CHAT_MSG_CHANNEL_NOTICE(event, chatType, modChatColor, timeStamp, ...) --fires when you change channels
  282.     local notice, _, _, _, _, _, _, _, channelName = ...
  283.     if notice then
  284.         local _, class = UnitClass('player')
  285.         local colors = RAID_CLASS_COLORS[class]
  286.         local You = rgbPercToHex(colors.r, colors.g, colors.b)..'You' --color the word 'You' by your class color
  287.  
  288.         if notice == 'YOU_CHANGED' then
  289.             ChatFrame1:AddMessage(timeStamp..' '..You..modChatColor..' joined '..channelName..'.|r')
  290.         elseif (notice == 'YOU_LEFT' or notice == 'SUSPENDED') then
  291.             ChatFrame1:AddMessage(timeStamp..' '..You..modChatColor..' left '..channelName..'.|r')
  292.         elseif notice == 'THROTTLED' then
  293.             ChatFrame1:AddMessage(timeStamp..' '..You..modChatColor..' were throttled in '..channelName..'.|r')
  294.         end
  295.     end
  296. end
  297.  
  298. function f:CHAT_MSG_CHANNEL_JOIN(event, chatType, modChatColor, timeStamp, ...) --fires when another player joins a channel you're in
  299.     local playerClassColorHex, channelName = handleJoinLeaveChannel(...) --returns a colorized player name and the colored channel name
  300.     ChatFrame1:AddMessage(timestamp..' '..playerName..modChatColor..' + '..channelName..'.|r')
  301. end
  302.  
  303. function f:CHAT_MSG_CHANNEL_LEAVE(event, chatType, modChatColor, timeStamp, ...) --fires when another player leaves a channel you're in
  304.     local playerClassColorHex, channelName = handleJoinLeaveChannel(...) --returns a colorized player name and the colored channel name
  305.     ChatFrame1:AddMessage(timestamp..' '..playerName..modChatColor..' - '..channelName..'.|r')
  306. end
  307.  
  308. function f:CHAT_MSG_CHANNEL_LIST(event, chatType, modChatColor, timeStamp, ...) --fires when you type /script ListChannels()
  309.     local arg1 = ... --arg1 is the string of channels
  310.     ChatFrame1:AddMessage(timeStamp..' '..'|cffc0c0c0'..arg1..'|r') --cffc0c0c0 is the hexcode for a grey text
  311. end
  312.  
  313. function f:CHAT_MSG_CHANNEL_NOTICE_USER(event, chatType, modChatColor, timeStamp, ...) --fires after a LOT of different chat events related to channel management
  314.     local notice, playerName, _, _, actionTarget, _, _, _, channelName = ...
  315.     local colors, targetColors --call these up top so they're accessible to the if statements below
  316.     if playerName then
  317.         colors, playerName = getNameColors(playerName)
  318.         playerName = rgbPercToHex(colors. r, colors.g, colors.b)..playerName
  319.     end
  320.  
  321.     if actionTarget then
  322.         targetColors = getNameColors(actionTarget)
  323.         actionTarget = rgbPercToHex(targetColors.r, targetColors.g, targetColors.b)..actionTarget
  324.     end
  325.     --the idea of this is to run through various hash tables and handle these strings accordingly. this has more pipeline stalls than I'd like,
  326.     --but it's better than a much longer if elseif chain for each individual case. the final lines have a catch in case I missed a notice and someone finds it other than me
  327.     if noticeUserStrings[notice] then
  328.         colors = getNameColors('player')
  329.         local you = rgbPercToHex(colors.r, colors.g, colors.b)..'you'
  330.         _G['CHAT_'..notice..'_NOTICE'] = _G['CHAT_'..notice..'_NOTICE']:gsub('you', you..modChatColor) --replace 'you' with a class colored 'you'
  331.         ChatFrame1:AddMessage(string.format(timeStamp..' '.._G['CHAT_'..notice..'_NOTICE'], playerName..modChatColor, channelName))
  332.     elseif channelNoticeStrings[notice] then
  333.         colors = getNameColors('player')
  334.         local You = rgbPercToHex(colors.r, colors.g, colors.b)..'You'
  335.         local you = rgbPercToHex(colors.r, colors.g, colors.b)..'you'
  336.         _G['CHAT_'..notice..'_NOTICE'] = _G['CHAT_'..notice..'_NOTICE']:gsub('You', You..modChatColor) --replace 'You' with a class colored 'You'
  337.         _G['CHAT_'..notice..'_NOTICE'] = _G['CHAT_'..notice..'_NOTICE']:gsub('you', you..modChatColor) --replace 'you' with a class colored 'you'
  338.         ChatFrame1:AddMessage(string.format(timeStamp..' '.._G['CHAT_'..notice..'_NOTICE'], modChatColor, channelName))
  339.     elseif targetActionNoticeStrings[notice] then
  340.         ChatFrame1:AddMessage(string.format(timeStamp..' '.._G['CHAT_'..notice..'_NOTICE'], playerName..modChatColor, actionTarget, channelName))
  341.     elseif yourInviteNoticeStrings[notice] then
  342.         colors = getNameColors('player')
  343.         local You = rgbPercToHex(colors.r, colors.g, colors.b)..'You'
  344.         _G['CHAT_'..notice..'NOTICE'] = _G['CHAT_'..notice..'_NOTICE']:gsub('You', You..modChatColor) --replace 'You' with a class colored 'You'
  345.         ChatFrame1:AddMessage(string.format(timeStamp..' '.._G['CHAT_'..notice..'_NOTICE'], actionTarget, channelName))
  346.     elseif targetActionNoticeStrings[notice] then
  347.         ChatFrame1:AddMessage(string.format(timeStamp..' '.._G['CHAT_'..notice..'_NOTICE'], actionTarget..modChatColor, channelName))
  348.     else
  349.         print('tell terenna that the '..notice..' is not properly handled.')
  350.     end
  351. end
  352.  
  353. ------------------------------------------------
  354. --Say, Yell, and Whisper Modifications Section--
  355. ------------------------------------------------
  356. --[[
  357. removing the brackets around this would allow you to once again see the player you whispered's afk message. we filtered it out above.
  358. function f:CHAT_MSG_AFK(event, chatType, modChatColor, timeStamp, ...)
  359.     local afkMessage, fullNameAndRealm, _, _, nameNoRealm = ...
  360.     local playerLink = createPlayerLinks(event, chatType, ...) --generate our hyperlinks for players in chat
  361.     afkMessage = colorAndFormatChatString(afkMessage, modChatColor)
  362.     afkMessage = timeStamp.. ' '..playerLink..modChatColor..' is away: |r'..afkMessage --put it all together
  363.     ChatFrame1:AddMessage(afkMessage)
  364. end
  365. ]]--
  366. --[[
  367. removing the brackets around this would allow you to once again see the player you whispered's dnd message. we filtered it out above.
  368. function f:CHAT_MSG_DND(event, chatType, modChatColor, timeStamp, ...)
  369.     local dndMessage, fullNameAndRealm, _, _, nameNoRealm = ...
  370.     local playerLink = createPlayerLinks(event, chatType, ...) --generate our hyperlinks for players in chat
  371.     dndMessage = colorAndFormatChatString(dndMessage, modChatColor)
  372.     dndMessage = timeStamp.. ' '..playerLink..modChatColor..' does not wished to be disturbed: |r'..dndMessage --put it all together
  373.     ChatFrame1:AddMessage(dndMessage)
  374. end
  375. ]]--
  376. --[[
  377. CHAT_MSG_ACHIEVEMENT
  378. CHAT_MSG_ADDON
  379. CHAT_MSG_BG_SYSTEM_ALLIANCE
  380. CHAT_MSG_BG_SYSTEM_HORDE
  381. CHAT_MSG_BG_SYSTEM_NEUTRAL
  382. CHAT_MSG_BN_INLINE_TOAST_ALERT
  383. CHAT_MSG_BN_INLINE_TOAST_BROADCAST
  384. CHAT_MSG_BN_INLINE_TOAST_BROADCAST_INFORM
  385. CHAT_MSG_BN_INLINE_TOAST_CONVERSATION
  386. CHAT_MSG_BN_WHISPER
  387. CHAT_MSG_BN_WHISPER_INFORM
  388. CHAT_MSG_BN_WHISPER_PLAYER_OFFLINE
  389. CHAT_MSG_COMBAT_FACTION_CHANGE
  390. CHAT_MSG_COMBAT_HONOR_GAIN
  391. CHAT_MSG_COMBAT_MISC_INFO
  392. CHAT_MSG_COMBAT_XP_GAIN
  393. CHAT_MSG_COMMUNITIES_CHANNEL
  394. CHAT_MSG_CURRENCY
  395. CHAT_MSG_EMOTE
  396. CHAT_MSG_FILTERED
  397. CHAT_MSG_GUILD
  398. CHAT_MSG_GUILD_ACHIEVEMENT
  399. CHAT_MSG_GUILD_ITEM_LOOTED
  400. CHAT_MSG_IGNORED
  401. CHAT_MSG_INSTANCE_CHAT
  402. CHAT_MSG_INSTANCE_CHAT_LEADER
  403. CHAT_MSG_LOOT
  404. CHAT_MSG_MONEY
  405. CHAT_MSG_MONSTER_EMOTE
  406. CHAT_MSG_MONSTER_PARTY
  407. CHAT_MSG_MONSTER_SAY
  408. CHAT_MSG_MONSTER_WHISPER
  409. CHAT_MSG_MONSTER_YELL
  410. CHAT_MSG_OFFICER
  411. CHAT_MSG_OPENING
  412. CHAT_MSG_PARTY
  413. CHAT_MSG_PARTY_LEADER
  414. CHAT_MSG_PET_BATTLE_COMBAT_LOG
  415. CHAT_MSG_PET_BATTLE_INFO
  416. CHAT_MSG_PET_INFO
  417. CHAT_MSG_RAID
  418. CHAT_MSG_RAID_BOSS_EMOTE
  419. CHAT_MSG_RAID_BOSS_WHISPER
  420. CHAT_MSG_RAID_LEADER
  421. CHAT_MSG_RAID_WARNING
  422. CHAT_MSG_RESTRICTED
  423. CHAT_MSG_SAY
  424. CHAT_MSG_SKILL
  425. CHAT_MSG_SYSTEM
  426. CHAT_MSG_TARGETICONS
  427. CHAT_MSG_TEXT_EMOTE
  428. CHAT_MSG_TRADESKILLS
  429. CHAT_MSG_WHISPER
  430. CHAT_MSG_WHISPER_INFORM
  431. CHAT_MSG_YELL
  432. CHAT_SERVER_DISCONNECTED
  433. CHAT_SERVER_RECONNECTED
  434. CLUB_MESSAGE_ADDED
  435. ]]--
  Reply With Quote