WoWInterface SVN StopTradeSpam

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 24 to Rev 25
    Reverse comparison

Rev 24 → Rev 25

StopTradeSpam/StopTradeSpam.lua
1,7 → 1,9
local version = 6.6
local version = 6.7
sts_session_all = 0
sts_session_filtered = 0
sts_last_action = 0
sts_last_msg = -1
sts_last_msgtext = ""
--local iw_ComplainChat = true
sts_lang = "enUS"
local f = CreateFrame("Frame", "STSFrame")
110,78 → 112,100
SendAddonMessage("STS_?Version",GetAddOnMetadata("StopTradeSpam","Version"),"WHISPER",STScommand[2])
end
dcfa(GetAddOnMetadata("StopTradeSpam","Version"))
elseif STScommand[1] == "options" then
elseif STScommand[1] == "options" or STScommand[1] == "o" then
if IsAddOnLoaded("StopTradeSpam_Options") then
InterfaceOptionsFrame_OpenToCategory("StopTradeSpam");
else
LoadAddOn("StopTradeSpam_Options")
InterfaceOptionsFrame_OpenToCategory("StopTradeSpam");
end
elseif STScommand[1] == "debug" then
if STScommand[2] then
STS_SV["debug"] = true
dcfa("debug flag set")
else
STS_SV["debug"] = nil
dcfa("debug flag unset")
end
else
dcfa("Wrong parameters.")
end
 
