Skip to content

Commit ed128f8

Browse files
committed
Added enabled by default settings to ignore vote kick / vote abandon popups
1 parent 8e57ab6 commit ed128f8

File tree

2 files changed

+47
-59
lines changed

2 files changed

+47
-59
lines changed

main.lua

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ local DialogKey = LibStub("AceAddon-3.0"):NewAddon(name, "AceEvent-3.0", "AceHoo
1111
ns.Core = DialogKey
1212

1313
local defaultPopupBlacklist = { -- If a popup dialog contains one of these strings, don't click it
14-
AREA_SPIRIT_HEAL, -- Prevents cancelling the resurrection
15-
TOO_MANY_LUA_ERRORS,
16-
END_BOUND_TRADEABLE, -- Probably quite reasonable to make the user click on this one
17-
ADDON_ACTION_FORBIDDEN, -- Don't disable and reload UI on errors
14+
AREA_SPIRIT_HEAL = true, -- Prevents cancelling the resurrection
15+
TOO_MANY_LUA_ERRORS = true,
16+
END_BOUND_TRADEABLE = true, EQUIP_BIND_TRADEABLE = true, -- Probably quite reasonable to make the user click on this one
17+
ADDON_ACTION_FORBIDDEN = true, -- Don't disable and reload UI on errors
18+
CONFIRM_LEAVE_RESTRICTED_CHALLENGE_MODE = true,
19+
WARN_LEAVE_RESTRICTED_CHALLENGE_MODE = true,
1820
}
1921

2022
local function callFrameMethod(frame, method, ...)
@@ -273,46 +275,26 @@ function DialogKey:GetValidPopupButtons()
273275
return next(buttons) and buttons or nil
274276
end
275277

276-
-- Takes a global string like '%s has challenged you to a duel.' and converts it to a format suitable for string.find
277-
local summonMatch = CONFIRM_SUMMON:gsub("%%d", ".+"):format(".+", ".+", ".+")
278-
local duelMatch = DUEL_REQUESTED:format(".+")
279-
local resurrectMatch = RESURRECT_REQUEST_NO_SICKNESS:format(".+")
280-
local groupinviteMatch = INVITATION:format(".+")
281-
local instanceLogMatches = {
282-
INSTANCE_LOCK_TIMER:format(".+", ".+"),
283-
INSTANCE_LOCK_TIMER_PREVIOUSLY_SAVED:format(".+", ".+"),
284-
INSTANCE_LOCK_WARNING:format(".+"),
285-
INSTANCE_LOCK_WARNING_PREVIOUSLY_SAVED:format(".+"),
286-
}
287-
288278
--- @param popupFrame StaticPopupTemplate # One of the StaticPopup1-4 frames
289279
--- @return Frame|nil|false # The button to click, nil if no button should be clicked, false if the text is empty and should be checked again later
290280
function DialogKey:GetPopupButton(popupFrame)
291281
local fontString = popupFrame.GetTextFontString and popupFrame:GetTextFontString() or popupFrame.text
292282
local text = fontString and fontString:GetText()
293-
local button1, button2
294-
if popupFrame.GetButtons then
295-
button1, button2 = unpack(popupFrame:GetButtons())
296-
else
297-
button1 = popupFrame.button1
298-
button2 = popupFrame.button2
299-
end
283+
local which = popupFrame.which
284+
285+
local button1 = popupFrame.button1 or popupFrame:GetButton1()
286+
local button2 = popupFrame.button2 or popupFrame:GetButton2()
300287

301288
-- Some popups have no text when they initially show, and instead get text applied OnUpdate (summons are an example)
302289
-- False is returned in that case, so we know to keep checking OnUpdate
303290
if not text or text == " " or text == "" then return false end
304291

305-
-- Don't accept group invitations if the option is enabled
306-
if self.db.dontAcceptInvite and text:find(groupinviteMatch) then return end
307-
308-
-- Don't accept summons/duels/resurrects if the options are enabled
309-
if self.db.dontClickSummons and text:find(summonMatch) then return end
310-
if self.db.dontClickDuels and text:find(duelMatch) then return end
311-
if self.db.dontAcceptInstanceLocks then
312-
for _, match in pairs(instanceLogMatches) do
313-
if text:find(match) then return end
314-
end
315-
end
292+
if self.db.dontAcceptInvite and which == 'PARTY_INVITE' then return end
293+
if self.db.dontClickSummons and which == 'CONFIRM_SUMMON' then return end
294+
if self.db.dontClickDuels and which == 'DUEL_REQUESTED' then return end
295+
if self.db.dontAcceptInstanceLocks and which == 'INSTANCE_LOCK' then return end
296+
if self.db.dontAcceptAbandonVote and which == 'VOTE_ABANDON_INSTANCE_VOTE' or which == 'VOTE_ABANDON_INSTANCE_WAIT' then return end
297+
if self.db.dontAcceptVoteKick and which == 'VOTE_BOOT_PLAYER' then return end
316298

317299
-- If resurrect dialog has three buttons, and the option is enabled, use the middle one instead of the first one (soulstone, etc.)
318300
-- Located before resurrect/release checks/returns so it happens even if you have releases/revives disabled
@@ -325,27 +307,18 @@ function DialogKey:GetPopupButton(popupFrame)
325307
return button2
326308
end
327309

328-
if self.db.dontClickRevives and (text == RECOVER_CORPSE or text:find(resurrectMatch)) then return end
310+
if self.db.dontClickRevives and (text == RECOVER_CORPSE or which == 'RESURRECT_NO_SICKNESS' or which == 'RESURRECT_NO_TIMER') then return end
329311
if self.db.dontClickReleases and canRelease then return end
330312

331-
-- Ignore blacklisted popup dialogs!
313+
-- Ignore blacklisted popup dialogs
314+
if defaultPopupBlacklist[which] or self.db.dialogBlacklist[which] then return end
332315
local lowerCaseText = text:lower()
333316
for blacklistText, _ in pairs(self.db.dialogBlacklist) do
334317
-- Prepend non-alphabetical characters with '%' to escape them
335318
blacklistText = blacklistText:gsub("%W", "%%%0"):gsub("%%%%s", ".+")
336319
if lowerCaseText:find(blacklistText:lower()) then return end
337320
end
338321

339-
for _, blacklistText in pairs(defaultPopupBlacklist) do
340-
-- Prepend non-alphabetical characters with '%' to escape them
341-
-- Replace %s and %d with .+ to match any string or number
342-
-- Trim whitespaces
343-
blacklistText = blacklistText:gsub("%W", "%%%0"):gsub("%%%%s", ".+"):gsub("%%%%d", ".+"):gsub("^%s*(.-)%s*$", "%1")
344-
if lowerCaseText:find(blacklistText:lower()) then
345-
return
346-
end
347-
end
348-
349322
return button1:IsVisible() and button1 or nil
350323
end
351324

options.lua

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ ns.defaultOptions = {
2323
dontClickRevives = true,
2424
dontClickReleases = true,
2525
dontAcceptInvite = true,
26+
dontAcceptAbandonVote = true,
27+
dontAcceptVoteKick = true,
2628
dontAcceptInstanceLocks = false,
2729
useSoulstoneRez = true,
2830
handleCraftingOrders = true,
@@ -248,7 +250,7 @@ function ns:GetOptionsTable()
248250
order = increment(),
249251
name = wrapName("Number keys for Gossip - Risky"),
250252
disabled = function() return not db.numKeysForGossip end,
251-
desc = "Ensure scrollbar is enabled if the text becomes too long. This may taint objective frame buttons, such as dropping candles in delves. If you encounter issues, just disable this option.",
253+
desc = "Ensure scrollbar is enabled if the text becomes too long. This may taint objective frame buttons. If you encounter issues, just disable this option.",
252254
descStyle = "inline", width = "full", type = "toggle",
253255
},
254256
numKeysForQuestRewards = {
@@ -343,49 +345,62 @@ If you have trouble finding the name, try "/fstack", pressing ALT until the fram
343345
order = increment(),
344346
name = wrapName("Don't Accept Group Invites"),
345347
desc = "Don't allow DialogKey to accept Raid/Party Invitations",
346-
descStyle = "inline", width = "full", type = "toggle",
348+
width = 1.2, type = "toggle",
347349
},
348350
dontAcceptInstanceLocks = {
349351
order = increment(),
350352
name = wrapName("Don't Accept Instance Lockouts"),
351353
desc = "Don't allow DialogKey to accept/\"save\" Instance Lockouts",
352-
descStyle = "inline", width = "full", type = "toggle",
354+
width = 1.2, type = "toggle",
355+
},
356+
dontAcceptAbandonVote = {
357+
order = increment(),
358+
name = wrapName("Don't Accept M+ Abandon Key Votes"),
359+
desc = "Don't allow DialogKey to vote to abandon a m+ key",
360+
width = 1.2, type = "toggle",
361+
},
362+
dontAcceptVoteKick = {
363+
order = increment(),
364+
name = wrapName("Don't Accept Vote Kicks"),
365+
desc = "Don't allow DialogKey to vote in Vote Kicks",
366+
width = 1.2, type = "toggle",
353367
},
354368
dontClickSummons = {
355369
order = increment(),
356370
name = wrapName("Don't Accept Summons"),
357371
desc = "Don't allow DialogKey to accept Summon Requests",
358-
descStyle = "inline", width = "full", type = "toggle",
372+
width = 1.2, type = "toggle",
359373
},
360374
dontClickDuels = {
361375
order = increment(),
362376
name = wrapName("Don't Accept Duels"),
363377
desc = "Don't allow DialogKey to accept Duel Requests",
364-
descStyle = "inline", width = "full", type = "toggle",
378+
width = 1.2, type = "toggle",
365379
},
366380
dontClickRevives = {
367381
order = increment(),
368382
name = wrapName("Don't Accept Revives"),
369383
desc = "Don't allow DialogKey to accept Resurrections",
370-
descStyle = "inline", width = "full", type = "toggle",
371-
},
372-
dontClickReleases = {
373-
order = increment(),
374-
name = wrapName("Don't Release Spirit"),
375-
desc = "Don't allow DialogKey to Release Spirit",
376-
descStyle = "inline", width = "full", type = "toggle",
384+
width = 1.2, type = "toggle",
377385
},
378386
useSoulstoneRez = {
379387
order = increment(),
380388
name = wrapName("Use Class-specific Revive"),
381389
desc = "Use Soulstone/Ankh/etc. resurrection option when one is available and a normal/battle resurrection is not\n\nThis option |cffff0000ignores|r the |cffffd100Don't Accept Revives|r option!",
382-
descStyle = "inline", width = "full", type = "toggle",
390+
width = 1.2, type = "toggle",
391+
},
392+
dontClickReleases = {
393+
order = increment(),
394+
name = wrapName("Don't Release Spirit"),
395+
desc = "Don't allow DialogKey to Release Spirit",
396+
width = 1.2, type = "toggle",
383397
},
384398
desc = {
385399
order = increment(),
386400
name = [[
387401
Here you can create a custom list of popups that DialogKey should ignore.
388402
Simply add (part of) the text that appears in the popup, and DialogKey will ignore it.
403+
Alternatively, you can add the technical name of the popup, which you can find with /dump StaticPopup1.which while the popup is open.
389404
]],
390405
type = "description",
391406
fontSize = "medium",

0 commit comments

Comments
 (0)