Quantcast

Added option whitelist bypass blacklist

Erik L. Vonderscheer [08-08-09 - 03:08]
Added option whitelist bypass blacklist
Added simple duel spam block
Fix repeat filter not actually being off
Filename
TradeFilter3.lua
TradeFilter3Options.lua
diff --git a/TradeFilter3.lua b/TradeFilter3.lua
index 8d8da69..fbaccf4 100644
--- a/TradeFilter3.lua
+++ b/TradeFilter3.lua
@@ -83,6 +83,7 @@ defaults = {
 		whitelist_enable = true,
 		redirect_blacklist = false,
 		wlbp = false,
+		wlblbp = false,
 		repeat_enable = true,
 		special_enable = false,
 		num_repeats = "2",
@@ -303,33 +304,37 @@ end

 --[[ BlackList Func ]]--
 --[[ Base blacklist words from BadBoy(Funkydude) ]]--
-function TF3:BlackList(msg, userID, msgID)
+function TF3:BlackList(msg, userID, msgID, arg)
 	local blword = TF3.db.profile.blacklist
 	local msg = lower(msg)
-	if (TF3.db.profile.blacklist_enable) then
-		for _,word in pairs(blword) do
-			if (find(msg,word)) then
-				if (TF3.db.profile.debug) then
-					if (msgID ~= lastmsgID) then
-						TF3:FindFrame(debugFrame, "|cFFFF0000[" .. L["bLists"] .. "]|r |cFFD9D9D9[" .. userID .. "]:|r |cFFC08080" .. msg .. "|r")
-						TF3:FindFrame(debugFrame, L["MATCHED"] .. " |cFFFF0000" .. word .. "|r")
-						if not (TF3.db.profile.redirect_blacklist) then
-							lastmsgID = msgID
+	if (arg == whitelist and TF3.db.profile.wlblbp == true) then
+		return false
+	else
+		if (TF3.db.profile.blacklist_enable) then
+			for _,word in pairs(blword) do
+				if (find(msg,word)) then
+					if (TF3.db.profile.debug) then
+						if (msgID ~= lastmsgID) then
+							TF3:FindFrame(debugFrame, "|cFFFF0000[" .. L["bLists"] .. "]|r |cFFD9D9D9[" .. userID .. "]:|r |cFFC08080" .. msg .. "|r")
+							TF3:FindFrame(debugFrame, L["MATCHED"] .. " |cFFFF0000" .. word .. "|r")
+							if not (TF3.db.profile.redirect_blacklist) then
+								lastmsgID = msgID
+							end
 						end
 					end
-				end
-				if (TF3.db.profile.redirect_blacklist) then
-					if (msgID ~= lastmsgID) then
-						TF3:FindFrame(redirectFrame, "|cFFFF0000[" .. L["bLists"] .. "]|r |cFFD9D9D9[" .. userID .. "]:|r |cFFC08080" .. msg .. "|r")
-						TF3:FindFrame(redirectFrame, L["MATCHED"] .. " |cFFFF0000" .. word .. "|r")
-						lastmsgID = msgID
+					if (TF3.db.profile.redirect_blacklist) then
+						if (msgID ~= lastmsgID) then
+							TF3:FindFrame(redirectFrame, "|cFFFF0000[" .. L["bLists"] .. "]|r |cFFD9D9D9[" .. userID .. "]:|r |cFFC08080" .. msg .. "|r")
+							TF3:FindFrame(redirectFrame, L["MATCHED"] .. " |cFFFF0000" .. word .. "|r")
+							lastmsgID = msgID
+						end
 					end
+					return true
 				end
-				return true
 			end
 		end
+		return false
 	end
-	return false
 end

 --[[ WhiteList Func ]]--
@@ -338,7 +343,7 @@ function TF3:WhiteList(msg, userID, msgID)
 	local msg = lower(msg)
 	if (TF3.db.profile.whitelist_enable) then
 		for _,word in pairs(wlword) do
-			if (find(msg,word) and TF3:FindRepeat(msg, userID, msgID, whitelist) == false and TF3:BlackList(msg, userID, msgID) == false) then
+			if (find(msg,word) and TF3:FindRepeat(msg, userID, msgID, whitelist) == false and TF3:BlackList(msg, userID, msgID, whitelist) == false) then
 				if (TF3.db.profile.debug) then
 					if (msgID ~= lastmsgID) then
 						TF3:FindFrame(debugFrame, "|cFFFFFF80[" .. L["wLists"] .. "]|r |cFFD9D9D9[" .. userID .. "]:|r |cFFC08080" .. msg .. "|r")
@@ -370,8 +375,12 @@ end

 --[[ Repeat Func ]]--
 function TF3:FindRepeat(msg, userID, msgID, arg)
-	if (arg == whitelist and not TF3.db.profile.wlbp) then
-		local gtime = math.floor(GetTime()*math.pow(10,0)+0.5) / math.pow(10,0)
+	local gtime = math.floor(GetTime()*math.pow(10,0)+0.5) / math.pow(10,0)
+	if (arg == whitelist and TF3.db.profile.wlbp == true) then
+		return false
+	elseif (TF3.db.profile.repeat_enable == false) then
+		return false
+	else
 		if (msgID ~= repeatdata[userID].lastmsgID and msg == repeatdata[userID].lastmsg and gtime - repeatdata[userID].lastIndex < tonumber(TF3.db.profile.time_repeats)) then
 			repeatdata[userID].repeats = repeatdata[userID].repeats + 1
 			if (repeatdata[userID].repeats >= tonumber(TF3.db.profile.num_repeats)) then
@@ -395,8 +404,6 @@ function TF3:FindRepeat(msg, userID, msgID, arg)
 		repeatdata[userID].lastmsgID = msgID
 		repeatdata[userID].lastIndex  = gtime
 		return false
-	else
-		return false
 	end
 end

diff --git a/TradeFilter3Options.lua b/TradeFilter3Options.lua
index 1e2f48b..3895e3a 100644
--- a/TradeFilter3Options.lua
+++ b/TradeFilter3Options.lua
@@ -115,12 +115,34 @@ options = {
 						},
 						optionsHeader1a = {
 							type	= "header",
-							order	= 8,
+							order	= 7,
+							name	= L["FDS"],
+						},
+						filterDuelSpam = {
+							type = 'toggle',
+							order = 8,
+							width = "double",
+							disabled = false,
+							name = L["FDS"],
+							desc = L["FDSD"],
+							get = function() return TF3.db.profile.filterDuelSpam end,
+							set = function()
+								TF3.db.profile.filterDuelSpam = not TF3.db.profile.filterDuelSpam
+								if (TF3.db.profile.filterDuelSpam) then
+									DUEL_WINNER_KNOCKOUT, DUEL_WINNER_RETREAT = "", ""
+								else
+									DUEL_WINNER_KNOCKOUT, DUEL_WINNER_RETREAT = L["DUEL_WINNER_KNOCKOUT"], L["DUEL_WINNER_RETREAT"]
+								end
+							end,
+						},
+						optionsHeader1b = {
+							type	= "header",
+							order	= 9,
 							name	= L["SPCS"],
 						},
 						GuildAddOnsChannel = {
 							type = 'toggle',
-							order = 9,
+							order = 10,
 							width = "double",
 							disabled = false,
 							name = L["GAC"],
@@ -130,7 +152,7 @@ options = {
 						},
 						special_enable = {
 							type = 'toggle',
-							order = 10,
+							order = 11,
 							width = "double",
 							disabled = false,
 							name = L["SPCST"],
@@ -144,7 +166,7 @@ options = {
 								return not TF3.db.profile.special_enable
 							end,
 							multiline = 4,
-							order = 11,
+							order = 12,
 							width = "full",
 							name = L["SPCST"],
 							desc = L["SPCSTD"],
@@ -182,7 +204,7 @@ options = {
 							disabled = function()
 								return not TF3.db.profile.special_enable
 							end,
-							order = 12,
+							order = 13,
 							name = L["RSF"],
 							desc = L["RSF"],
 							func = function() TF3.db.profile.filters.SPECIAL = TF3:CopyTable(L.FILTERS.SPECIAL) end,
@@ -436,13 +458,22 @@ options = {
 							get = function() return TF3.db.profile.wlbp end,
 							set = function() TF3.db.profile.wlbp = not TF3.db.profile.wlbp end,
 						},
+						whitelist_blacklist_bypass = {
+							type = 'toggle',
+							order = 11,
+							width = "double",
+							name = L["BLBYPASS"],
+							desc = L["BLBYPASSD"],
+							get = function() return TF3.db.profile.wlblbp end,
+							set = function() TF3.db.profile.wlblbp = not TF3.db.profile.wlblbp end,
+						},
 						wlist = {
 							type = 'input',
 							disabled = function()
 								return not TF3.db.profile.ewl
 							end,
 							multiline = 8,
-							order = 11,
+							order = 12,
 							width = "full",
 							name = L["wLists"],
 							usage = L["INPUSAGE"],
@@ -479,7 +510,7 @@ options = {
 							disabled = function()
 								return not TF3.db.profile.ewl
 							end,
-							order = 12,
+							order = 13,
 							name = L["RWLS"],
 							desc = L["RWLS"],
 							func = function() TF3.db.profile.whitelist = TF3:CopyTable(L.WHITELIST) end,