end
local function STS_ChatFilter(self, event, ...)
if (select(2,...) == UnitName("player")) or (select(6,...) == "GM") then
if (select(2,...) == UnitName("player")) or (select(2,...) == "") or (select(6,...) == "GM") then
return false,...
elseif event == "CHAT_MSG_CHANNEL" then
if sts_last_msg == select(11,...) then
if sts_last_action == 1 then -- filtered based on last scan of same message
if sts_last_action >= 1 then -- filtered based on last scan of same message
return true
elseif sts_last_action == 0 then
return false,...
elseif sts_last_action == -1 then
return false,sts_notify..STS_SV["settings"]["notify_new"].." \124r"..select(1,...),select(2,...),select(3,...),select(4,...),select(5,...),select(6,...),select(7,...),select(8,...),select(9,...),select(10,...),select(11,...),select(12,...)
elseif sts_last_action <= -1 then
return false,sts_last_msgtext,select(2,...),select(3,...),select(4,...),select(5,...),select(6,...),select(7,...),select(8,...),select(9,...),select(10,...),select(11,...),select(12,...)
end
else
sts_last_msg = select(11,...)
end
if select(7,...) == 2 then sts_session_all = sts_session_all + 1 end
--debug: not STS_SV["debug"] and
if STS_SV["ignore"][tignlist][select(2,...)] then
if select(7,...) == 2 then sts_session_filtered = sts_session_filtered + 1 end
sts_last_action = 1
return true
-- debug: return all: return false,select(1,...),select(2,...),select(3,...),select(4,...),select(5,...),select(6,...),select(7,...),select(8,...),select(9,...),select(10,...),select(11,...),select(12,...)
if STS_SV["settings"][event][select(8,...)] then -- if channel is activated for ignorelist in settings (default)
if select(7,...) == 2 then sts_session_filtered = sts_session_filtered + 1 end
sts_last_action = 1
return true
else --just notify
sts_last_msgtext = sts_notify..STS_SV["settings"]["notify_tign"].."\124r "..select(1,...)
sts_last_action = -1
return false,sts_last_msgtext,select(2,...),select(3,...),select(4,...),select(5,...),select(6,...),select(7,...),select(8,...),select(9,...),select(10,...),select(11,...),select(12,...)
end
end
if select(7,...) == 2 then -- Trade Channel: Filter this!
-- local sp = " # " --debug
local msg = select(1,...)
local spamfound = 0
for _,wle in pairs(STS_SV[sts_lang]["whitelist"]) do
if strfind(msg, wle) then
spamfound = spamfound - 1
break -- TODO: point system? don't break in that case
spamfound = spamfound - 2 --TODO: evaluate numbers
-- sp = sp..wle.." # " --debug
--debug/deprecated break -- TODO: point system? don't break in that case
end
end
if spamfound == 0 then
for _,ble in pairs(STS_SV[sts_lang]["blacklist"]) do
if strfind(msg, ble) then
spamfound = spamfound + 1
break -- TODO: point system? don't break in that case
end
--debug/deprecated if spamfound == 0 then
for _,ble in pairs(STS_SV[sts_lang]["blacklist"]) do
if strfind(msg, ble) then
spamfound = spamfound + 1
-- sp = sp..ble.." # " --debug
--debug/deprecated break -- TODO: point system? don't break in that case
end
end
--debug/deprecated end
-- sp = sp.."# #" --debug
if spamfound > 0 then
-- Ignore author of spam message here
-- if iw_ComplainChat and false then --debug and should be removed
-- ComplainChat(select(11,...))
-- dcfa(select(2,...).." reported")
-- end
sts_quiet = 1
STS_AddIgnore(select(2,...), "STS: ["..select(4,...).."] "..STS_ColoredNameLink(...)..": "..msg)
sts_session_filtered = sts_session_filtered + 1
if spamfound > 2 then
ComplainChat(select(11,...))
-- dcfa(select(2,...).." reported")
end
if STS_SV["settings"]["showblack"] then
sts_last_action = -1
return false,sts_notify..STS_SV["settings"]["notify_new"].." \124r"..select(1,...),select(2,...),select(3,...),select(4,...),select(5,...),select(6,...),select(7,...),select(8,...),select(9,...),select(10,...),select(11,...),select(12,...)
-- dcfa("Spam gefunden: ["..select(4,...).."] "..STS_ColoredNameLink(...)..": "..msg) -- Chatline is not needed: select(11,...); except for reporting spam
--debug w/: sts_last_msgtext = strsub("<"..spamfound.."> "..sp.." "..sts_notify..STS_SV["settings"]["notify_new"].." \124r"..select(1,...),1,255)
sts_last_msgtext = strsub(sts_notify..STS_SV["settings"]["notify_new"].." \124r"..select(1,...),1,255)
return false,sts_last_msgtext,select(2,...),select(3,...),select(4,...),select(5,...),select(6,...),select(7,...),select(8,...),select(9,...),select(10,...),select(11,...),select(12,...)
else
sts_last_action = 1
return true
end
else
--debug w/: sts_last_msgtext = strsub("<"..spamfound.."> "..sp.." "..select(1,...),1,255)
sts_last_action = 0
return false,...
--debug w/: return false,sts_last_msgtext,select(2,...),select(3,...),select(4,...),select(5,...),select(6,...),select(7,...),select(8,...),select(9,...),select(10,...),select(11,...),select(12,...)
end
end
sts_last_action = 0
return false,...
elseif tign_notify[event] and STS_SV["ignore"][tignlist][select(2,...)] then
return false, sts_notify..STS_SV["settings"]["notify_tign"].."\124r "..select(1,...),select(2,...),select(3,...),select(4,...),select(5,...),select(6,...),select(7,...),select(8,...),select(9,...),select(10,...),select(11,...),select(12,...)
elseif tign_filterthis[event] and STS_SV["ignore"][tignlist][select(2,...)] then
220,11 → 244,11
end
STS_SV["deDE"] = {
["whitelist"] = {"%d+% ?[Gg] ","%d+% ?[Gg]$","[Zz]ahle","[Pp]reis","[Rr]ezept","[Pp]l[äa]ne?"," AH","ingi","[Vv][Kk] "," [Tt]g","[Ss]tack","[Mm]ats","Hitem:","Henchant:","Htrade:","[Ww][Tt][Bb]","[Ss]chenk"},
["blacklist"] = {"www%..+%.de","%.com$","%.cn$","[Aa]rena","[235]% ?[vo]n?% ?[235]","priest","[Aa][Kk]% ?[12][05]","[Pp][Dd][Oo]?[Kk]","Onyx?i?a? ","[Oo]nyx?i?a?% ?[12][05]","[Uu]lduar"," 10/25"," 10er"," 25er","youtube","farmrun","[Gg]ilde","Hquest:245%d%d:83","[Ii][Cc][Cc]","[Aa]rcha","[Hh]eroic"," [Hh]eros? ","[Hh]eros?$","[Ww]eekly","[Dd]aily","[Gg]earcheck","[Nn]axx","DD[ s]"," dd","dds ","[Hh]eiler","[Hh]eal ","[Tt]ank ","[Dd][Pp][Ss]","[Gg][Rr][Pp] ","such.+gru?p?pe?","[Ss]tammgru?p?pe?","[Bb][Gg] ?[Ss]tamm"," [Rr]aid","[Gg]earscore","[Cc]huck "," [Nn]orris"},
["blacklist"] = {"www%..+%.de","%.com$","%.cn$","[Aa]rena","[235]% ?[vo][sn]?% ?[235]","priest","[Aa][Kk]% ?[12][05]","[Pp][Dd][Oo]?[Kk]","Onyx?i?a? ","[Oo]nyx?i?a?% ?[12][05]","[Uu]lduar"," 10/25"," 10er"," 25er","youtube","farmrun","[Gg]ilde","Hquest:245%d%d:8","[Ii][Cc][Cc]","[Aa]rcha","[Hh]eroic"," [Hh]eros? ","[Hh]eros?$","[Ww]eekly","[Dd]aily","[Gg]earcheck","[Nn]axx","DD[ s]"," dd","dds ","[Hh]eiler","[Hh]eal ","[Tt]ank ","[Dd][Pp][Ss]","[Gg][Rr][Pp] ","such.+gru?p?pe?","[Ss]tammgru?p?pe?","[Bb][Gg] ?[Ss]tamm"," [Rr]aid","[Gg]earscore","[Cc]huck "," [Nn]orris"},
}
STS_SV["enUS"] = {
["whitelist"] = {"[Pp]ay","[Pp]rice","^[Ww][Tt][SsBb]","[Oo]ffer","[Rr]ecipe","%d+% ?[Gg] ","%d+% ?[Gg]$","[Ss]tack","[Ss]ell","[Ll][Ff][Ww]","[Mm]ats","[Ff]ee","Hitem:","Henchant:","Htrade:", },
["blacklist"] = {"[Aa]rena","[Ii][Cc][Cc]","Hquest:245%d%d:83","^[Ll][Ff]%d?[RrGgMm]","[Tt]ank","[Hh]ealer","10/25","guild","recruit"," [Rr]aid","^[Ll][Ff][GgMm% ].+quest","rep% ?farm","[Gg]ear% ?[Ii]nspect","[Gg]ear% ?[Ss]core","[Ww]eekly","[Dd]aily","[Ll][Ff]%d?[GgRrMm] .+[12][05]","[Dd][Pp][Ss] ","http://","%.cn$","[Vv][Oo][Aa]% ?[12][05]","[Tt][Oo]?[Gg]?[Cc]% ?[12][05]", },
["blacklist"] = {"[Aa]rena","[Ii][Cc][Cc]","Hquest:245%d%d:8","^[Ll][Ff]%d?[RrGgMm]","[Tt]ank","[Hh]ealer","10/25","guild","recruit"," [Rr]aid","^[Ll][Ff][GgMm% ].+quest","rep% ?farm","[Gg]ear% ?[Ii]nspect","[Gg]ear% ?[Ss]core","[Ww]eekly","[Dd]aily","[Ll][Ff]%d?[GgRrMm] .+[12][05]","[Dd][Pp][Ss] ","http://","%.cn$","[Vv][Oo][Aa]% ?[12][05]","[Tt][Oo]?[Gg]?[Cc]% ?[12][05]", },
}
STS_SV["settings"] = {
["showblack"] = true,
234,6 → 258,7
["b"] = 1.0,
["notify_new"] = "<is now T-ignored>",
["notify_tign"] = "<tign>",
["CHAT_MSG_CHANNEL"] = {true, true, true, true, true, true, true, true, true, true},
}
if not STS_SV["ignore"] then
STS_SV["ignore"] = { }
244,17 → 269,16
end
 
