vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ ChatBox |
2 | by Norbet and the [many] unsung heroes. |
||
3 | |||
4 | |||
5 | -- |
||
6 | -- Change the chat groups to split out the Officer and Raid channels. |
||
7 | -- |
||
8 | ChatTypeGroup["PARTY"] = { |
||
9 | "CHAT_MSG_PARTY" |
||
10 | }; |
||
11 | |||
12 | ChatTypeGroup["RAID"] = { |
||
13 | "CHAT_MSG_RAID" |
||
14 | }; |
||
15 | ChannelMenuChatTypeGroups[6] = "RAID"; |
||
16 | |||
17 | now iterate through the chat frames and add the new raid channel.. |
||
18 | ChatFrame_AddMessageGroup(chatFrame, "RAID"); |
||
19 | |||
20 | now the hooks.. |
||
21 | |||
22 | ChatBox_FCFMessageTypeDropDown_OnClick = function() |
||
23 | -- For some reason the game refuses to save these in chat-cache.txt so I have to save them myself. |
||
24 | if (this.value == "RAID") then |
||
25 | local checked = UIDropDownMenuButton_GetChecked(); |
||
26 | local chatFrameName = FCF_GetCurrentChatFrame():GetName(); |
||
27 | |||
28 | if (not ChatBox[chatFrameName]) then |
||
29 | ChatBox[chatFrameName] = {}; |
||
30 | end |
||
31 | |||
32 | if (checked) then |
||
33 | ChatBox[chatFrameName][this.value] = nil; |
||
34 | else |
||
35 | ChatBox[chatFrameName][this.value] = 1; |
||
36 | end |
||
37 | end |
||
38 | |||
39 | CB_Orig_FCFMessageTypeDropDown_OnClick(); |
||
40 | end |
||
41 | |||
42 | |||
43 | ChatBox_FCF_OpenNewWindow = function(name) |
||
44 | CB_Orig_FCF_OpenNewWindow(name); |
||
45 | |||
46 | local chatFrame; |
||
47 | local chatTab; |
||
48 | local frameName; |
||
49 | |||
50 | for i=1, NUM_CHAT_WINDOWS do |
||
51 | chatFrame = getglobal("ChatFrame"..i); |
||
52 | chatTab = getglobal("ChatFrame"..i.."Tab"); |
||
53 | frameName = chatFrame:GetName(); |
||
54 | if (chatTab:GetText() == name) then |
||
55 | ChatFrame_AddMessageGroup(chatFrame, "RAID"); |
||
56 | |||
57 | if (not ChatBox[frameName]) then |
||
58 | ChatBox[frameName] = {}; |
||
59 | end |
||
60 | ChatBox[frameName]["RAID"] = 1; |
||
61 | return; |
||
62 | end |
||
63 | end |
||
64 | end |
||
65 | |||
66 | ]]-- |
||
67 | |||
68 | |||
69 | |||
70 | |||
71 | |||
72 | --init start vars... |
||
73 | ChatBox_isLoaded = nil |
||
74 | ChatBox_lastName = nil |
||
75 | CB_Orig_OnHyperlinkEnter_Table = {}; |
||
76 | CB_Orig_OnHyperlinkLeave_Table = {}; |
||
77 | ChatBox_frameCount = 0 |
||
78 | ChatBox_LastTell = "" |
||
79 | ChatBox_actions = { banker=1, taxi=1, trainer=1, vendor=1 }; |
||
80 | |||
81 | |||
82 | --misc stuff |
||
83 | local linkstring = "%s|Hxhenc:%s<XH>%s|h[%s]|h|r" -- color, arg2 (name), arg1, link |
||
84 | local linkstring2 = "%s|Hxhlink:%s<XH>%s|h[%s]|h|r" -- color, arg2 (name), arg1, link |
||
85 | local itemcapstr = "|c[%a%d]+|Hitem:%d+:%d+:%d+:%d+|h%[([^%]]+)%]|h|r" |
||
86 | local guildstring = "%s|Hxhguild:%s<XH>%s|h[%s]|h|r" -- color, arg2 (name), arg1, link |
||
87 | --TODO get rid of maybe? |
||
88 | local itemlinkformat = "item:" |
||
89 | local playerlinkformat = "player:" |
||
90 | local speciallinkformat = "xhenc:(%w+)<XH>(.+)" |
||
91 | local portallinkformat = "xhlink:(%w+)<XH>(.+)" |
||
92 | local hyperlinkformat = "ref:(.*)(%b[])|h" |
||
93 | local guildlinkformat = "xhguild:(%w+)<XH>(.+)" |
||
94 | |||
95 | |||
96 | local usedColors = {}; |
||
97 | local usedNames = {}; |
||
98 | |||
99 | -- Colors |
||
100 | GRN ="|cff20ff20" |
||
101 | YEL ="|cffffff00" |
||
102 | RED ="|cffff0000" |
||
103 | WHT ="|cffffffff" |
||
104 | BLU ="|cff8888ff" |
||
105 | DRKBLU ="|cff1b0495" |
||
106 | ORN ="|cffff9C00" |
||
107 | GRY ="|cffA0A0A0" |
||
108 | END = "|r" |
||
109 | |||
110 | |||
111 | |||
112 | local colorsubs = { |
||
113 | [YEL] = { |
||
114 | ["%[?Ara?ca?i?n?i?t?e? ?B?a?r? ?Tran?m?s?m?u?t?e?a?t?i?o?n?%]?"] = "Arcanite Transmute", |
||
115 | ["Ara?ca?i?n?i?t?e? ?B?a?r? ?xmute"] = "Arcanite Transmute", |
||
116 | ["Transmute?i?n?g?:? ?Ara?ca?n?i?t?e? ?B?a?r?"] = "Arcanite Transmute", |
||
117 | }, |
||
118 | [ORN] = { |
||
119 | ["Porta?l? ?f?t?o?r? Org?r?i?m?m?a?r?"] = "Portal: Orgrimmar", |
||
120 | ["Porta?l? ?f?t?o?r? Un?d?e?r?Ci?t?y?"] = "Portal: Undercity", |
||
121 | ["Porta?l? ?f?t?o?r? Th?u?n?d?e?r? ?Bl?u?f?f?"] = "Portal: Thunder Bluff", |
||
122 | ["Porta?l? ?f?t?o?r? Ir?o?n? ?Fo?r?g?e?"] = "Portal: Ironforge", |
||
123 | ["Porta?l? ?f?t?o?r? ST?o?r?m?Wi?n?d?"] = "Portal: Stormwind", |
||
124 | ["Porta?l? ?f?t?o?r? Dara?n?na?s?s?u?a?i?s?"] = "Portal: Darnassus", |
||
125 | } |
||
126 | } |
||
127 | |||
128 | --------------------------------------------------------------------------------------------------- |
||
129 | --Item Relinker and ChatLink |
||
130 | ---------------------------------------------------------------------------------------------------- |
||
131 | |||
132 | -- Turn CLINKs into normal item links. |
||
133 | function ChatBox_Decompose (chatstring) |
||
134 | if chatstring then |
||
135 | chatstring = string.gsub (chatstring, "{CLINK:(%x+):(%d-):(%d-):(%d-):(%d-):([^}]-)}", "|c%1|Hitem:%2:%3:%4:%5|h[%6]|h|r") |
||
136 | end |
||
137 | return chatstring |
||
138 | end |
||
139 | |||
140 | -- Turn item links into CLINKs. |
||
141 | function ChatBox_Compose (chatstring) |
||
142 | if chatstring then |
||
143 | chatstring = string.gsub (chatstring, "|c(%x+)|Hitem:(%d-):(%d-):(%d-):(%d-)|h%[([^%]]-)%]|h|r", "{CLINK:%1:%2:%3:%4:%5:%6}") |
||
144 | end |
||
145 | return chatstring |
||
146 | end |
||
147 | |||
148 | -- Translate item links into CLINKs on outgoing non-system channel messages. |
||
149 | function ChatBox_SendChatMessage (msg, ...) |
||
150 | local chan_num, chan_name = nil |
||
151 | system, language, channel = unpack (arg) |
||
152 | |||
153 | if ChatBox.CLINK and system == "CHANNEL" then |
||
154 | chan_num, chan_name = GetChannelName (channel) |
||
155 | if chan_name and |
||
156 | not string.find (chan_name, CB_GENERAL) and |
||
157 | not string.find (chan_name, CB_TRADE) and |
||
158 | not string.find (chan_name, CB_LFG) and |
||
159 | not string.find (chan_name, CB_LOCALDEF) and |
||
160 | not string.find (chan_name, CB_WORLDDEF) then |
||
161 | msg = ChatBox_Compose (msg) |
||
162 | end |
||
163 | end |
||
164 | |||
165 | -- Pass along to original function. |
||
166 | CB_Orig_SendChatMessage (msg, unpack (arg)) |
||
167 | end |
||
168 | |||
169 | function ChatBox_OnEvent(event) |
||
170 | |||
171 | local function updateFriendsList() |
||
172 | if not ChatBox.colorNames then return end; |
||
173 | local numFriends = GetNumFriends(); |
||
174 | for i = 1, numFriends do |
||
175 | local name, _, class, _ = GetFriendInfo(i); |
||
176 | if( class and name and class ~= "Unknown" ) then |
||
177 | ChatBox_ClassData(name, class); |
||
178 | end |
||
179 | end |
||
180 | end |
||
181 | |||
182 | local function updateGuildList() |
||
183 | if not ChatBox.colorNames then return end; |
||
184 | local numGuild = GetNumGuildMembers(); |
||
185 | for i = 1, numGuild do |
||
186 | local name,_,_,_,class = GetGuildRosterInfo(i); |
||
187 | if( class and name ) then |
||
188 | ChatBox_ClassData(name, class); |
||
189 | end |
||
190 | end |
||
191 | end |
||
192 | |||
193 | if event == "VARIABLES_LOADED" then |
||
194 | |||
195 | cb_display("|cffFFFFFF"..CB_LOADED .. CB_VERSION); |
||
196 | |||
197 | if (not ChatBox) or |
||
198 | (ChatBox and not ChatBox.version) or |
||
199 | (ChatBox and ChatBox.version and ChatBox.version ~= CB_VERSION) then |
||
200 | SetupChatVars(); |
||
201 | updateFriendsList(); |
||
202 | end |
||
203 | |||
204 | --this purges our database of names once per month (to keep if from getting HUGE!) |
||
205 | if ChatBox.date ~= date("%m") then |
||
206 | cb_display(RED.. "Purging the "..YEL.."name<->color " .. RED .. "database from last month.") |
||
207 | ChatBox_Names = {}; |
||
208 | ChatBox.date = date("%m"); |
||
209 | end |
||
210 | |||
211 | --Extends the "default to last channel" <Enter> keypress to include numbered and (possible) whisper channels. |
||
212 | ChatBox_SetSticky(); |
||
213 | |||
214 | --Alternative Global Strings |
||
215 | ChatBox_SetStrings(); |
||
216 | |||
217 | --make the arrows work in chat. |
||
218 | if ChatBox.useArrows then |
||
219 | ChatFrameEditBox:SetAltArrowKeyMode(false); |
||
220 | end |
||
221 | |||
222 | --Move EditBox to the top |
||
223 | if ChatBox.editAtTop then |
||
224 | ChatFrameEditBox:ClearAllPoints(); |
||
225 | ChatFrameEditBox:SetPoint("BOTTOMLEFT", "ChatFrame1", "TOPLEFT", 0, 2); |
||
226 | ChatFrameEditBox:SetPoint("BOTTOMRIGHT", "ChatFrame1", "TOPRIGHT", 0, 2); |
||
227 | end |
||
228 | |||
229 | --show/hide the emote button |
||
230 | if ChatBox.hideEmoteButton then |
||
231 | ChatFrameMenuButton:Hide() |
||
232 | end |
||
233 | |||
234 | -- Move the side buttons to new spot |
||
235 | ChatBox_Relocate_Buttons() |
||
236 | |||
237 | -- setup the additional data for my player link menu. |
||
238 | UnitPopupButtons["WHO"] = { text = TEXT(WHO), dist = 0 }; |
||
239 | UnitPopupButtons["TARGET"] = { text = TEXT(CB_TARGET), dist = 0 }; |
||
240 | UnitPopupButtons["IGNORE"] = { text = TEXT(IGNORE), dist = 0 }; |
||
241 | UnitPopupButtons["ADDFRIEND"] = { text = TEXT(ADD_FRIEND), dist = 0 }; |
||
242 | UnitPopupButtons["UNIGNORE"] = { text = TEXT(CB_UNIGNORE), dist = 0 }; |
||
243 | UnitPopupButtons["REMOVEFRIEND"] = { text = TEXT(CB_REMOVEFRIEND), dist = 0 }; |
||
244 | |||
245 | SetupPLM(); |
||
246 | |||
247 | --to trigger the GUILD_ROSTER_UPDATE event |
||
248 | GuildRoster(); |
||
249 | |||
250 | -- add current online friends |
||
251 | elseif ( event == "FRIENDLIST_UPDATE" ) then |
||
252 | updateFriendsList(); |
||
253 | |||
254 | --now add the people when doing a WHO |
||
255 | elseif ( event == "WHO_LIST_UPDATE" ) then |
||
256 | local numWhoList = GetNumWhoResults(); |
||
257 | if ( numWhoList and numWhoList > 20 ) then |
||
258 | numWhoList = 20; |
||
259 | end |
||
260 | if ( not numWhoList ) then |
||
261 | numWhoList = 2; |
||
262 | end |
||
263 | for i = 1, numWhoList do |
||
264 | local name, _, _, _, class = GetWhoInfo(i); |
||
265 | if( class ~= nil and name ~= nil ) then |
||
266 | ChatBox_ClassData(name, class); |
||
267 | end |
||
268 | end |
||
269 | |||
270 | -- add current online guild members |
||
271 | elseif ( event == "GUILD_ROSTER_UPDATE" ) then |
||
272 | updateGuildList(); |
||
273 | end |
||
274 | end |
||
275 | |||
276 | function ChatBox_Relocate_Buttons() |
||
277 | if ChatBox.menuOnLeft then |
||
278 | spotSide = "LEFT"; |
||
279 | spotEmote = "TOPLEFT"; |
||
280 | else |
||
281 | spotSide = "RIGHT"; |
||
282 | spotEmote = "TOPRIGHT"; |
||
283 | end |
||
284 | |||
285 | if ChatBox_frameCount == 0 then |
||
286 | return; |
||
287 | end |
||
288 | --put a for loop here to do all the frames. |
||
289 | for i=1, 7 do |
||
290 | -- Move the side buttons to new spot |
||
291 | local frame1 = getglobal('ChatFrame'..i..'BottomButton'); |
||
292 | local frame2 = getglobal('ChatFrame'..i); |
||
293 | frame1:SetPoint("RIGHT", frame2, spotSide, 0, 0); |
||
294 | frame1:SetPoint("LEFT", frame2, spotSide, -32, 0); |
||
295 | frame1:SetPoint("TOP", frame2, "BOTTOM", 0, 28); |
||
296 | frame1:SetPoint("BOTTOM", frame2, "BOTTOM", 0, 0); |
||
297 | |||
298 | --change the resize limits of the scroll frame |
||
299 | frame2:SetMinResize(32,32); |
||
300 | frame2:SetMaxResize(1600,1600); |
||
301 | |||
302 | --set MY script so that the hylerink on enter thing does what i want. |
||
303 | CB_Orig_OnHyperlinkEnter_Table["ChatFrame"..i] = getglobal("ChatFrame"..i):GetScript("OnHyperlinkEnter"); |
||
304 | CB_Orig_OnHyperlinkLeave_Table["ChatFrame"..i] = getglobal("ChatFrame"..i):GetScript("OnHyperlinkLeave"); |
||
305 | getglobal("ChatFrame"..i):SetScript("OnHyperlinkEnter", ChatBox_OnHyperlinkEnter); |
||
306 | getglobal("ChatFrame"..i):SetScript("OnHyperlinkLeave", ChatBox_OnHyperlinkHide); |
||
307 | end |
||
308 | |||
309 | ChatFrameMenuButton:SetAlpha(.4); |
||
310 | ChatFrameMenuButton:ClearAllPoints(); |
||
311 | ChatFrameMenuButton:SetPoint("TOPRIGHT", ChatFrame1, spotEmote, 0, 0); |
||
312 | end |
||
313 | |||
314 | |||
315 | function SetupChatVars() |
||
316 | cb_display(GRN .. "Different Version!" .. RED.. " Checking the vars"); |
||
317 | |||
318 | if not ChatBox then |
||
319 | ChatBox = {}; |
||
320 | end |
||
321 | |||
322 | ChatBox.date = date("%m"); |
||
323 | ChatBox.version = tonumber(CB_VERSION); |
||
324 | |||
325 | if ( ChatBox.setSticky == nil ) then |
||
326 | ChatBox.setSticky = true; |
||
327 | end |
||
328 | if ( ChatBox.shortLFG == nil ) then |
||
329 | ChatBox.shortLFG = true; |
||
330 | end |
||
331 | if ( ChatBox.useArrows == nil ) then |
||
332 | ChatBox.useArrows = true; |
||
333 | end |
||
334 | if ( ChatBox.throttle == nil ) then |
||
335 | ChatBox.throttle = 10; |
||
336 | end |
||
337 | if ( ChatBox.gthrottle == nil ) then |
||
338 | ChatBox.gthrottle = 20; |
||
339 | end |
||
340 | if ( ChatBox.hideGossip == nil ) then |
||
341 | ChatBox.hideGossip = true; |
||
342 | end |
||
343 | if ( ChatBox.longStrings == nil ) then |
||
344 | ChatBox.longStrings = true; |
||
345 | end |
||
346 | if ChatBox.plm_shift == nil then |
||
347 | ChatBox.plm_shift = ChatBox_specialSendWho; |
||
348 | ChatBox.plm_shift_name = WHO; |
||
349 | end |
||
350 | if ( ChatBox.TimeStamp_Settings == nil ) then |
||
351 | ChatBox.TimeStamp_Settings = { |
||
352 | color = false, |
||
353 | format = "[%H:%M:%S]", |
||
354 | frames = { |
||
355 | ChatFrame1 = CB_OFF, |
||
356 | ChatFrame2 = CB_OFF, |
||
357 | ChatFrame3 = CB_OFF, |
||
358 | ChatFrame4 = CB_OFF, |
||
359 | ChatFrame5 = CB_OFF, |
||
360 | ChatFrame6 = CB_OFF, |
||
361 | ChatFrame7 = CB_OFF, |
||
362 | }, |
||
363 | }; |
||
364 | end |
||
365 | end |
||
366 | |||
367 | ---------------------------------------------------------------------------------------------------- |
||
368 | --Tiny Chat |
||
369 | ---------------------------------------------------------------------------------------------------- |
||
370 | |||
371 | function ChatBoxFrame_OnUpdate() |
||
372 | |||
373 | |||
374 | --emote icon |
||
375 | if ChatBox.hideEmoteButton and ChatFrameMenuButton:IsVisible() then |
||
376 | ChatFrameMenuButton:Hide() |
||
377 | end |
||
378 | |||
379 | --button icons |
||
380 | local frame1 = this:GetParent():GetName().."UpButton" |
||
381 | local frame2 = this:GetParent():GetName().."DownButton" |
||
382 | local frame3 = this:GetParent():GetName().."BottomButton" |
||
383 | local frame4 = this:GetParent():GetName() |
||
384 | |||
385 | if (getglobal(frame1)):IsVisible() then |
||
386 | getglobal(frame1):Hide() |
||
387 | end |
||
388 | if (getglobal(frame2)):IsVisible() then |
||
389 | getglobal(frame2):Hide() |
||
390 | end |
||
391 | |||
392 | if ( (getglobal(frame4)):AtBottom() or ChatBox.hideBottomButton ) then |
||
393 | if (getglobal(frame3)):IsVisible() then |
||
394 | getglobal(frame3):Hide() |
||
395 | end |
||
396 | else |
||
397 | getglobal(frame3):Show() |
||
398 | end |
||
399 | |||
400 | end |
||
401 | |||
402 | function ChatBoxFrame_OnMouseWheel(chatframe, value) |
||
403 | if ( value > 0 ) then |
||
404 | if IsShiftKeyDown() then |
||
405 | chatframe:ScrollToTop() |
||
406 | elseif IsControlKeyDown() then |
||
407 | chatframe:ScrollUp() |
||
408 | chatframe:ScrollUp() |
||
409 | chatframe:ScrollUp() |
||
410 | else |
||
411 | chatframe:ScrollUp() |
||
412 | end |
||
413 | elseif ( value < 0 ) then |
||
414 | if IsShiftKeyDown() then |
||
415 | chatframe:ScrollToBottom() |
||
416 | elseif IsControlKeyDown() then |
||
417 | chatframe:ScrollDown() |
||
418 | chatframe:ScrollDown() |
||
419 | chatframe:ScrollDown() |
||
420 | else |
||
421 | chatframe:ScrollDown() |
||
422 | end |
||
423 | end |
||
424 | end |
||
425 | |||
426 | |||
427 | ---------------------------------------------------------------------------------------------------- |
||
428 | -- Combined Onload |
||
429 | ---------------------------------------------------------------------------------------------------- |
||
430 | |||
431 | function ChatBoxFrame_OnLoad() |
||
432 | |||
433 | --count how many frames we have. |
||
434 | ChatBox_frameCount = ChatBox_frameCount + 1 |
||
435 | |||
436 | if (not ChatBox_isLoaded) then |
||
437 | |||
438 | ChatBox_isLoaded = true; |
||
439 | |||
440 | --vars loaded!! |
||
441 | this:RegisterEvent("VARIABLES_LOADED") |
||
442 | --anything to do with vars put there!! DOH!!! |
||
443 | |||
444 | --to scan the guild and friend and wholist thing for class names. |
||
445 | this:RegisterEvent("GUILD_ROSTER_UPDATE"); |
||
446 | this:RegisterEvent("FRIENDLIST_UPDATE"); |
||
447 | this:RegisterEvent("WHO_LIST_UPDATE"); |
||
448 | |||
449 | --hooks for the chat link relinker into other chat channels |
||
450 | CB_Orig_SendChatMessage = SendChatMessage; |
||
451 | SendChatMessage = ChatBox_SendChatMessage; |
||
452 | |||
453 | -- Hooks for the enchantments |
||
454 | CB_Orig_SetItemRef = SetItemRef; |
||
455 | SetItemRef = ChatBox_SetItemRef; |
||
456 | |||
457 | CB_Orig_ChatFrame_OnEvent = ChatFrame_OnEvent; |
||
458 | ChatFrame_OnEvent = ChatBox_ChatFrame_OnEvent; |
||
459 | |||
460 | -- Hook gossip window |
||
461 | CB_Orig_GossipFrame_OnEvent = GossipFrame_OnEvent; |
||
462 | GossipFrame_OnEvent = ChatBox_Gossip; |
||
463 | |||
464 | -- hooks to do my own player link menu. |
||
465 | CB_Orig_UnitPopup_HideButtons = UnitPopup_HideButtons; |
||
466 | UnitPopup_HideButtons = ChatBox_UnitPopup_HideButtons; |
||
467 | |||
468 | CB_Orig_UnitPopup_OnClick = UnitPopup_OnClick; |
||
469 | UnitPopup_OnClick = ChatBox_UnitPopup_OnClick; |
||
470 | |||
471 | --register the slash commands. |
||
472 | SlashCmdList["CHATBOX"] = ChatBox_Commands; |
||
473 | SLASH_CHATBOX1 = "/chatbox"; |
||
474 | SLASH_CHATBOX2 = "/cb"; |
||
475 | |||
476 | -- Enable slash commands |
||
477 | SlashCmdList["TIMESTAMP"] = ChatBox_TimeStamp_Commands; |
||
478 | SLASH_TIMESTAMP1 = "/timestamp"; |
||
479 | SLASH_TIMESTAMP2 = "/ts"; |
||
480 | |||
481 | -- Enable slash commands |
||
482 | SlashCmdList["PLM"] = ChatBox_PLM_Commands; |
||
483 | SLASH_PLM1 = "/playerlinkmenu"; |
||
484 | SLASH_PLM2 = "/plm"; |
||
485 | |||
486 | |||
487 | --telltarget (for those who want it..) |
||
488 | SlashCmdList["TELLTARGET"] = ChatBox_TT_Commands; |
||
489 | SLASH_TELLTARGET1 = "/telltarget"; |
||
490 | SLASH_TELLTARGET2 = "/tellt"; |
||
491 | SLASH_TELLTARGET3 = "/tt"; |
||
492 | |||
493 | --clear all the chatframe boxes |
||
494 | SlashCmdList["CLEARCHATCOMMAND"] = ChatBox_ClearChat_SlashCommands; |
||
495 | SLASH_CLEARCHATCOMMAND1 = "/clearChat"; |
||
496 | SLASH_CLEARCHATCOMMAND2 = "/clear"; |
||
497 | SLASH_CLEARCHATCOMMAND3 = "/clr"; |
||
498 | end |
||
499 | end |
||
500 | |||
501 | |||
502 | ---------------------------------------------------------------------------------------------------- |
||
503 | -- ChatBox ClearChat Slash Commands |
||
504 | ---------------------------------------------------------------------------------------------------- |
||
505 | function ChatBox_ClearChat_SlashCommands(msg) |
||
506 | local command = string.lower(msg); |
||
507 | if (string.lower(msg) == "" ) then |
||
508 | local chatFrame; |
||
509 | for i = 1, 7 do |
||
510 | chatFrame = getglobal("ChatFrame"..i); |
||
511 | if( (chatFrame ~= nil) and chatFrame:IsVisible() ) then |
||
512 | chatFrame:Clear(); |
||
513 | end |
||
514 | end |
||
515 | end |
||
516 | end |
||
517 | |||
518 | ---------------------------------------------------------------------------------------------------- |
||
519 | -- TellTarget |
||
520 | ---------------------------------------------------------------------------------------------------- |
||
521 | |||
522 | -- Handles a slash command |
||
523 | function ChatBox_TT_Commands(msg) |
||
524 | local target = UnitName('target'); |
||
525 | if target == nil then |
||
526 | msg = "You need to have someone targeted!"; |
||
527 | target = UnitName("player"); |
||
528 | end |
||
529 | SendChatMessage(msg, "WHISPER", this.language, target) |
||
530 | end |
||
531 | |||
532 | ---------------------------------------------------------------------------------------------------- |
||
533 | -- Misc functions |
||
534 | ---------------------------------------------------------------------------------------------------- |
||
535 | |||
536 | function ChatBox_specialSendWho(name) |
||
537 | SendWho("n-"..name) |
||
538 | end |
||
539 | |||
540 | function ChatBox_check(state) |
||
541 | if state then |
||
542 | if state == true then |
||
543 | return CB_ON |
||
544 | else |
||
545 | return tostring(state) |
||
546 | end |
||
547 | else |
||
548 | return CB_OFF |
||
549 | end |
||
550 | end |
||
551 | |||
552 | function ChatBox_check_color() |
||
553 | if ( ChatBox.TimeStamp_Settings.color ) then |
||
554 | --TODO double check. |
||
555 | return "|cff" .. string.lower(ChatBox.TimeStamp_Settings.color) .. CB_TS_COLOR .. "|r"; |
||
556 | else |
||
557 | return RED .. CB_OFF |
||
558 | end |
||
559 | end |
||
560 | |||
561 | |||
562 | function cb_display(output) |
||
563 | local anyoutput = false; |
||
564 | |||
565 | -- IF the output ends without a carriage return but has some in it, the entire message will not display |
||
566 | for msg in string.gfind(output,"(.+)\n") do |
||
567 | if (msg~=nil) then |
||
568 | anyoutput = true; |
||
569 | end |
||
570 | DEFAULT_CHAT_FRAME:AddMessage(msg); |
||
571 | end |
||
572 | |||
573 | -- This basically means that there were no carriage returns |
||
574 | if (not anyoutput) then |
||
575 | DEFAULT_CHAT_FRAME:AddMessage(output); |
||
576 | end |
||
577 | end |
||
578 | |||
579 | function ChatBox_SetSticky() |
||
580 | --Extends the "default to last channel" <Enter> keypress to include numbered and (possible) whisper channels. |
||
581 | if ChatBox.setSticky then |
||
582 | --ChatTypeInfo["WHISPER"].sticky = 1; |
||
583 | ChatTypeInfo["CHANNEL"].sticky = 1; |
||
584 | ChatTypeInfo["OFFICER"].sticky = 1; |
||
585 | else |
||
586 | --ChatTypeInfo["WHISPER"].sticky = 0; |
||
587 | ChatTypeInfo["CHANNEL"].sticky = 0; |
||
588 | ChatTypeInfo["OFFICER"].sticky = 0; |
||
589 | end |
||
590 | end |
||
591 | |||
592 | function ChatBox_SetStrings() |
||
593 | ---- Changing current global strings to more suitable ones ---- |
||
594 | CHAT_FLAG_AFK = "[AFK] "; |
||
595 | CHAT_FLAG_DND = "[DND] "; |
||
596 | CHAT_FLAG_GM = "[GM] "; |
||
597 | CHAT_WHISPER_GET = "From %s:\32"; -- Whisper from player %s |
||
598 | CHAT_WHISPER_INFORM_GET = "To %s:\32"; -- A whisper already sent to player %s |
||
599 | |||
600 | if ChatBox.longStrings then |
||
601 | CHAT_GUILD_GET = "[Guild] %s:\32"; -- Guild message from player %s |
||
602 | CHAT_RAID_GET = "[Raid] %s:\32"; -- Raid message from player %s |
||
603 | CHAT_PARTY_GET = "[Party] %s:\32"; -- Party message from player %s |
||
604 | CHAT_OFFICER_GET = "[Officer] %s:\32"; -- Officer message from player %s |
||
605 | elseif ChatBox.shortStrings then |
||
606 | CHAT_GUILD_GET = "[G] %s:\32"; -- Guild message from player %s |
||
607 | CHAT_RAID_GET = "[R] %s:\32"; -- Raid message from player %s |
||
608 | CHAT_PARTY_GET = "[P] %s:\32"; -- Party message from player %s |
||
609 | CHAT_OFFICER_GET = "[O] %s:\32"; -- Officer message from player %s |
||
610 | else |
||
611 | CHAT_GUILD_GET = "%s:\32"; -- Guild message from player %s |
||
612 | CHAT_RAID_GET = "%s:\32"; -- Raid message from player %s |
||
613 | CHAT_PARTY_GET = "%s:\32"; -- Party message from player %s |
||
614 | CHAT_OFFICER_GET = "%s:\32"; -- Officer message from player %s |
||
615 | end |
||
616 | end |
||
617 | |||
618 | function SetupPLM() |
||
619 | |||
620 | --NOTE: I should be insterting, removing these from the tables instead.... so it will work with OTHER mods, and be friendly! |
||
621 | if ChatBox.plm then |
||
622 | UnitPopupMenus["PARTY"] = {"WHO", "WHISPER", "TARGET", "PROMOTE", "LOOT_PROMOTE", "UNINVITE", "INSPECT", "TRADE", "FOLLOW", "DUEL", "ADDFRIEND", "REMOVEFRIEND", "CANCEL" }; |
||
623 | UnitPopupMenus["PLAYER"] = {"WHO", "WHISPER", "INSPECT", "INVITE", "TARGET", "IGNORE", "UNIGNORE", "TRADE", "FOLLOW", "DUEL", "ADDFRIEND", "REMOVEFRIEND", "CANCEL" }; |
||
624 | UnitPopupMenus["RAID"] = { "RAID_LEADER", "RAID_PROMOTE", "RAID_DEMOTE", "RAID_REMOVE", "CANCEL" }; |
||
625 | UnitPopupMenus["FRIEND"] = { "WHO", "WHISPER", "INVITE", "TARGET", "IGNORE", "UNIGNORE", "GUILD_PROMOTE", "GUILD_LEAVE", "ADDFRIEND", "REMOVEFRIEND", "CANCEL" }; |
||
626 | else |
||
627 | UnitPopupMenus["PARTY"] = { "WHISPER", "PROMOTE", "LOOT_PROMOTE", "UNINVITE", "INSPECT", "TRADE", "FOLLOW", "DUEL", "CANCEL" }; |
||
628 | UnitPopupMenus["PLAYER"] = { "WHISPER", "INSPECT", "INVITE", "TRADE", "FOLLOW", "DUEL", "CANCEL" }; |
||
629 | UnitPopupMenus["RAID"] = { "RAID_LEADER", "RAID_PROMOTE", "RAID_DEMOTE", "RAID_REMOVE", "CANCEL" }; |
||
630 | UnitPopupMenus["FRIEND"] = { "WHISPER", "INVITE", "GUILD_PROMOTE", "GUILD_LEAVE", "CANCEL" }; |
||
631 | end |
||
632 | |||
633 | --Re-Set up alt key functionality |
||
634 | if ( ChatBox.plm_alt_name == WHO ) then |
||
635 | ChatBox.plm_alt = ChatBox_specialSendWho; |
||
636 | elseif ( ChatBox.plm_alt_name == CB_TARGET) then |
||
637 | ChatBox.plm_alt = TargetByName; |
||
638 | elseif ( ChatBox.plm_alt_name == WHISPER ) then |
||
639 | ChatBox.plm_alt = ChatFrame_SendTell; |
||
640 | elseif ( ChatBox.plm_alt_name == PARTY_INVITE ) then |
||
641 | ChatBox.plm_alt = InviteByName; |
||
642 | elseif ( ChatBox.plm_alt_name == IGNORE ) then |
||
643 | ChatBox.plm_alt = AddIgnore; |
||
644 | end |
||
645 | |||
646 | |||
647 | --Re-Set up the shift key functionality |
||
648 | if ( ChatBox.plm_shift_name == WHO ) then |
||
649 | ChatBox.plm_shift = ChatBox_specialSendWho; |
||
650 | elseif ( ChatBox.plm_shift_name == CB_TARGET ) then |
||
651 | ChatBox.plm_shift = TargetByName; |
||
652 | elseif ( ChatBox.plm_shift_name == WHISPER ) then |
||
653 | ChatBox.plm_shift = ChatFrame_SendTell; |
||
654 | elseif ( ChatBox.plm_shift_name == PARTY_INVITE ) then |
||
655 | ChatBox.plm_shift = InviteByName; |
||
656 | elseif ( ChatBox.plm_shift_name == IGNORE ) then |
||
657 | ChatBox.plm_shift = AddIgnore; |
||
658 | end |
||
659 | |||
660 | --Re-Set up change the control key functionality |
||
661 | if ( ChatBox.plm_ctrl_name == WHO ) then |
||
662 | ChatBox.plm_ctrl = ChatBox_specialSendWho; |
||
663 | elseif ( ChatBox.plm_ctrl_name == CB_TARGET ) then |
||
664 | ChatBox.plm_ctrl = TargetByName; |
||
665 | elseif ( ChatBox.plm_ctrl_name == WHISPER ) then |
||
666 | ChatBox.plm_ctrl = ChatFrame_SendTell; |
||
667 | elseif ( ChatBox.plm_ctrl_name == PARTY_INVITE ) then |
||
668 | ChatBox.plm_ctrl = InviteByName; |
||
669 | elseif ( ChatBox.plm_ctrl_name == IGNORE ) then |
||
670 | ChatBox.plm_ctrl = AddIgnore; |
||
671 | end |
||
672 | end |
||
673 | |||
674 | |||
675 | function ChatBox_HashString(name) |
||
676 | local hash = 17; |
||
677 | for i = 1, string.len(name) do |
||
678 | hash = hash * 37 * string.byte(name, i); |
||
679 | end |
||
680 | return hash; |
||
681 | end |
||
682 | |||
683 | ---------------------------------------------------------------------------------------------------- |
||
684 | -- ChatBox_AddMessage (for timestamp and shortening the channel name) |
||
685 | ---------------------------------------------------------------------------------------------------- |
||
686 | function ChatBox_AddMessage(this, msg, r, g, b, id) |
||
687 | |||
688 | if (not msg) then |
||
689 | return; |
||
690 | end |
||
691 | |||
692 | --remove chuck norris spam. It's annoying as hell. |
||
693 | if (msg ~= nil and ChatBox.chuckNorris) then |
||
694 | if string.find(string.lower(msg), "%s*chu?c?k?%s*nor?r?i?s?") and not (string.find(msg, CB_NORRIS_HELP_TEXT) or string.find(msg, CB_NORRIS_TEXT)) then |
||
695 | if ChatBox.chuckNorris == CB_VERBOSE then |
||
696 | msg = DRKBLU .. "[Something stupid about Chuck Norris]"; |
||
697 | else |
||
698 | return; |
||
699 | end |
||
700 | end |
||
701 | end |
||
702 | |||
703 | -- URL detection (from SCCN) |
||
704 | if (msg ~= nil) then |
||
705 | local urlFound = nil; |
||
706 | |||
707 | local function GetURL(before, URL, after) |
||
708 | urlFound = true; |
||
709 | return before .. YEL .. "|Href:" .. URL .. "|h[".. URL .."]|h|r" .. after; |
||
710 | end |
||
711 | |||
712 | -- numeric IP's 123.123.123.123:12345 |
||
713 | if ( not urlFound ) then |
||
714 | msg = string.gsub(msg, "(%s?)(%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?:%d%d?%d?%d?%d?)(%s?)", GetURL); |
||
715 | end; |
||
716 | -- numeric IP's 123.123.123.123 |
||
717 | if ( not urlFound ) then |
||
718 | msg = string.gsub(msg, "(%s?)(%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?)(%s?)", GetURL); |
||
719 | end; |
||
720 | -- TeamSpeak like IP's sub.domain.org:12345 or domain.com:123 |
||
721 | if ( not urlFound ) then |
||
722 | msg = string.gsub(msg, "(%s?)([%w_-]+%.?[%w_-]+%.[%w_-]+:%d%d%d?%d?%d?)(%s?)", GetURL); |
||
723 | end; |
||
724 | -- complete http urls |
||
725 | if ( not urlFound ) then |
||
726 | msg = string.gsub(msg, "(%s?)(%a+://[%w_/%.%?%%=~&-]+)(%s?)", GetURL); |
||
727 | end; |
||
728 | -- www.URL.com |
||
729 | if ( not urlFound ) then |
||
730 | msg = string.gsub(msg, "(%s?)(www%.[%w_/%.%?%%=~&-]+)(%s?)", GetURL); |
||
731 | end; |
||
732 | -- test@test.com |
||
733 | if ( not urlFound ) then |
||
734 | msg = string.gsub(msg, "(%s?)([_%w-%.~-]+@[_%w-]+%.[_%w-%.]+)(%s?)", GetURL); |
||
735 | end; |
||
736 | end |
||
737 | |||
738 | -- Change LookingForGroup channel name to LFG |
||
739 | if ChatBox.shortLFG then |
||
740 | if (msg) then |
||
741 | msg = string.gsub(msg, CB_LOOKINGFORGROUPCOMM, CB_SHORTLFGCOMM); |
||
742 | end |
||
743 | end |
||
744 | |||
745 | --truncate channel names over 8 chars |
||
746 | if ChatBox.truncLength and ChatBox.truncLength < 21 then |
||
747 | if (msg ~= nil) then |
||
748 | msg = string.gsub(msg, "%b[]", |
||
749 | function(s) |
||
750 | if string.find(s, "^%[%d") then |
||
751 | s = string.gsub(s, "%a+", |
||
752 | function (s) |
||
753 | return string.sub(s, 1, ChatBox.truncLength) |
||
754 | end) |
||
755 | return s |
||
756 | else |
||
757 | return s; |
||
758 | end |
||
759 | end, 1 ) |
||
760 | end |
||
761 | end |
||
762 | |||
763 | -- Translate CLINKs back into normal links on incoming messages. (from...CLINK!) |
||
764 | if (ChatBox.CLINK and msg ~= nil) then |
||
765 | msg = ChatBox_Decompose (msg) |
||
766 | end |
||
767 | |||
768 | --do the name coloring thing here! (sorta my own thing..) |
||
769 | if (msg ~= nil and (this and getglobal(this:GetName() .. "TabText") and not string.find(getglobal(this:GetName() .. "TabText"):GetText(), "Combat")) and ( ChatBox.colorNames or ChatBox.colorRandom) ) then |
||
770 | local _, _, _, name, _, type = string.find(msg, "(|Hplayer:.-|h%[)(%a+)(%])(.*:%s)"); |
||
771 | |||
772 | if name and not string.find(name, "%s") and |
||
773 | (type and not (string.find(type, CB_SAY) or string.find(type, CB_YELL)) ) then |
||
774 | msg = string.gsub(msg, "(|Hplayer:.-|h%[)([%w]+)(%])", "%1" .. ChatBox_SetNameColor(nil, name) .. "%2|r%3"); |
||
775 | end |
||
776 | end |
||
777 | |||
778 | -- Add the ChatBox_TimeStamp (TimeStamp stuff taken from TimeStamp!) |
||
779 | if ( ChatBox.TimeStamp_Settings.frames[this:GetName()] == CB_ON ) then |
||
780 | |||
781 | -- Generate the timestamp |
||
782 | local stamp = date(ChatBox.TimeStamp_Settings.format); |
||
783 | |||
784 | if (ChatBox.TimeStamp_Settings.color) then |
||
785 | -- The timestamp should be colored |
||
786 | msg = "|cff" .. string.lower(ChatBox.TimeStamp_Settings.color) .. stamp .. END .. msg; |
||
787 | else |
||
788 | -- The timestamp should use the same color as the message |
||
789 | msg = stamp .. " " .. msg; |
||
790 | end |
||
791 | end |
||
792 | |||
793 | this:Original_AddMessage(msg, r, g, b, id); --call the real AddMessage function |
||
794 | end |
||
795 | |||
796 | |||
797 | |||
798 | ---------------------------------------------------------------------------------------------------- |
||
799 | -- ChatBox Tell Target (from TellTrack) |
||
800 | ---------------------------------------------------------------------------------------------------- |
||
801 | function ChatBox_TargetTell(name) |
||
802 | if name then |
||
803 | ChatFrame_SendTell(name); |
||
804 | end |
||
805 | end |
||
806 | |||
807 | |||
808 | ---------------------------------------------------------------------------------------------------- |
||
809 | -- Player Link Menu Woot! TONS smaller (only 4k) than every OTHER ONE OUT THERE!! more efficient too! |
||
810 | ---------------------------------------------------------------------------------------------------- |
||
811 | |||
812 | function ChatBox_UnitPopup_HideButtons() |
||
813 | CB_Orig_UnitPopup_HideButtons(); |
||
814 | |||
815 | local dropdownMenu = getglobal(UIDROPDOWNMENU_INIT_MENU); |
||
816 | |||
817 | for index, value in UnitPopupMenus[dropdownMenu.which] do |
||
818 | |||
819 | if ( value == "WHO" or value == "TARGET" ) then |
||
820 | if ( dropdownMenu.name == UnitName("player") ) then |
||
821 | UnitPopupShown[index] = 0; |
||
822 | else |
||
823 | UnitPopupShown[index] = 1; |
||
824 | end |
||
825 | elseif ( value == "IGNORE" ) then |
||
826 | --kinda backasswards, but it works. |
||
827 | if ( dropdownMenu.name == UnitName("player") or ChatBox_isOnIgnoreList(dropdownMenu.name) ) then |
||
828 | UnitPopupShown[index] = 0; |
||
829 | else |
||
830 | UnitPopupShown[index] = 1; |
||
831 | end |
||
832 | elseif ( value == "UNIGNORE" ) then |
||
833 | if ( dropdownMenu.name == UnitName("player") or not ChatBox_isOnIgnoreList(dropdownMenu.name) ) then |
||
834 | UnitPopupShown[index] = 0; |
||
835 | else |
||
836 | UnitPopupShown[index] = 1; |
||
837 | end |
||
838 | elseif ( value == "ADDFRIEND" ) then |
||
839 | if ( dropdownMenu.name == UnitName("player") or ChatBox_isPlayerFriend(dropdownMenu.name) ) then |
||
840 | UnitPopupShown[index] = 0; |
||
841 | else |
||
842 | UnitPopupShown[index] = 1; |
||
843 | end |
||
844 | elseif ( value == "REMOVEFRIEND" ) then |
||
845 | if ( dropdownMenu.name == UnitName("player") or not ChatBox_isPlayerFriend(dropdownMenu.name) ) then |
||
846 | UnitPopupShown[index] = 0; |
||
847 | else |
||
848 | UnitPopupShown[index] = 1; |
||
849 | end |
||
850 | end |
||
851 | end |
||
852 | end |
||
853 | |||
854 | function ChatBox_UnitPopup_OnClick() |
||
855 | local index = this.value; |
||
856 | local dropdownFrame = getglobal(UIDROPDOWNMENU_INIT_MENU); |
||
857 | local button = UnitPopupMenus[this.owner][index]; |
||
858 | local unit = dropdownFrame.unit; |
||
859 | local name = dropdownFrame.name; |
||
860 | local notFound = false; |
||
861 | |||
862 | if ( button == "WHO" ) then |
||
863 | SendWho("n-"..name); |
||
864 | elseif ( button == "TARGET" ) then |
||
865 | TargetByName(name); |
||
866 | elseif ( button == "IGNORE" ) then |
||
867 | AddIgnore(name); |
||
868 | elseif ( button == "UNIGNORE" ) then |
||
869 | DelIgnore(name); |
||
870 | elseif ( button == "ADDFRIEND" ) then |
||
871 | AddFriend(name); |
||
872 | elseif ( button == "REMOVEFRIEND" ) then |
||
873 | RemoveFriend(name); |
||
874 | else |
||
875 | notFound = true; |
||
876 | end |
||
877 | |||
878 | if notFound then |
||
879 | CB_Orig_UnitPopup_OnClick(); |
||
880 | else |
||
881 | PlaySound("UChatScrollButton"); |
||
882 | end |
||
883 | end |
||
884 | |||
885 | function ChatBox_isOnIgnoreList(checkname) |
||
886 | local ignores = GetNumIgnores(); |
||
887 | |||
888 | for i=1, ignores do |
||
889 | local name = GetIgnoreName(i); |
||
890 | if(name == checkname) then |
||
891 | return true; |
||
892 | end |
||
893 | end |
||
894 | |||
895 | return false; |
||
896 | end |
||
897 | |||
898 | function ChatBox_isPlayerFriend(checkname) |
||
899 | local friends = GetNumFriends(); |
||
900 | for i=1, friends do |
||
901 | local name, level, class, area, connected = GetFriendInfo(i); |
||
902 | if(name == checkname) then |
||
903 | return true; |
||
904 | end |
||
905 | end |
||
906 | |||
907 | return false; |
||
908 | end |
||
909 | |||
910 | |||
911 | ---------------------------------------------------------------------------------------------------- |
||
912 | -- AutoSelect |
||
913 | ---------------------------------------------------------------------------------------------------- |
||
914 | |||
915 | function ChatBox_Gossip() |
||
916 | if( event == "GOSSIP_SHOW" and ChatBox.hideGossip and not IsControlKeyDown() and not GetGossipAvailableQuests() and not GetGossipActiveQuests() ) then |
||
917 | if(ChatBox_Gossip_Action()) then |
||
918 | return; |
||
919 | end |
||
920 | end |
||
921 | CB_Orig_GossipFrame_OnEvent(); |
||
922 | end |
||
923 | |||
924 | function ChatBox_Gossip_Action() |
||
925 | local list = {GetGossipOptions()}; |
||
926 | for i = 2,getn(list),2 do |
||
927 | if(ChatBox_actions[list[i]]) then |
||
928 | SelectGossipOption(i/2); |
||
929 | return true; |
||
930 | end |
||
931 | end |
||
932 | end |
||
933 | |||
934 | ---------------------------------------------------------------------------------------------------- |
||
935 | -- Custom Set ItemRef. |
||
936 | ---------------------------------------------------------------------------------------------------- |
||
937 | |||
938 | -- called on hyperlink enter |
||
939 | function ChatBox_OnHyperlinkEnter() |
||
940 | if (CB_Orig_OnHyperlinkEnter_Table and CB_Orig_OnHyperlinkEnter_Table[this:GetName()]) then |
||
941 | CB_Orig_OnHyperlinkEnter_Table[this:GetName()](); |
||
942 | end |
||
943 | |||
944 | local link = arg1; |
||
945 | local text = arg2; |
||
946 | local button = arg3; |
||
947 | |||
948 | if not (IsShiftKeyDown() or IsControlKeyDown() or IsAltKeyDown()) then |
||
949 | return; |
||
950 | end |
||
951 | |||
952 | if ( string.find(link, itemlinkformat) ) then |
||
953 | ShowUIPanel(GameTooltip); |
||
954 | GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR"); |
||
955 | GameTooltip:SetHyperlink(link); |
||
956 | elseif string.find(link, speciallinkformat) then |
||
957 | for name, msg in string.gfind( link, speciallinkformat ) do |
||
958 | ChatBox_lastName = name; |
||
959 | |||
960 | ShowUIPanel(GameTooltip); |
||
961 | |||
962 | GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR"); |
||
963 | |||
964 | GameTooltip:ClearLines(); |
||
965 | |||
966 | if (not IsControlKeyDown() ) then |
||
967 | msg = formatText(msg) |
||
968 | end |
||
969 | |||
970 | GameTooltip:AddLine( " ", 0.5, 0.5, 1 ); |
||
971 | GameTooltip:AddLine( name ); |
||
972 | GameTooltip:AddLine( msg, 1, 1, 1, 1, 1 ); |
||
973 | |||
974 | GameTooltip:Show(); |
||
975 | end |
||
976 | elseif string.find(link, portallinkformat) then |
||
977 | for name, msg in string.gfind( link, portallinkformat ) do |
||
978 | ChatBox_lastName = name; |
||
979 | |||
980 | ShowUIPanel(GameTooltip); |
||
981 | |||
982 | GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR"); |
||
983 | |||
984 | GameTooltip:ClearLines(); |
||
985 | |||
986 | GameTooltip:AddLine( " ", 0.5, 0.5, 1 ); |
||
987 | GameTooltip:AddLine( name ); |
||
988 | GameTooltip:AddLine( msg, 1, 1, 1, 1, 1 ); |
||
989 | |||
990 | GameTooltip:Show(); |
||
991 | end |
||
992 | end |
||
993 | end |
||
994 | |||
995 | |||
996 | -- called on hyperlink leave |
||
997 | function ChatBox_OnHyperlinkHide() |
||
998 | if (CB_Orig_OnHyperlinkLeave_Table[this:GetName()]) then |
||
999 | CB_Orig_OnHyperlinkLeave_Table[this:GetName()](); |
||
1000 | end |
||
1001 | |||
1002 | HideUIPanel(GameTooltip); |
||
1003 | end |
||
1004 | |||
1005 | |||
1006 | function ChatBox_SetItemRef(link, text, button) |
||
1007 | |||
1008 | if ( IsControlKeyDown() and string.find(link, itemlinkformat) ) then |
||
1009 | DressUpItemLink(text); |
||
1010 | return; |
||
1011 | elseif ( IsShiftKeyDown() and ChatFrameEditBox:IsVisible() and string.find(link, itemlinkformat) ) then |
||
1012 | ChatFrameEditBox:Insert(text); |
||
1013 | return; |
||
1014 | elseif ( IsShiftKeyDown() and MacroFrameText and MacroFrameText:IsVisible() and string.find(link, itemlinkformat) ) then |
||
1015 | MacroFrameText:Insert(text); |
||
1016 | return; |
||
1017 | end |
||
1018 | |||
1019 | if ( string.find(link, playerlinkformat) ) then |
||
1020 | local name = strsub(link, 8); |
||
1021 | if ( name and (strlen(name) > 0) ) then |
||
1022 | name = gsub(name, "([^%s]*)%s+([^%s]*)%s+([^%s]*)", "%3"); |
||
1023 | name = gsub(name, "([^%s]*)%s+([^%s]*)", "%2"); |
||
1024 | |||
1025 | if ( button == "RightButton" ) then |
||
1026 | FriendsFrame_ShowDropdown(name, 1); |
||
1027 | return; |
||
1028 | end |
||
1029 | if ( IsShiftKeyDown() ) then |
||
1030 | -- execute a function action |
||
1031 | if type(ChatBox.plm_shift) == 'function' then |
||
1032 | ChatBox.plm_shift(name); |
||
1033 | return; |
||
1034 | end |
||
1035 | |||
1036 | elseif ( IsControlKeyDown() )then |
||
1037 | -- execute a function action |
||
1038 | if type(ChatBox.plm_ctrl) == 'function' then |
||
1039 | ChatBox.plm_ctrl(name); |
||
1040 | return; |
||
1041 | end |
||
1042 | |||
1043 | elseif ( IsAltKeyDown() ) then |
||
1044 | -- execute a function action |
||
1045 | if type(ChatBox.plm_alt) == 'function' then |
||
1046 | ChatBox.plm_alt(name); |
||
1047 | return; |
||
1048 | end |
||
1049 | |||
1050 | else |
||
1051 | ChatFrame_SendTell(name); |
||
1052 | return; |
||
1053 | end |
||
1054 | end |
||
1055 | return; |
||
1056 | end |
||
1057 | |||
1058 | --this is to setup the urlCopy functionality. |
||
1059 | for url in string.gfind( text, hyperlinkformat ) do |
||
1060 | getglobal( "ChatBoxHyperlinkerFormEditBox" ):SetText( url ); |
||
1061 | ChatBoxHyperlinkerForm:Show(); |
||
1062 | return; |
||
1063 | end |
||
1064 | |||
1065 | --this is to setup the enchanter spam link... |
||
1066 | for name, msg in string.gfind( link, speciallinkformat ) do |
||
1067 | if( ItemRefTooltip:IsVisible() and ChatBox_lastName and ChatBox_lastName == name ) then |
||
1068 | |||
1069 | HideUIPanel(ItemRefTooltip); |
||
1070 | ChatBox_lastName = nil; |
||
1071 | |||
1072 | else |
||
1073 | ChatBox_lastName = name; |
||
1074 | |||
1075 | ShowUIPanel(ItemRefTooltip); |
||
1076 | if ( not ItemRefTooltip:IsVisible() ) then |
||
1077 | ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE"); |
||
1078 | end |
||
1079 | |||
1080 | ItemRefTooltip:ClearLines(); |
||
1081 | |||
1082 | if (not IsControlKeyDown() ) then |
||
1083 | msg = formatText(msg) |
||
1084 | end |
||
1085 | |||
1086 | ItemRefTooltip:AddLine( " ", 0.5, 0.5, 1 ); |
||
1087 | ItemRefTooltip:AddLine( name ); |
||
1088 | ItemRefTooltip:AddLine( msg, 1, 1, 1, 1, 1 ); |
||
1089 | |||
1090 | ItemRefTooltip:Show(); |
||
1091 | end |
||
1092 | return |
||
1093 | end |
||
1094 | |||
1095 | --this is to setup the guild spam link... |
||
1096 | for name, msg in string.gfind( link, guildlinkformat ) do |
||
1097 | if( ItemRefTooltip:IsVisible() and ChatBox_lastName and ChatBox_lastName == name ) then |
||
1098 | |||
1099 | HideUIPanel(ItemRefTooltip); |
||
1100 | ChatBox_lastName = nil; |
||
1101 | |||
1102 | else |
||
1103 | ChatBox_lastName = name; |
||
1104 | |||
1105 | ShowUIPanel(ItemRefTooltip); |
||
1106 | if ( not ItemRefTooltip:IsVisible() ) then |
||
1107 | ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE"); |
||
1108 | end |
||
1109 | |||
1110 | ItemRefTooltip:ClearLines(); |
||
1111 | |||
1112 | ItemRefTooltip:AddLine( " ", 0.5, 0.5, 1 ); |
||
1113 | ItemRefTooltip:AddLine( name ); |
||
1114 | ItemRefTooltip:AddLine( msg, 1, 1, 1, 1, 1 ); |
||
1115 | |||
1116 | ItemRefTooltip:Show(); |
||
1117 | end |
||
1118 | return |
||
1119 | end |
||
1120 | |||
1121 | --this is to special links (portals, xmutes, etc...) |
||
1122 | for name, msg in string.gfind( link, portallinkformat ) do |
||
1123 | if( ItemRefTooltip:IsVisible() and ChatBox_lastName and ChatBox_lastName == name ) then |
||
1124 | |||
1125 | HideUIPanel(ItemRefTooltip); |
||
1126 | ChatBox_lastName = nil; |
||
1127 | |||
1128 | else |
||
1129 | ChatBox_lastName = name; |
||
1130 | |||
1131 | ShowUIPanel(ItemRefTooltip); |
||
1132 | if ( not ItemRefTooltip:IsVisible() ) then |
||
1133 | ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE"); |
||
1134 | end |
||
1135 | |||
1136 | ItemRefTooltip:ClearLines(); |
||
1137 | |||
1138 | ItemRefTooltip:AddLine( " ", 0.5, 0.5, 1 ); |
||
1139 | ItemRefTooltip:AddLine( name ); |
||
1140 | ItemRefTooltip:AddLine( msg, 1, 1, 1, 1, 1 ); |
||
1141 | |||
1142 | ItemRefTooltip:Show(); |
||
1143 | end |
||
1144 | return |
||
1145 | end |
||
1146 | |||
1147 | ChatBox_lastName = nil; |
||
1148 | --this still around for legacy reasons (other mods might also have hooks in this...) |
||
1149 | CB_Orig_SetItemRef(link, text, button); |
||
1150 | end |
||
1151 | |||
1152 | |||
1153 | function ChatBox_ChatFrame_OnEvent() |
||
1154 | |||
1155 | --does the whole name color thing. |
||
1156 | if ( ChatBox.colorNames and strsub(event, 1, 8) == "CHAT_MSG" and arg2) then |
||
1157 | ChatBox_SetNameColor(event, arg2); |
||
1158 | end |
||
1159 | |||
1160 | --saves who I talked to last (for tell target) |
||
1161 | if ( event == "CHAT_MSG_WHISPER_INFORM" ) then |
||
1162 | ChatBox_LastTell = arg2; |
||
1163 | end |
||
1164 | |||
1165 | |||
1166 | --hook this function, so I can disable the flashing of tabs? |
||
1167 | -- FCF_FlashTab(); |
||
1168 | |||
1169 | |||
1170 | --if we haven't already done so, hook the AddMessage function |
||
1171 | if(not this.Original_AddMessage) then |
||
1172 | this.Original_AddMessage = this.AddMessage; |
||
1173 | this.AddMessage = ChatBox_AddMessage; |
||
1174 | end |
||
1175 | |||
1176 | if ( (event == "CHAT_MSG_CHANNEL") or (event == "CHAT_MSG_SAY") or (event == "CHAT_MSG_YELL") and not (string.find(arg9, "LookingForGroup") or string.find(arg9, "Defense")) ) then |
||
1177 | --this is an ENCHANT... (from Enchanter Ad Shrinker by sacha) |
||
1178 | --need to have a check if there are any other links in the msg. it will screw up if there are. |
||
1179 | if ( ChatBox_IsEnch(arg1) ) then |
||
1180 | arg1 = string.gsub(arg1, "|", "") |
||
1181 | |||
1182 | arg1 = string.format(linkstring, BLU, arg2, arg1, CB_SPAM_ENCHANTMENTS) |
||
1183 | |||
1184 | if ((string.find(string.lower(arg1), CB_SPAM_WTS)) or (string.find(string.lower(arg1), CB_SPAM_ENCHANTING))) then |
||
1185 | arg1 = string.upper(CB_SPAM_WTS).." "..arg1 |
||
1186 | elseif ((string.find(string.lower(arg1), CB_SPAM_WTB)) or (string.find(string.lower(arg1), CB_SPAM_BUY)) or (string.find(string.lower(arg1), CB_SPAM_LOOKINGFOR))) then |
||
1187 | arg1 = string.upper(CB_SPAM_WTB).." "..arg1 |
||
1188 | end |
||
1189 | --is this GUILD spam??? |
||
1190 | --if there are item links in the text, it messes up. |
||
1191 | elseif ( ChatBox_IsGuild(arg1) ) then |
||
1192 | arg1 = string.format(guildstring, ORN, arg2, arg1, CB_SPAM_GUILD) |
||
1193 | else |
||
1194 | --lets color certain combination of words. (portals, lockpicks, etc...) |
||
1195 | for color,wordset in colorsubs do |
||
1196 | for word,sub in wordset do |
||
1197 | local a, b = string.find(string.lower(arg1), string.lower(word)); |
||
1198 | if (a and b) then |
||
1199 | local _, _, _, a1 = string.find(arg1, "xhenc:(.+)<XH>(.+)"); |
||
1200 | if (not a1) then |
||
1201 | a1 = string.gsub(arg1, itemcapstr, "[%1]"); |
||
1202 | a1 = string.gsub(a1, "|", "") |
||
1203 | arg1 = string.sub(arg1, 1, a-1).. string.format(linkstring2, color, arg2, a1, sub).. string.sub(arg1, b+1); |
||
1204 | end |
||
1205 | end |
||
1206 | end |
||
1207 | end |
||
1208 | end |
||
1209 | end |
||
1210 | |||
1211 | CB_Orig_ChatFrame_OnEvent(event) |
||
1212 | end |
||
1213 | |||
1214 | |||
1215 | function ChatBox_IsEnch(str) |
||
1216 | |||
1217 | if string.find(str, itemlinkformat) then |
||
1218 | return false; |
||
1219 | end |
||
1220 | |||
1221 | local totalFound = 0 |
||
1222 | local numFound = 0 |
||
1223 | local text = string.lower(str) |
||
1224 | |||
1225 | -- text = string.gsub(text, "|hitem:%d+:%d+:%d+:%d+|h[[][^]]+[]]|h", "") |
||
1226 | for key1,val1 in ChatBoxWords do |
||
1227 | for key2,val2 in val1 do |
||
1228 | if (string.find(text, val2)) then |
||
1229 | text, numFound = string.gsub(text, val2, " ") |
||
1230 | totalFound = totalFound + numFound |
||
1231 | end |
||
1232 | end |
||
1233 | end |
||
1234 | |||
1235 | if ChatBox.throttle and totalFound >= ChatBox.throttle then |
||
1236 | return true |
||
1237 | else |
||
1238 | return false |
||
1239 | end |
||
1240 | end |
||
1241 | |||
1242 | function ChatBox_IsGuild(str) |
||
1243 | |||
1244 | if string.find(str, itemlinkformat) then |
||
1245 | return false; |
||
1246 | end |
||
1247 | |||
1248 | local totalFound = 0 |
||
1249 | local numFound = 0 |
||
1250 | local text = string.lower(str) |
||
1251 | |||
1252 | -- text = string.gsub(text, "|hitem:%d+:%d+:%d+:%d+|h[[][^]]+[]]|h", "") |
||
1253 | for key1,val1 in ChatBoxGuildWords do |
||
1254 | if (string.find(text, val1)) then |
||
1255 | text, numFound = string.gsub(text, val1, " ") |
||
1256 | totalFound = totalFound + numFound |
||
1257 | end |
||
1258 | end |
||
1259 | |||
1260 | if ChatBox.gthrottle and totalFound >= ChatBox.gthrottle then |
||
1261 | return true; |
||
1262 | else |
||
1263 | return false; |
||
1264 | end |
||
1265 | end |
||
1266 | |||
1267 | function ChatBox_SetNameColor(event, arg2) |
||
1268 | --the only time information is added to my DBase, is with party/raid events. |
||
1269 | if ( event ) then |
||
1270 | if ( event == "CHAT_MSG_PARTY" ) then |
||
1271 | local numParty = GetNumPartyMembers(); |
||
1272 | for i=1, numParty do |
||
1273 | if ( UnitName("party"..i) == arg2 ) then |
||
1274 | localizedClass, englishClass = UnitClass("party"..i); |
||
1275 | ChatBox_ClassData(arg2, englishClass); |
||
1276 | elseif ( UnitName("player") == arg2 ) then |
||
1277 | localizedClass, englishClass = UnitClass("player"); |
||
1278 | ChatBox_ClassData(arg2, englishClass); |
||
1279 | end |
||
1280 | end |
||
1281 | end |
||
1282 | if ( event == "CHAT_MSG_RAID" ) then |
||
1283 | for i=1, MAX_RAID_MEMBERS do |
||
1284 | local name, _, _, _, class = GetRaidRosterInfo(i); |
||
1285 | if ( name and name == arg2 ) then |
||
1286 | ChatBox_ClassData(arg2, class); |
||
1287 | end |
||
1288 | end |
||
1289 | end |
||
1290 | else |
||
1291 | return ChatBox_ClassData(arg2); |
||
1292 | end |
||
1293 | end |
||
1294 | |||
1295 | function ChatBox_ClassData(arg2, class ) |
||
1296 | |||
1297 | if arg2 then |
||
1298 | arg2 = string.upper(arg2); |
||
1299 | end |
||
1300 | |||
1301 | if class then |
||
1302 | class = string.upper(class); |
||
1303 | end |
||
1304 | |||
1305 | if not ChatBox then |
||
1306 | cb_display(RED.."Error #A1 in ClassData! " .. WHT .. "Please report this in the ChatBox forums at ui.worldofwar.net!!"); |
||
1307 | ChatBox = {}; |
||
1308 | end |
||
1309 | |||
1310 | if not ChatBox_Names then |
||
1311 | ChatBox_Names = {}; |
||
1312 | end |
||
1313 | |||
1314 | if not arg2 then |
||
1315 | return ""; |
||
1316 | end |
||
1317 | |||
1318 | -- this retrieves the data. |
||
1319 | if not class then |
||
1320 | --this pulls the class color from the dbase! |
||
1321 | if ChatBox.colorNames then |
||
1322 | for name, color in ChatBox_Names do |
||
1323 | if name == arg2 then |
||
1324 | return color; |
||
1325 | end |
||
1326 | end |
||
1327 | end |
||
1328 | -- then we can assign them random colors! |
||
1329 | if ChatBox.colorRandom then --(From CleanChat) |
||
1330 | if not usedNames[arg2] then |
||
1331 | local hash = ChatBox_HashString(arg2); |
||
1332 | |||
1333 | local rgb = { math.floor(math.mod(hash, 255)), |
||
1334 | math.floor(math.mod(hash * 3, 255)), |
||
1335 | math.floor(math.mod(hash / 17, 255)) }; |
||
1336 | |||
1337 | local i; |
||
1338 | |||
1339 | -- Make color bright if to dark |
||
1340 | if rgb[1] < 190 and rgb[2] < 190 and rgb[3] < 190 then |
||
1341 | i = math.mod(hash, 3) + 1; |
||
1342 | while rgb[i] < 190 do |
||
1343 | rgb[i] = rgb[i] + 60; |
||
1344 | end |
||
1345 | end |
||
1346 | |||
1347 | local color = "|cff" .. string.lower(string.format("%02X%02X%02X", rgb[1], rgb[2], rgb[3] )); |
||
1348 | |||
1349 | i = 1; |
||
1350 | -- max five loops to find new color, otherwise use default as fallback |
||
1351 | while usedColors[color] or ( color == ChatBox_GetClassColor(CB_CLASS_MAGE) or |
||
1352 | color == ChatBox_GetClassColor(CB_CLASS_WARLOCK) or |
||
1353 | color == ChatBox_GetClassColor(CB_CLASS_PRIEST) or |
||
1354 | color == ChatBox_GetClassColor(CB_CLASS_DRUID) or |
||
1355 | color == ChatBox_GetClassColor(CB_CLASS_SHAMAN) or |
||
1356 | color == ChatBox_GetClassColor(CB_CLASS_PALADIN) or |
||
1357 | color == ChatBox_GetClassColor(CB_CLASS_ROGUE) or |
||
1358 | color == ChatBox_GetClassColor(CB_CLASS_HUNTER) or |
||
1359 | color == ChatBox_GetClassColor(CB_CLASS_WARRIOR)) |
||
1360 | and i < 6 do |
||
1361 | color = "|cff" .. string.lower(string.format("%02X%02X%02X", rgb[1], rgb[2], rgb[3] )); |
||
1362 | i = i + 1; |
||
1363 | end |
||
1364 | |||
1365 | usedColors[color] = true; |
||
1366 | |||
1367 | --now color their name. |
||
1368 | usedNames[arg2] = color |
||
1369 | end |
||
1370 | return usedNames[arg2]; |
||
1371 | end |
||
1372 | else |
||
1373 | --have to check if I already have the name there... |
||
1374 | local found; |
||
1375 | for name, color in ChatBox_Names do |
||
1376 | if name == arg2 then |
||
1377 | found = true; |
||
1378 | end |
||
1379 | end |
||
1380 | --only get here if I don't find the name in my dbase. |
||
1381 | if not found then |
||
1382 | local color = ChatBox_GetClassColor( class ); |
||
1383 | ChatBox_Names[arg2] = color; |
||
1384 | end |
||
1385 | end |
||
1386 | |||
1387 | -- never retrieved a color, so... |
||
1388 | return ""; |
||
1389 | end |
||
1390 | |||
1391 | |||
1392 | function ChatBox_GetClassColor( class ) |
||
1393 | |||
1394 | --class is CAPS!! |
||
1395 | --from IdentiChat. |
||
1396 | local classcolor = ""; |
||
1397 | --coloring class text |
||
1398 | if (class == CB_CLASS_MAGE) then |
||
1399 | classcolor = "|cff7fffff"; |
||
1400 | elseif (class == CB_CLASS_WARLOCK) then |
||
1401 | classcolor = "|cff7f4ce5"; |
||
1402 | elseif (class == CB_CLASS_PRIEST) then |
||
1403 | classcolor = "|cffcccccc"; |
||
1404 | elseif (class == CB_CLASS_DRUID) then |
||
1405 | classcolor = "|cffe59919"; |
||
1406 | elseif (class == CB_CLASS_SHAMAN) then |
||
1407 | classcolor = "|cffe566b2"; |
||
1408 | elseif (class == CB_CLASS_PALADIN) then |
||
1409 | classcolor = "|cffff6699"; |
||
1410 | elseif (class == CB_CLASS_ROGUE) then |
||
1411 | classcolor = "|cffe5e519"; |
||
1412 | elseif (class == CB_CLASS_HUNTER) then |
||
1413 | classcolor = "|cff19cc19"; |
||
1414 | elseif (class == CB_CLASS_WARRIOR) then |
||
1415 | classcolor = "|cffb27f4c"; |
||
1416 | end |
||
1417 | return classcolor; |
||
1418 | end |
||
1419 | |||
1420 | |||
1421 | |||
1422 | function formatText(msg) |
||
1423 | |||
1424 | --DEFAULT_CHAT_FRAME:AddMessage(":"..msg) |
||
1425 | |||
1426 | msg = string.lower(msg); |
||
1427 | |||
1428 | msg = string.gsub(msg, ":", "") |
||
1429 | msg = string.gsub(msg, "=", "") |
||
1430 | |||
1431 | --this gray's out the price of the enchant (or tries to) |
||
1432 | msg = string.gsub(msg, "%b()", |
||
1433 | function(s) |
||
1434 | if string.find(s, "%d+") then |
||
1435 | return GRY..s..END; |
||
1436 | else |
||
1437 | return s; |
||
1438 | end |
||
1439 | end ) |
||
1440 | |||
1441 | --this removes all double spaces. |
||
1442 | msg = string.gsub(msg, "%s+", " "); |
||
1443 | |||
1444 | |||
1445 | --have to seperate letters and parenthesis |
||
1446 | --do it for letter as a prefix to the paren. |
||
1447 | start_search = 1 |
||
1448 | for w in string.gfind(msg, "%(") do |
||
1449 | local a, b = string.find(msg, "%w%(", start_search); |
||
1450 | if a and b then |
||
1451 | msg = string.sub(msg, 1, b-1) .. " " .. string.sub(msg, b, string.len(msg)); |
||
1452 | start_search = b+1; |
||
1453 | end |
||
1454 | end |
||
1455 | --do it for letter as a prefix to the paren. |
||
1456 | start_search = 1; |
||
1457 | for w in string.gfind(msg, "%)") do |
||
1458 | local a, b = string.find(msg, "%)%w", start_search); |
||
1459 | if a and b then |
||
1460 | msg = string.sub(msg, 1, a) .. " " .. string.sub(msg, a+1, string.len(msg)); |
||
1461 | start_search = b+1; |
||
1462 | end |
||
1463 | end |
||
1464 | |||
1465 | newmsg = ""; |
||
1466 | |||
1467 | for w1, word, w4, space in string.gfind(msg, "(%p*)(%w+)(%p*)(%s?)") do |
||
1468 | |||
1469 | --DEFAULT_CHAT_FRAME:AddMessage(":"..w1..word..w4) |
||
1470 | --DEFAULT_CHAT_FRAME:AddMessage(":"..word) |
||
1471 | |||
1472 | --have to seperate letters and numbers *except for "g", "h", etc... |
||
1473 | --do it for number as a prefix. |
||
1474 | for n, w in string.gfind(word, "(%d+)(%a+)") do |
||
1475 | if not string.find(word, "cff") then |
||
1476 | if string.len(w) > 1 then |
||
1477 | word = n .. " " .. w; |
||
1478 | end |
||
1479 | end |
||
1480 | end |
||
1481 | --do it for number as a suffix. |
||
1482 | for w, n in string.gfind(word, "(%a+)(%d+)") do |
||
1483 | if not string.find(word, "cff") then |
||
1484 | if string.len(w) > 1 then |
||
1485 | word = w .. " " .. n; |
||
1486 | end |
||
1487 | end |
||
1488 | end |
||
1489 | |||
1490 | for key1,val1 in ChatBoxWords.equip do |
||
1491 | local temp_word = string.lower(val1); |
||
1492 | local a, b = string.find(word, temp_word); |
||
1493 | |||
1494 | if a and b then |
||
1495 | if string.sub(word, a, b+1) == temp_word .. "s" then |
||
1496 | temp_word = temp_word .. "s"; |
||
1497 | end |
||
1498 | |||
1499 | word = string.gsub(word, temp_word, ORN.."\n\n"..string.upper(temp_word)..": "..END); |
||
1500 | end |
||
1501 | |||
1502 | end |
||
1503 | |||
1504 | for key1,val1 in ChatBoxWords.stats do |
||
1505 | if word == val1 then |
||
1506 | word = string.gsub(word, val1, YEL..val1..END); |
||
1507 | end |
||
1508 | end |
||
1509 | |||
1510 | for key1,val1 in ChatBoxWords.riding do |
||
1511 | if word == val1 then |
||
1512 | word = string.gsub(word, val1, GRN..val1..END); |
||
1513 | end |
||
1514 | end |
||
1515 | |||
1516 | for key1,val1 in ChatBoxWords.bonusdmg do |
||
1517 | word = string.gsub(word, val1, RED..val1..END); |
||
1518 | end |
||
1519 | |||
1520 | newmsg = newmsg..w1..word..w4..space; |
||
1521 | end |
||
1522 | |||
1523 | return newmsg; |
||
1524 | end |