/trunk
sts_notify = "" |
sts_quiet = 0 |
tignlist = "" |
-- DEBUG: LDB testing |
LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("StopTradeSpam", { |
type = "launcher", |
icon = "Interface\\Icons\\Spell_Nature_StormReach", |
OnClick = function(clickedframe, button) |
print(clickedframe, button) |
STS_Options() |
end, |
}) |
sts_numignore = -1 |
-- Events where author is ignored, but msg should not be filtered out (only notify) |
tign_notify = { |
["CHAT_MSG_BATTLEGROUND"] = STS_ChatFilter, |
["CHAT_MSG_BATTLEGROUND"] = STS_ChatFilter, |
["CHAT_MSG_BATTLEGROUND_LEADER"] = STS_ChatFilter, |
["CHAT_MSG_GUILD"] = STS_ChatFilter, --TODO: Maybe unignore if this is seen. |
["CHAT_MSG_OFFICER"] = STS_ChatFilter, --TODO: Same as guild? |
["CHAT_MSG_PARTY"] = STS_ChatFilter, |
["CHAT_MSG_PARTY_LEADER"] = STS_ChatFilter, |
["CHAT_MSG_RAID"] = STS_ChatFilter, |
["CHAT_MSG_RAID_LEADER"] = STS_ChatFilter, |
["CHAT_MSG_RAID_WARNING"] = STS_ChatFilter, |
["CHAT_MSG_SAY"] = STS_ChatFilter, |
["CHAT_MSG_WHISPER"] = STS_ChatFilter, |
["CHAT_MSG_WHISPER_INFORM"] = STS_ChatFilter, |
["CHAT_MSG_BATTLEGROUND"] = true, |
["CHAT_MSG_BATTLEGROUND"] = true, |
["CHAT_MSG_BATTLEGROUND_LEADER"] = true, |
["CHAT_MSG_GUILD"] = true, --TODO: Maybe unignore if this is seen. |
["CHAT_MSG_OFFICER"] = true, --TODO: Same as guild? |
["CHAT_MSG_PARTY"] = true, |
["CHAT_MSG_PARTY_LEADER"] = true, |
["CHAT_MSG_RAID"] = true, |
["CHAT_MSG_RAID_LEADER"] = true, |
["CHAT_MSG_RAID_WARNING"] = true, |
["CHAT_MSG_SAY"] = true, |
["CHAT_MSG_WHISPER"] = true, |
["CHAT_MSG_WHISPER_INFORM"] = true, |
} |
--Events where author is ignored and should be filtered |
tign_filterthis = { |
["CHAT_MSG_CHANNEL_JOIN"] = STS_ChatFilter, |
["CHAT_MSG_CHANNEL_LEAVE"] = STS_ChatFilter, |
["CHAT_MSG_EMOTE"] = STS_ChatFilter, |
["CHAT_MSG_GUILD_ACHIEVEMENT"] = STS_ChatFilter, |
["CHAT_MSG_TEXT_EMOTE"] = STS_ChatFilter, |
["CHAT_MSG_YELL"] = STS_ChatFilter, |
["CHAT_MSG_CHANNEL_JOIN"] = true, |
["CHAT_MSG_CHANNEL_LEAVE"] = true, |
["CHAT_MSG_EMOTE"] = true, |
["CHAT_MSG_GUILD_ACHIEVEMENT"] = true, |
["CHAT_MSG_TEXT_EMOTE"] = true, |
["CHAT_MSG_YELL"] = true, |
} |
function dcfa(...) |
-- TODO: Maybe replace all "dcfa(" with "DEFAULT_CHAT_FRAME:AddMessage(" and remove this function |
end |
function STS_Slash(argument) |
local STScommand = { strsplit(" ", argument) } |
if STScommand[1] == "help" or argument == "" then |
dcfa("\124cffff0000S\124cff00ff00top \124cffff0000T\124cff00ff00rade \124cffff0000S\124cff00ff00pam") |
dcfa("StopTradeSpam will, based on your whitelist and blacklist automatically try to ignore players, who are looking for groups/raids/... in trade channel.") |
dcfa("Maybe in a future version it will Report Spam to gamemasters, but thats a bad idea with unreliable filtering.") |
dcfa("\124cff00ff00List of usable commands:") |
dcfa("\124cffff0000/sts list <white/black/ignore> \124cff00ff00Lists all entrys of the specified list.") |
dcfa("\124cffff0000/sts find <white/black/ignore> <entry> \124cff00ff00Looks for an entry which is exactly <entry> in the specified list. If no list is specified it will search the T-ignorelist.") |
dcfa("\124cffff0000/sts ignore <name> [<reason>] \124cff00ff00T-ignores someone, with reason, if given.") |
dcfa("\124cffff0000/sts unignore <name> \124cff00ff00Removes someone from your T-ignore list.") |
dcfa("\124cffff0000/sts add <white/black> <pattern> \124cff00ff00Used to add a new filter pattern to the specifeid list.") |
dcfa("\124cffff0000/sts del <white/black> <pattern/numberOfPattern> \124cff00ff00Used to delete a filter pattern from a specified list. Use \"/sts list <white/black>\" to find the number of a specific pattern.") |
dcfa("\124cffff0000/sts language set/del <lang> \124cff00ff00possible options are \"enUS\" (english), \"deDE\" (german) or any other (a few default filters will be set)") |
dcfa("\124cffff0000/sts statistic \124cff00ff00Prints a short session statistic") |
dcfa("\124cffff0000/sts post <name> \124cff00ff00Whispers the reason and the time of his T-ignore to the character <name>.") |
dcfa("\124cffff0000/sts party \124cff00ff00Lists all party members who are on your T-ignorelist.") |
dcfa("\124cffff0000/sts raid \124cff00ff00Lists all raid members who are on your T-ignorelist.") |
dcfa("\124cffff0000/sts version \124cff00ff00Shows the current version number.") |
dcfa("\124cffff0000/sts options \124cff00ff00Not yet working.") |
dcfa("\124cffff0000/sts reset \124cff00ff00Reset language setting, language filters and T-ignorelist to default") |
elseif STScommand[1] == "reset" then |
STS_ResetSV() |
STS_InitSV() |
elseif STScommand[1] == "list" then |
STS_List(STScommand[2]) |
elseif STScommand[1] == "find" then |
if STScommand[3] then |
STS_Find(STScommand[3], STScommand[2]) |
elseif STScommand[2] then |
STS_Find(STScommand[2], "ignore") |
else |
STS_Find(select(1,UnitName("target")), "ignore") |
end |
elseif STScommand[1] == "add" then |
STS_Add(strsub(argument, 2 + select(2, strfind(argument, STScommand[2], 1))), STScommand[2]) |
elseif STScommand[1] == "del" or STScommand[1] == "remove" then |
STS_Remove(strsub(argument, 2 + select(2, strfind(argument, STScommand[2], 1))), STScommand[2]) |
elseif STScommand[1] == "ignore" then |
if STScommand[3] then |
STS_AddIgnore(STScommand[2], strsub(argument, 9 + strlen(STScommand[2]))) |
else |
STS_AddIgnore(STScommand[2], nil) |
end |
elseif STScommand[1] == "unignore" or STScommand[1] == "delignore" then |
STS_DelIgnore(STScommand[2]) |
elseif (STScommand[1] == "lang" or STScommand[1] == "language") and STScommand[2] == "set" then |
STS_SetLanguage(STScommand[3]) |
elseif (STScommand[1] == "lang" or STScommand[1] == "language") and (STScommand[2] == "del" or STScommand[2] == "remove") then |
STS_DelLanguage(STScommand[3]) |
elseif STScommand[1] == "stat" or STScommand[1] == "statistic" then |
STS_Statistic(true) |
elseif STScommand[1] == "post" then |
if STScommand[2] then |
STS_PostReason(STScommand[2]) |
else |
STS_PostReason(select(1,UnitName("target"))) |
end |
elseif STScommand[1] == "party" then |
STS_Find("party","ignore") |
elseif STScommand[1] == "raid" then |
STS_Find("raid","ignore") |
elseif STScommand[1] == "version" then |
if STScommand[2] then |
SendAddonMessage("STS_?Version",GetAddOnMetadata("StopTradeSpam","Version"),"WHISPER",STScommand[2]) |
end |
dcfa(GetAddOnMetadata("StopTradeSpam","Version")) |
elseif STScommand[1] == "options" or STScommand[1] == "o" then |
STS_Options() |
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(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 |
return true |
elseif sts_last_action == 0 then |
return false,... |
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 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 - 2 --TODO: evaluate numbers |
-- sp = sp..wle.." # " --debug |
--debug/deprecated break -- TODO: point system? don't break in that case |
end |
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 |
sts_quiet = 1 |
STS_AddIgnore(select(2,...), "STS: ["..select(4,...).."] "..STS_ColoredNameLink(...)..": "..msg) |
sts_session_filtered = sts_session_filtered + 1 |
if STS_SV["settings"]["complainchat"] and spamfound > 2 then |
ComplainChat(select(11,...)) |
-- dcfa(select(2,...).." reported") |
end |
if STS_SV["settings"]["showblack"] then |
sts_last_action = -1 |
--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 |
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 |
return true |
else |
return false,... |
end |
end |
function STS_ResetSV(...) -- reset anything except ignorelist |
if not STS_SV then |
return false |
return true |
end |
function STS_InitSV() |
if not STS_SV then |
STS_SV = { } |
end |
if not STS_SV["language"] then |
STS_SV["language"] = { |
[tignlist] = GetLocale() |
} |
elseif not STS_SV["language"][tignlist] then |
STS_SV["language"][tignlist] = GetLocale() |
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][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: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, |
["enabletign"] = true, |
["r"] = 1.0, |
["g"] = 1.0, |
["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"] = { } |
if not STS_SV["ignore"][tignlist] then |
STS_SV["ignore"][tignlist] = { } |
end |
end |
end |
function STS_Update(oldv) |
sts_quiet = 100 |
if oldv <= 6.1 then |
STS_InitSV() |
end |
if oldv <= 6.2 then |
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 |
end |
if oldv <= 6.5 then |
STS_SV["settings"]["notify_new"] = "<is now T-ignored>" |
STS_SV["settings"]["notify_tign"] = "<tign>" |
end |
if oldv <= 6.6 then |
if STS_SV["language"][tignlist] == "deDE" then |
if STS_Find("DD","black") then |
STS_SV["deDE"]["blacklist"][STS_Find("DD","black")]="DD[ s]" |
end |
if not STS_Find("[Cc]huck ","black") then |
STS_Add("[Cc]huck ","black") |
end |
if not STS_Find(" [Nn]orris","black") then |
STS_Add(" [Nn]orris","black") |
end |
if not STS_Find("[Ss]chenk","white") then |
STS_Add("[Ss]chenk","white") |
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 |
STS_SV["settings"]["CHAT_MSG_CHANNEL"] = {true, true, true, true, true, true, true, true, true, true} |
end |
if oldv <= 6.8 then |
STS_SV["settings"]["complainchat"] = true |
end |
sts_quiet = 0 |
return version |
end |
function STS_SetLanguage(setlang) |
if not STS_SV[setlang] then |
STS_SV[setlang] = { |
else |
dcfa(ign_name.." is now T-ignored. Reason: "..ign_reason) |
end |
sts_numignore = sts_numignore + 1 |
return true |
else |
dcfa("Character is already ignored. Use \"/sts unignore "..ign_name.."\" to remove him from T-ignorelist.") |
if STS_SV["ignore"][tignlist][ign_name] then |
STS_SV["ignore"][tignlist][ign_name] = nil |
dcfa(ign_name.." is no longer T-ignored.") |
sts_numignore = sts_numignore - 1 |
return true |
else |
dcfa("Character "..ign_name.." not found on T-ignorelist.") |
function STS_Statistic(...) |
if select(1,...) == true then |
dcfa("Trade messages filtered this session: "..sts_session_filtered.." of "..sts_session_all..". There are "..STS_GetNumIgnore().." characters on your T-ignorelist.") |
dcfa("Trade messages filtered this session: "..sts_session_filtered.." of "..sts_session_all..". There are "..sts_numignore.." characters on your T-ignorelist.") |
end |
return sts_session_filtered,sts_session_all |
end |
end |
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 |
else |
return nil |
end |
elseif select('#',...) == 3 then |
elseif select('#',...) == 3 then --deeper in Table! |
if STS_SV["settings"][select(2,...)][select(3,...)] then |
return STS_SV["settings"][select(2,...)][select(3,...)] |
else |
return false,1 |
end |
function STS_GetNumIgnore() |
local num = 0 |
for _,_ in pairs(STS_SV["ignore"][tignlist]) do |
num = num + 1 |
function STS_Slash(argument) |
local STScommand = { strsplit(" ", argument) } |
if STScommand[1] == "help" or argument == "" then |
dcfa("\124cffff0000S\124cff00ff00top \124cffff0000T\124cff00ff00rade \124cffff0000S\124cff00ff00pam") |
dcfa("StopTradeSpam will, based on your whitelist and blacklist automatically try to ignore players, who are looking for groups/raids/... in trade channel.") |
dcfa("Maybe in a future version it will Report Spam to gamemasters, but thats a bad idea with unreliable filtering.") |
dcfa("\124cff00ff00List of usable commands:") |
dcfa("\124cffff0000/sts list <white/black/ignore> \124cff00ff00Lists all entrys of the specified list.") |
dcfa("\124cffff0000/sts find <white/black/ignore> <entry> \124cff00ff00Looks for an entry which is exactly <entry> in the specified list. If no list is specified it will search the T-ignorelist.") |
dcfa("\124cffff0000/sts ignore <name> [<reason>] \124cff00ff00T-ignores someone, with reason, if given.") |
dcfa("\124cffff0000/sts unignore <name> \124cff00ff00Removes someone from your T-ignore list.") |
dcfa("\124cffff0000/sts add <white/black> <pattern> \124cff00ff00Used to add a new filter pattern to the specifeid list.") |
dcfa("\124cffff0000/sts del <white/black> <pattern/numberOfPattern> \124cff00ff00Used to delete a filter pattern from a specified list. Use \"/sts list <white/black>\" to find the number of a specific pattern.") |
dcfa("\124cffff0000/sts language set/del <lang> \124cff00ff00possible options are \"enUS\" (english), \"deDE\" (german) or any other (a few default filters will be set)") |
dcfa("\124cffff0000/sts statistic \124cff00ff00Prints a short session statistic") |
dcfa("\124cffff0000/sts post <name> \124cff00ff00Whispers the reason and the time of his T-ignore to the character <name>.") |
dcfa("\124cffff0000/sts party \124cff00ff00Lists all party members who are on your T-ignorelist.") |
dcfa("\124cffff0000/sts raid \124cff00ff00Lists all raid members who are on your T-ignorelist.") |
dcfa("\124cffff0000/sts version \124cff00ff00Shows the current version number.") |
dcfa("\124cffff0000/sts options \124cff00ff00Not yet working.") |
dcfa("\124cffff0000/sts reset \124cff00ff00Reset language setting, language filters and T-ignorelist to default") |
elseif STScommand[1] == "reset" then |
STS_ResetSV() |
STS_InitSV() |
elseif STScommand[1] == "list" then |
STS_List(STScommand[2]) |
elseif STScommand[1] == "find" then |
if STScommand[3] then |
STS_Find(STScommand[3], STScommand[2]) |
elseif STScommand[2] then |
STS_Find(STScommand[2], "ignore") |
else |
STS_Find(select(1,UnitName("target")), "ignore") |
end |
elseif STScommand[1] == "add" then |
STS_Add(strsub(argument, 2 + select(2, strfind(argument, STScommand[2], 1))), STScommand[2]) |
elseif STScommand[1] == "del" or STScommand[1] == "remove" then |
STS_Remove(strsub(argument, 2 + select(2, strfind(argument, STScommand[2], 1))), STScommand[2]) |
elseif STScommand[1] == "ignore" then |
if STScommand[3] then |
STS_AddIgnore(STScommand[2], strsub(argument, 9 + strlen(STScommand[2]))) |
else |
STS_AddIgnore(STScommand[2], nil) |
end |
elseif STScommand[1] == "unignore" or STScommand[1] == "delignore" then |
STS_DelIgnore(STScommand[2]) |
elseif (STScommand[1] == "lang" or STScommand[1] == "language") and STScommand[2] == "set" then |
STS_SetLanguage(STScommand[3]) |
elseif (STScommand[1] == "lang" or STScommand[1] == "language") and (STScommand[2] == "del" or STScommand[2] == "remove") then |
STS_DelLanguage(STScommand[3]) |
elseif STScommand[1] == "stat" or STScommand[1] == "statistic" then |
STS_Statistic(true) |
elseif STScommand[1] == "post" then |
if STScommand[2] then |
STS_PostReason(STScommand[2]) |
else |
STS_PostReason(select(1,UnitName("target"))) |
end |
elseif STScommand[1] == "party" then |
STS_Find("party","ignore") |
elseif STScommand[1] == "raid" then |
STS_Find("raid","ignore") |
elseif STScommand[1] == "version" then |
if STScommand[2] then |
SendAddonMessage("STS_?Version",GetAddOnMetadata("StopTradeSpam","Version"),"WHISPER",STScommand[2]) |
end |
dcfa(GetAddOnMetadata("StopTradeSpam","Version")) |
elseif STScommand[1] == "options" or STScommand[1] == "o" then |
STS_Options() |
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 |
return num |
end |
local function STS_ChatFilter(self, event, ...) |
if sts_last_msg == select(11,...) then |
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_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(2,...) == UnitName("player")) or (select(2,...) == "") or (select(6,...) == "GM") then |
sts_last_action = 0 |
return false,... |
elseif event == "CHAT_MSG_CHANNEL" then |
if select(7,...) == 2 then sts_session_all = sts_session_all + 1 end |
if STS_SV["ignore"][tignlist][select(2,...)] then |
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 - 2 --TODO: evaluate numbers |
--sp = sp..wle.." # " --debug |
end |
end |
for _,ble in pairs(STS_SV[sts_lang]["blacklist"]) do |
if strfind(msg, ble) then |
spamfound = spamfound + 1 |
--sp = sp..ble.." # " --debug |
end |
end |
--sp = sp.."# #" --debug |
if spamfound > 0 then |
-- Ignore author of spam message here |
sts_quiet = 1 |
STS_AddIgnore(select(2,...), "STS: ["..select(4,...).."] "..STS_ColoredNameLink(...)..": "..msg) |
sts_session_filtered = sts_session_filtered + 1 |
if STS_SV["settings"]["complainchat"] and spamfound > 2 then |
ComplainChat(select(11,...)) |
--dcfa(select(2,...).." reported") |
end |
if STS_SV["settings"]["showblack"] then |
sts_last_action = -1 |
--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 |
elseif tign_notify[event] and STS_SV["ignore"][tignlist][select(2,...)] then |
sts_last_action = -1 |
sts_last_msgtext = strsub(sts_notify..STS_SV["settings"]["notify_tign"].."\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,...) |
elseif tign_filterthis[event] and STS_SV["ignore"][tignlist][select(2,...)] then |
sts_last_action = 1 |
return true |
else |
sts_last_action = 0 |
return false,... |
end |
end |
SlashCmdList["StopTradeSpam_SlashCommand"] = STS_Slash |
SLASH_StopTradeSpam_SlashCommand1 = "/sts" |
f:RegisterEvent("ADDON_LOADED") |
if not STS_SV["language"][GetRealmName().."-"..UnitFactionGroup("player")] then |
STS_SV["language"][GetRealmName().."-"..UnitFactionGroup("player")] = GetLocale() |
end |
if sts_numignore < 0 then |
sts_numignore = 0 |
for _,_ in pairs(STS_SV["ignore"][tignlist]) do |
sts_numignore = sts_numignore + 1 |
end |
end |
sts_notify = "\124cff"..("%.2x%.2x%.2x"):format(STS_SV["settings"]["r"]*255,STS_SV["settings"]["g"]*255,STS_SV["settings"]["b"]*255) |
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) |
for event,_ in pairs(tign_notify) do |
ChatFrame_AddMessageEventFilter(event, STS_ChatFilter) |
end |
for event, filterf in pairs(tign_filterthis) do |
ChatFrame_AddMessageEventFilter(event, filterf) |
for event,_ in pairs(tign_filterthis) do |
ChatFrame_AddMessageEventFilter(event, STS_ChatFilter) |
end |
elseif event == "CHAT_MSG_ADDON" and strsub(select(1,...),1,3) == "STS" then |
if strsub(select(1,...),4,12) == "_?Version" then |
end |
end |
end) |
-- DEBUG: LDB testing |
LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("StopTradeSpam", { |
type = "launcher", |
icon = "Interface\\Icons\\Spell_Nature_StormReach", |
OnClick = function(clickedframe, button) |
print(clickedframe, button) |
STS_Options() |
end, |
}) |
libs\LibStub\LibStub.lua |
libs\CallbackHandler-1.0\CallbackHandler-1.0.lua |
libs\LibDataBroker-1.1\LibDataBroker-1.1.lua |
StopTradeSpam.lua |