function STS_Update(oldv)
sts_quiet = 100
if oldv <= 6.1 then
STS_InitSV()
end
if oldv <= 6.2 then
sts_quiet = 4
if not STS_Find("[Pp]l[äa]ne?","white") then STS_Add("[Pp]l[äa]ne?","white") end
if STS_Find("[Tt][Tt]?[Gg]?[Oo][Cc]% ?[12][05]","black") then
STS_SV["enUS"]["blacklist"][STS_Find("[Tt][Tt]?[Gg]?[Oo][Cc]% ?[12][05]","black")]="[Tt][Oo]?[Gg]?[Cc]% ?[12][05]"
end
STS_SV["settings"]["showblack"] = true
sts_quiet = 0
end
if oldv <= 6.5 then
STS_SV["settings"]["notify_new"] = "<is now T-ignored>"
276,6 → 300,21
end
end
end
if oldv <= 6.7 then
if STS_SV["language"][tignlist] == "deDE" then
if STS_Find("%d+% ?[Gg] ","white") then
STS_SV["deDE"]["whitelist"][STS_Find("%d+% ?[Gg] ","white")]="%d+% ?[Gg]o?l?[d ]"
end
if STS_Find("[235]% ?[vo]n?% ?[235]","black") then
STS_SV["deDE"]["blacklist"][STS_Find("[235]% ?[vo]n?% ?[235]","black")]="[235]% ?[vo][sn]?% ?[235]"
end
end
if STS_Find("Hquest:245%d%d:83","black") then
STS_SV[STS_SV["language"][tignlist]]["blacklist"][STS_Find("Hquest:245%d%d:83","black")]="Hquest:245%d%d:8"
end
end
STS_SV["settings"]["CHAT_MSG_CHANNEL"] = {true, true, true, true, true, true, true, true, true, true}
sts_quiet = 0
return version
end
 
