Code format

This commit is contained in:
2025-05-15 20:37:50 +02:00
parent 9e6432d0b0
commit 69d1f9fd93
105 changed files with 24069 additions and 28084 deletions

View File

@@ -29,18 +29,18 @@ SlashCmdList["FREMOVE"] = cleanse
SLASH_FUPDATE1 = "/fupdate"
SLASH_FUPDATE2 = "/fu"
SlashCmdList["FUPDATE"] = function(msg)
cleanse()
add()
cleanse()
add()
end
local chatEvents = {
"CHAT_MSG_SAY",
"CHAT_MSG_RAID",
"CHAT_MSG_YELL",
"CHAT_MSG_PARTY",
"CHAT_MSG_GUILD",
"CHAT_MSG_WHISPER",
"CHAT_MSG_CHANNEL",
"CHAT_MSG_SAY",
"CHAT_MSG_RAID",
"CHAT_MSG_YELL",
"CHAT_MSG_PARTY",
"CHAT_MSG_GUILD",
"CHAT_MSG_WHISPER",
"CHAT_MSG_CHANNEL",
}
if not ChatFilter then ChatFilter = {} end
@@ -51,85 +51,92 @@ if not ChatFilter.RemovedCommon then ChatFilter.RemovedCommon = {} end
--Own filter
local function myChatFilter(self, e, msg, author, lang)
print(msg, author, lang)
print(msg, author, lang)
local function getDate()
local date = date()
local year = date:match("%d%d%/%d%d/(%d%d)") + 2000 --01/07/(19) 14:36:42
local month = date:match("(%d%d)") --(01)/07/19 14:36:42
local day = date:match("%d%d%/(%d%d)") --01/(07)/19 14:36:42
--Remove first place zeros
if day:find("0") == 1 then
day = day:gsub("0", "")
end
if month:find("0") == 1 then
month = month:gsub("0", "")
end
local localdate = day .. "." .. month .. "." .. year
return localdate
end
local function getTime()
local date = date()
local localtime = date:match("%d%d%/%d%d%/%d%d%s(%d%d%p%d%d%p%d%d)")
return localtime
end
author = author:match("(.+)-")
--Remove Alliance
if lang == "Common" then
-- print("Caught one!")
ChatFilter.RemovedCommon[#ChatFilter.RemovedCommon + 1] = format("\[%s\]\[%s\]%s: %s", getDate(), getTime(), author, msg)
return true
end
--Remove People
for k, v in pairs(ChatFilter.People) do
if author == v then
if e == "CHAT_MSG_WHISPER" and author ~= UnitName("player") then
SendChatMessage(format("Your message \"%s\" has been filtered out because I hate fun", msg), "WHISPER", nil, author)
end
ChatFilter.RemovedLines[#ChatFilter.RemovedLines + 1] = format("\[%s\]\[%s\]%s: %s", getDate(), getTime(), author, msg)
-- print("Caught one!")
return true
end
end
--Remove Words
for k, v in pairs(ChatFilter.Words) do
if msg:match(v) then
if e == "CHAT_MSG_WHISPER" and author ~= UnitName("player") then
SendChatMessage(format("Your message \"%s\" has been filtered out because I hate fun", msg), "WHISPER", nil, author)
end
ChatFilter.RemovedLines[#ChatFilter.RemovedLines + 1] = format("\[%s\]\[%s\]%s: %s", getDate(), getTime(), author, msg)
-- print("Caught one!")
return true
end
end
local function getDate()
local date = date()
local year = date:match("%d%d%/%d%d/(%d%d)") + 2000 --01/07/(19) 14:36:42
local month = date:match("(%d%d)") --(01)/07/19 14:36:42
local day = date:match("%d%d%/(%d%d)") --01/(07)/19 14:36:42
--Remove first place zeros
if day:find("0") == 1 then day = day:gsub("0", "") end
if month:find("0") == 1 then month = month:gsub("0", "") end
local localdate = day .. "." .. month .. "." .. year
return localdate
end
local function getTime()
local date = date()
local localtime = date:match("%d%d%/%d%d%/%d%d%s(%d%d%p%d%d%p%d%d)")
return localtime
end
author = author:match("(.+)-")
--Remove Alliance
if lang == "Common" then
-- print("Caught one!")
ChatFilter.RemovedCommon[#ChatFilter.RemovedCommon + 1] =
format("[%s][%s]%s: %s", getDate(), getTime(), author, msg)
return true
end
--Remove People
for k, v in pairs(ChatFilter.People) do
if author == v then
if e == "CHAT_MSG_WHISPER" and author ~= UnitName("player") then
SendChatMessage(
format('Your message "%s" has been filtered out because I hate fun', msg),
"WHISPER",
nil,
author
)
end
ChatFilter.RemovedLines[#ChatFilter.RemovedLines + 1] =
format("[%s][%s]%s: %s", getDate(), getTime(), author, msg)
-- print("Caught one!")
return true
end
end
--Remove Words
for k, v in pairs(ChatFilter.Words) do
if msg:match(v) then
if e == "CHAT_MSG_WHISPER" and author ~= UnitName("player") then
SendChatMessage(
format('Your message "%s" has been filtered out because I hate fun', msg),
"WHISPER",
nil,
author
)
end
ChatFilter.RemovedLines[#ChatFilter.RemovedLines + 1] =
format("[%s][%s]%s: %s", getDate(), getTime(), author, msg)
-- print("Caught one!")
return true
end
end
end
--Remove all filters
local function cleanse()
for k, v in pairs(chatEvents) do
if ChatFrame_GetMessageEventFilters(v) then
print(v, unpack(ChatFrame_GetMessageEventFilters(v)))
for k2, v2 in pairs(ChatFrame_GetMessageEventFilters(v)) do
ChatFrame_RemoveMessageEventFilter(v, v2)
end
end
print("Done?")
if ChatFrame_GetMessageEventFilters(v) then
print(unpack(ChatFrame_GetMessageEventFilters(v)))
end
print("Got it.")
end
for k, v in pairs(chatEvents) do
if ChatFrame_GetMessageEventFilters(v) then
print(v, unpack(ChatFrame_GetMessageEventFilters(v)))
for k2, v2 in pairs(ChatFrame_GetMessageEventFilters(v)) do
ChatFrame_RemoveMessageEventFilter(v, v2)
end
end
print("Done?")
if ChatFrame_GetMessageEventFilters(v) then print(unpack(ChatFrame_GetMessageEventFilters(v))) end
print("Got it.")
end
end
--Add filter
local function add()
for k, v in pairs(chatEvents) do
print("Adding filter to", v)
ChatFrame_AddMessageEventFilter(v, myChatFilter)
end
for k, v in pairs(chatEvents) do
print("Adding filter to", v)
ChatFrame_AddMessageEventFilter(v, myChatFilter)
end
end