/
TurtleHCFilter.lua
executable file
·115 lines (107 loc) · 3.09 KB
/
TurtleHCFilter.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
if HCFFrame == nil then HCFFrame = 1 end
if HCFPrefix == nil then HCFPrefix = "HC" end
if HCFColour == nil then HCFColour = "e6cd80" end
TurtleHCFilter_ChatFrame_OnEvent = ChatFrame_OnEvent
HCFSpam = ''
function ChatFrame_OnEvent(event)
if (event == "CHAT_MSG_HARDCORE") then
if HCFSpam == arg1 then
return false
end
--SuperIgnore support
if IsAddOnLoaded("SuperIgnore") then
if SI_BannedGetIndex(arg2) then
TurtleHCFilter_ChatFrame_OnEvent(event)
return
end
end
local prefix
if HCFPrefix == nil then
prefix = ""
else
prefix = "["..HCFPrefix.."] "
end
local msg = string.gsub(arg1, "|r", "|r|cff"..HCFColour)
local output = "|cff"..HCFColour..prefix.."|cff"..HCFColour.."\124Hplayer:"..arg2.."\124h["..arg2.."]\124h\124r|cff"..HCFColour.." "..msg
if HCFFrame == 1 then
ChatFrame1:AddMessage(output)
elseif HCFFrame == 2 then
ChatFrame2:AddMessage(output)
elseif HCFFrame == 3 then
ChatFrame3:AddMessage(output)
elseif HCFFrame == 4 then
ChatFrame4:AddMessage(output)
elseif HCFFrame == 5 then
ChatFrame5:AddMessage(output)
elseif HCFFrame == 6 then
ChatFrame6:AddMessage(output)
elseif HCFFrame == 7 then
ChatFrame7:AddMessage(output)
elseif HCFFrame == 8 then
ChatFrame8:AddMessage(output)
elseif HCFFrame == 9 then
ChatFrame9:AddMessage(output)
end
HCFSpam = arg1
return false
end
TurtleHCFilter_ChatFrame_OnEvent(event);
end
function Error(message)
DEFAULT_CHAT_FRAME:AddMessage("|cffbe5effHCF|cffff0000 "..message)
end
function Message(message)
DEFAULT_CHAT_FRAME:AddMessage("|cffbe5effHCF|r "..message)
end
function SetFrame(frameString)
local frame = tonumber(frameString)
if frame == nil then
Error("Not a number: "..(frameString or "nil"))
else
HCFFrame = frame
Message("Frame set to: "..HCFFrame)
end
end
SLASH_TurtleHCFilter1, SLASH_TurtleHCFilter2 = "/HCF", "/HCFilter"
SlashCmdList["TurtleHCFilter"] = function(message)
local gfind = string.gmatch or string.gfind
local frame = tonumber(message)
if frame == nil then
local commandlist = { }
local command
for command in gfind(message, "[^ ]+") do
table.insert(commandlist, command)
end
if commandlist[1] == nil then
Error("No command provided: "..message)
return
end
if commandlist[1] == "frame" then
if commandlist[2] == nil then
Error("No argument provided for command: "..message)
return
end
SetFrame(commandlist[2])
elseif commandlist[1] == "prefix" then
HCFPrefix = commandlist[2]
if commandlist[2] == nil then
Message("Channel prefix set to nothing")
else
Message("Channel prefix set to: "..HCFPrefix)
end
elseif commandlist[1] == "colour" or commandlist[1] == "color" then
if commandlist[2] == nil then
Message("Channel prefix set to the default: |cffe6cd80e6cd80")
HCFColour = "e6cd80"
else
HCFColour = commandlist[2]
Message("Channel prefix set to: "..HCFColour)
end
else
Error("Invalid command: "..message)
return
end
else
SetFrame(frame)
end
end