283,7 → 322,7
if not STS_SV[setlang] then
STS_SV[setlang] = {
whitelist = { "Hitem:","Hspell:","Henchant:","Htrade:", },
blacklist = { "Hquest:245%d%d:83" },
blacklist = { "Hquest:245%d%d:8" },
}
dcfa("New language \""..setlang.."\" created.")
else
467,6 → 506,29
 
function STS_Settings(...)
--TODO: Interface for Options Frame
local ret
if select(1,...) == "GET" then
if select('#',...) == 2 then
if STS_SV["settings"][select(2,...)] then
return STS_SV["settings"][select(2,...)]
else
return nil
end
elseif select('#',...) == 3 then
if STS_SV["settings"][select(2,...)][select(3,...)] then
return STS_SV["settings"][select(2,...)][select(3,...)]
else
return nil
end
end
elseif select(1,...) == "SET" then
if select('#',...) <= 3 then
STS_SV["settings"][select(2,...)] = select(3,...)
elseif select('#',...) == 4 then --deeper in Table!
STS_SV["settings"][select(2,...)][select(3,...)] = select(4,...)
end
end
return false,1
end
 
function STS_GetNumIgnore()
511,6 → 573,7
f:UnregisterEvent("ADDON_LOADED")
f:RegisterEvent("PARTY_INVITE_REQUEST")
f:RegisterEvent("CHAT_MSG_ADDON")
if STS_SV["debug"] then f:RegisterEvent("WHO_LIST_UPDATE") end
ChatFrame_AddMessageEventFilter("CHAT_MSG_CHANNEL", STS_ChatFilter)
for event, filterf in pairs(tign_notify) do
ChatFrame_AddMessageEventFilter(event, filterf)
522,5 → 585,12
if strsub(select(1,...),4,12) == "_?Version" then
SendAddonMessage("STS_!Version",GetAddOnMetadata("StopTradeSpam","Version"),"WHISPER",select(4,...))
end
elseif event == "WHO_LIST_UPDATE" then
for i=1,GetNumWhoResults() do
local charname, guildname, level, race, class, zone, classFileName = GetWhoInfo(i)
if STS_SV["ignore"][tignlist][charname] and level < 80 then
print("["..level.."] "..STS_SV["ignore"][tignlist][charname]["reason"])
end
end
end
end)