vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | ImprovedIgnore.lua |
||
3 | by Yrys - Hellscream <yrysremove at twparemove dot net> |
||
4 | |||
5 | Improved functionality for ignore. Ignored players show up as red on |
||
6 | who lists, and sending a tell to a player on ignore will optionally either |
||
7 | auto-remove that player from your ignore list, or block the tell. |
||
8 | |||
9 | Version history: |
||
10 | - 1.1.1.11100 (2005-09-30): The binary version! Updated for 1.11 patch. |
||
11 | - 1.1.1.11000 (2005-09-30): The binary version! Updated for 1.10 patch. |
||
12 | - 1.1.1.10900 (2005-12-02): Removed emote blocking code, and updated for 1.9. |
||
13 | - 1.1.0.1800 (2005-09-30): Updated for 1.8 patch. |
||
14 | - 1.1.0.1700 (2005-09-13): Updated for 1.7 patch. |
||
15 | - 1.1.0.1600 (2005-07-12): Updated for 1.6 patch. |
||
16 | - 1.1.0.1500 (2005-06-07): Updated for 1.5 patch. |
||
17 | - 1.1.0.1300 (2005-04-30): Emotes are now suppressed for people on your ignore list. |
||
18 | - 1.0.1.1300 (2005-04-29): Added command line options, whisper setting, system who. |
||
19 | - 1.0.0.1300 (2005-04-26): First version. |
||
20 | ]] |
||
21 | |||
22 | -- Variables. |
||
23 | IIGNORE_VER = "1.1.0.11000" |
||
24 | local SendChatMessage_Orig = nil |
||
25 | local GetWhoInfo_Orig = nil |
||
26 | local AddMessage1_Orig = nil |
||
27 | local AddMessage2_Orig = nil |
||
28 | local AddMessage3_Orig = nil |
||
29 | local AddMessage4_Orig = nil |
||
30 | local AddMessage5_Orig = nil |
||
31 | local AddMessage6_Orig = nil |
||
32 | local AddMessage7_Orig = nil |
||
33 | local syswhofound = nil |
||
34 | ImprovedIgnore_Settings = { |
||
35 | whisper = STR_IIGNORE_COMMAND_OFF |
||
36 | } |
||
37 | |||
38 | |||
39 | |||
40 | function ImprovedIgnore_OnLoad() |
||
41 | -- Hook functions. |
||
42 | |||
43 | if SendChatMessage ~= ImprovedIgnore_SendChatMessage then |
||
44 | SendChatMessage_Orig = SendChatMessage |
||
45 | SendChatMessage = ImprovedIgnore_SendChatMessage |
||
46 | end |
||
47 | if GetWhoInfo ~= ImprovedIgnore_GetWhoInfo then |
||
48 | GetWhoInfo_Orig = GetWhoInfo |
||
49 | GetWhoInfo = ImprovedIgnore_GetWhoInfo |
||
50 | end |
||
51 | if DEFAULT_CHAT_FRAME.AddMessage ~= ImprovedIgnore_AddMessage1 then |
||
52 | AddMessage1_Orig = DEFAULT_CHAT_FRAME.AddMessage |
||
53 | DEFAULT_CHAT_FRAME.AddMessage = ImprovedIgnore_AddMessage1 |
||
54 | end |
||
55 | if ChatFrame2 and ChatFrame2.AddMessage ~= ImprovedIgnore_AddMessage2 then |
||
56 | AddMessage2_Orig = ChatFrame2.AddMessage |
||
57 | ChatFrame2.AddMessage = ImprovedIgnore_AddMessage2 |
||
58 | end |
||
59 | if ChatFrame3 and ChatFrame3.AddMessage ~= ImprovedIgnore_AddMessage3 then |
||
60 | AddMessage3_Orig = ChatFrame3.AddMessage |
||
61 | ChatFrame3.AddMessage = ImprovedIgnore_AddMessage3 |
||
62 | end |
||
63 | if ChatFrame4 and ChatFrame4.AddMessage ~= ImprovedIgnore_AddMessage4 then |
||
64 | AddMessage4_Orig = ChatFrame4.AddMessage |
||
65 | ChatFrame4.AddMessage = ImprovedIgnore_AddMessage4 |
||
66 | end |
||
67 | if ChatFrame5 and ChatFrame5.AddMessage ~= ImprovedIgnore_AddMessage5 then |
||
68 | AddMessage5_Orig = ChatFrame5.AddMessage |
||
69 | ChatFrame5.AddMessage = ImprovedIgnore_AddMessage5 |
||
70 | end |
||
71 | if ChatFrame6 and ChatFrame6.AddMessage ~= ImprovedIgnore_AddMessage6 then |
||
72 | AddMessage6_Orig = ChatFrame6.AddMessage |
||
73 | ChatFrame6.AddMessage = ImprovedIgnore_AddMessage6 |
||
74 | end |
||
75 | if ChatFrame7 and ChatFrame7.AddMessage ~= ImprovedIgnore_AddMessage7 then |
||
76 | AddMessage7_Orig = ChatFrame7.AddMessage |
||
77 | ChatFrame7.AddMessage = ImprovedIgnore_AddMessage7 |
||
78 | end |
||
79 | if SendChatMessage ~= ImprovedIgnore_SendChatMessage then |
||
80 | SendChatMessage_Orig = SendChatMessage |
||
81 | SendChatMessage = ImprovedIgnore_SendChatMessage |
||
82 | end |
||
83 | |||
84 | -- Register events we want to catch. |
||
85 | this:RegisterEvent ("CHAT_MSG_SYSTEM") |
||
86 | |||
87 | -- Set up slash commands. |
||
88 | SlashCmdList["IMPROVEDIGNORE"] = ImprovedIgnore_CmdRelay |
||
89 | SLASH_IMPROVEDIGNORE1 = "/ii" |
||
90 | SLASH_IMPROVEDIGNORE2 = "/improvedignore" |
||
91 | |||
92 | -- Show loaded message. |
||
93 | DEFAULT_CHAT_FRAME:AddMessage (string.format (STR_IIGNORE_FUNC_LOADED, IIGNORE_VER)) |
||
94 | end |
||
95 | |||
96 | |||
97 | |||
98 | -- Event handler. Checks for non-WhoFrame /whos. |
||
99 | function ImprovedIgnore_OnEvent() |
||
100 | local name, othertext, start, stop = nil |
||
101 | |||
102 | if event == "CHAT_MSG_SYSTEM" and arg1 then |
||
103 | start, stop, name, othertext = string.find (arg1, "^(%a+)(: Level %d+ [^-]+- .*)") |
||
104 | if name and othertext then |
||
105 | syswhofound = 1 |
||
106 | end |
||
107 | end |
||
108 | end |
||
109 | |||
110 | |||
111 | |||
112 | -- Command-line handler. Passes to other functions. |
||
113 | function ImprovedIgnore_CmdRelay (args) |
||
114 | local start, stop, cmd, subargs = nil |
||
115 | |||
116 | -- Split arguments into first and all others. |
||
117 | if args then |
||
118 | start, stop, cmd, subargs = string.find (args, "^([^ ]-) (.+)$") |
||
119 | if not cmd then |
||
120 | cmd = args |
||
121 | end |
||
122 | end |
||
123 | |||
124 | if cmd then |
||
125 | cmd = string.lower (cmd) |
||
126 | end |
||
127 | if subargs then |
||
128 | subargs = string.lower (subargs) |
||
129 | end |
||
130 | |||
131 | if cmd == STR_IIGNORE_COMMAND_STATUS then |
||
132 | ImprovedIgnore_CmdStatus() |
||
133 | elseif cmd == STR_IIGNORE_COMMAND_WHISPER or cmd == STR_IIGNORE_COMMAND_TELL then |
||
134 | ImprovedIgnore_CmdWhisperConfig (subargs) |
||
135 | else |
||
136 | ImprovedIgnore_CmdHelp() |
||
137 | end |
||
138 | end |
||
139 | |||
140 | |||
141 | |||
142 | -- Shows command-line help. |
||
143 | function ImprovedIgnore_CmdHelp() |
||
144 | local syscolor = ChatTypeInfo["SYSTEM"] |
||
145 | |||
146 | DEFAULT_CHAT_FRAME:AddMessage (string.format (STR_IIGNORE_HELP_HEADER, IIGNORE_VER), syscolor.r, syscolor.g, syscolor.b, syscolor.id) |
||
147 | DEFAULT_CHAT_FRAME:AddMessage (STR_IIGNORE_HELP_STATUS, syscolor.r, syscolor.g, syscolor.b, syscolor.id) |
||
148 | DEFAULT_CHAT_FRAME:AddMessage (STR_IIGNORE_HELP_WHISPER, syscolor.r, syscolor.g, syscolor.b, syscolor.id) |
||
149 | end |
||
150 | |||
151 | |||
152 | |||
153 | -- Shows ImprovedIgnore status. |
||
154 | function ImprovedIgnore_CmdStatus() |
||
155 | DEFAULT_CHAT_FRAME:AddMessage (STR_IIGNORE_STATUS_HEADER) |
||
156 | if ImprovedIgnore_Settings.whisper == STR_IIGNORE_COMMAND_ON then |
||
157 | DEFAULT_CHAT_FRAME:AddMessage (STR_IIGNORE_STATUS_WHISPERON) |
||
158 | elseif ImprovedIgnore_Settings.whisper == STR_IIGNORE_COMMAND_AUTO then |
||
159 | DEFAULT_CHAT_FRAME:AddMessage (STR_IIGNORE_STATUS_WHISPERAUTO) |
||
160 | elseif ImprovedIgnore_Settings.whisper == STR_IIGNORE_COMMAND_OFF then |
||
161 | DEFAULT_CHAT_FRAME:AddMessage (STR_IIGNORE_STATUS_WHISPEROFF) |
||
162 | end |
||
163 | end |
||
164 | |||
165 | |||
166 | |||
167 | -- Configure whisper settings. |
||
168 | function ImprovedIgnore_CmdWhisperConfig (arg) |
||
169 | local syscolor = ChatTypeInfo["SYSTEM"] |
||
170 | |||
171 | if arg == STR_IIGNORE_COMMAND_ON then |
||
172 | ImprovedIgnore_Settings.whisper = STR_IIGNORE_COMMAND_ON |
||
173 | DEFAULT_CHAT_FRAME:AddMessage (STR_IIGNORE_WHISPER_ON) |
||
174 | elseif arg == STR_IIGNORE_COMMAND_AUTO then |
||
175 | ImprovedIgnore_Settings.whisper = STR_IIGNORE_COMMAND_AUTO |
||
176 | DEFAULT_CHAT_FRAME:AddMessage (STR_IIGNORE_WHISPER_AUTO) |
||
177 | elseif arg == STR_IIGNORE_COMMAND_OFF then |
||
178 | ImprovedIgnore_Settings.whisper = STR_IIGNORE_COMMAND_OFF |
||
179 | DEFAULT_CHAT_FRAME:AddMessage (STR_IIGNORE_WHISPER_OFF) |
||
180 | else |
||
181 | DEFAULT_CHAT_FRAME:AddMessage (STR_IIGNORE_HELP_WHISPER, syscolor.r, syscolor.g, syscolor.b, syscolor.id) |
||
182 | end |
||
183 | end |
||
184 | |||
185 | |||
186 | |||
187 | -- Check a name to see if it's being ignored. 1 if true, nil if false. |
||
188 | function ImprovedIgnore_IsPlayerIgnored (player) |
||
189 | if player and GetNumIgnores() then |
||
190 | for x = 1, GetNumIgnores() do |
||
191 | if string.lower (GetIgnoreName(x)) == string.lower (player) then |
||
192 | return 1 |
||
193 | end |
||
194 | end |
||
195 | end |
||
196 | |||
197 | return nil |
||
198 | end |
||
199 | |||
200 | |||
201 | |||
202 | -- Color a name red if player is on ignore. |
||
203 | function ImprovedIgnore_ColorWhoName (player) |
||
204 | if ImprovedIgnore_IsPlayerIgnored (player) then |
||
205 | player = "|cffff0000" .. player .. "|r"; |
||
206 | end |
||
207 | |||
208 | return player |
||
209 | end |
||
210 | |||
211 | |||
212 | |||
213 | -- When getting who info, check for ignored names. |
||
214 | function ImprovedIgnore_GetWhoInfo (whoIndex) |
||
215 | name, guild, level, race, class, zone, group = GetWhoInfo_Orig (whoIndex) |
||
216 | |||
217 | name = ImprovedIgnore_ColorWhoName (name) |
||
218 | |||
219 | return name, guild, level, race, class, zone, group |
||
220 | end |
||
221 | |||
222 | |||
223 | |||
224 | -- Check to see if message is a system /who. |
||
225 | function ImprovedIgnore_CheckSysWho (whotext) |
||
226 | local start, stop, name, othertext = nil |
||
227 | |||
228 | if whotext then |
||
229 | start, stop, name, othertext = string.find (arg1, "^(%a+)(: Level %d+ [^-]+- .*)") |
||
230 | if name and othertext then |
||
231 | name = ImprovedIgnore_ColorWhoName (name) |
||
232 | whotext = name .. othertext |
||
233 | end |
||
234 | end |
||
235 | |||
236 | return whotext |
||
237 | end |
||
238 | |||
239 | |||
240 | |||
241 | -- Check to see if an emote is from an ignored player. 1 on true, nil on false. |
||
242 | -- REMOVED FOR 1.9. This will be deleted from the code in the next release. |
||
243 | --[[ function ImprovedIgnore_CheckEmote (message) |
||
244 | local start, stop, name = nil |
||
245 | |||
246 | if message then |
||
247 | start, stop, name = string.find (message, "^(%a+)") |
||
248 | if name and ImprovedIgnore_IsPlayerIgnored (name) then |
||
249 | return 1 |
||
250 | end |
||
251 | end |
||
252 | |||
253 | return nil |
||
254 | end ]] |
||
255 | |||
256 | |||
257 | |||
258 | -- Check for ignored players on sending a whisper. |
||
259 | function ImprovedIgnore_SendChatMessage (msg, ...) |
||
260 | local system, language, player = unpack (arg) |
||
261 | |||
262 | if system == "WHISPER" and player then |
||
263 | if ImprovedIgnore_IsPlayerIgnored (player) then |
||
264 | if ImprovedIgnore_Settings.whisper == STR_IIGNORE_COMMAND_AUTO then |
||
265 | DEFAULT_CHAT_FRAME:AddMessage (string.format (STR_IIGNORE_FUNC_AUTO, player), 1, 0, 0) |
||
266 | DelIgnore (player) |
||
267 | elseif ImprovedIgnore_Settings.whisper == STR_IIGNORE_COMMAND_OFF then |
||
268 | DEFAULT_CHAT_FRAME:AddMessage (string.format (STR_IIGNORE_FUNC_BLOCK, player), 1, 0, 0) |
||
269 | return |
||
270 | end |
||
271 | end |
||
272 | end |
||
273 | |||
274 | SendChatMessage_Orig (msg, unpack (arg)) |
||
275 | end |
||
276 | |||
277 | |||
278 | |||
279 | -- Modified default AddMessage. If flag is set, check for ignored /who name. |
||
280 | function ImprovedIgnore_AddMessage1 (t, s, ...) |
||
281 | if syswhofound then |
||
282 | s = ImprovedIgnore_CheckSysWho (s) |
||
283 | syswhofound = nil |
||
284 | end |
||
285 | |||
286 | AddMessage1_Orig (t, s, unpack (arg)) |
||
287 | end |
||
288 | |||
289 | |||
290 | |||
291 | -- Modified chat 2 AddMessage. If flag is set, check for ignored /who name. |
||
292 | function ImprovedIgnore_AddMessage2 (t, s, ...) |
||
293 | if syswhofound then |
||
294 | s = ImprovedIgnore_CheckSysWho (s) |
||
295 | syswhofound = nil |
||
296 | end |
||
297 | |||
298 | AddMessage2_Orig (t, s, unpack (arg)) |
||
299 | end |
||
300 | |||
301 | |||
302 | |||
303 | -- Modified chat 3 AddMessage. If flag is set, check for ignored /who name. |
||
304 | function ImprovedIgnore_AddMessage3 (t, s, ...) |
||
305 | if syswhofound then |
||
306 | s = ImprovedIgnore_CheckSysWho (s) |
||
307 | syswhofound = nil |
||
308 | end |
||
309 | |||
310 | AddMessage3_Orig (t, s, unpack (arg)) |
||
311 | end |
||
312 | |||
313 | |||
314 | |||
315 | -- Modified chat 4 AddMessage. If flag is set, check for ignored /who name. |
||
316 | function ImprovedIgnore_AddMessage4 (t, s, ...) |
||
317 | if syswhofound then |
||
318 | s = ImprovedIgnore_CheckSysWho (s) |
||
319 | syswhofound = nil |
||
320 | end |
||
321 | |||
322 | AddMessage4_Orig (t, s, unpack (arg)) |
||
323 | end |
||
324 | |||
325 | |||
326 | |||
327 | -- Modified chat 5 AddMessage. If flag is set, check for ignored /who name. |
||
328 | function ImprovedIgnore_AddMessage5 (t, s, ...) |
||
329 | if syswhofound then |
||
330 | s = ImprovedIgnore_CheckSysWho (s) |
||
331 | syswhofound = nil |
||
332 | end |
||
333 | |||
334 | AddMessage5_Orig (t, s, unpack (arg)) |
||
335 | end |
||
336 | |||
337 | |||
338 | |||
339 | -- Modified chat 6 AddMessage. If flag is set, check for ignored /who name. |
||
340 | function ImprovedIgnore_AddMessage6 (t, s, ...) |
||
341 | if syswhofound then |
||
342 | s = ImprovedIgnore_CheckSysWho (s) |
||
343 | syswhofound = nil |
||
344 | end |
||
345 | |||
346 | AddMessage6_Orig (t, s, unpack (arg)) |
||
347 | end |
||
348 | |||
349 | |||
350 | |||
351 | -- Modified chat 7 AddMessage. If flag is set, check for ignored /who name. |
||
352 | function ImprovedIgnore_AddMessage7 (t, s, ...) |
||
353 | if syswhofound then |
||
354 | s = ImprovedIgnore_CheckSysWho (s) |
||
355 | syswhofound = nil |
||
356 | end |
||
357 | |||
358 | AddMessage7_Orig (t, s, unpack (arg)) |
||
359 | end |