-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcore.lua
More file actions
executable file
·214 lines (190 loc) · 6.55 KB
/
core.lua
File metadata and controls
executable file
·214 lines (190 loc) · 6.55 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
-- "Telepath" addon by tomill
local addon = LibStub("AceAddon-3.0"):NewAddon("Telepath", "LibSink-2.0")
local option_catch = {
type = "group",
name = "Hook message",
args = {
channel = {
order = 1,
type = "multiselect",
name = "Source channel",
desc = "reacts only checked channel.",
values = {
raid = "Raid/Instance",
party = "Party",
guild = "Guild",
officer = "Officer",
say = "Say (for your test)",
ch1 = "/1 General",
ch2 = "/2 Trade",
ch3 = "/3 LocalDefense",
ch4 = "/4 usually LfG",
chx = "Custom channels",
},
set = function(info, k, v) addon.db.profile.channel[k] = v end,
get = function(info, k) return addon.db.profile.channel[k] end,
},
all_messages = {
order = 2,
type = "toggle",
name = "All Messages",
desc = "displays all messages from the selected channels",
width = "full",
set = function(info, v) addon.db.profile.all_messages = v end,
get = function(info) return addon.db.profile.all_messages end,
},
all_messages_hint = {
order = 3,
type = "description",
name = [[
Or messages with the following conditions:
]],
fontSize = "medium",
},
nickname = {
order = 4,
type = "input",
name = "Nickname always highlight",
multiline = true,
set = function(info, v)
addon.db.profile.nickname = v
addon.db.profile.nickname_list = {}
for nick in string.gmatch(v, "%S+") do
addon.db.profile.nickname_list[string.lower(nick)] = true
end
end,
get = function(info) return addon.db.profile.nickname end,
},
nickname_hint = {
order = 5,
type = "description",
name = [[
Tip: Set your raid leader name or no-VC player name.
(1 nickname 1 line)
]],
fontSize = "medium",
},
keyword = {
order = 7,
type = "input",
name = "Keyword list (optional)",
multiline = true,
set = function(info, v)
addon.db.profile.keyword = v
addon.db.profile.keyword_list = {}
for word in string.gmatch(v, "%S+") do
addon.db.profile.keyword_list[string.lower(word)] = true
end
end,
get = function(info) return addon.db.profile.keyword end,
},
keyword_hint = {
order = 8,
type = "description",
name = [[
Tip: set "inc" or "help" or your name.
(1 keyword 1 line)
]],
fontSize = "medium",
},
}
}
function addon:OnInitialize()
local options = {
type = "group",
args = {
catch = {},
output = {},
}
}
options.args.catch = option_catch
options.args.catch.order = 1
options.args.output = self:GetSinkAce3OptionsDataTable()
options.args.output.name = "Output style"
options.args.output.order = 2
self.db = LibStub("AceDB-3.0"):New(self.name .. "DB", {
profile = {
["channel"] = {["raid"] = true},
["all_messages"] = false,
["nickname"] = "",
["nickname_list"] = {},
["keyword"] = "inc\nincoming\nhelp\nsafe",
["keyword_list"] = {["inc"] = true, ["help"] = true},
["sink20OutputSink"] = "RaidWarning",
}
})
local config = LibStub("AceConfig-3.0")
local dialog = LibStub("AceConfigDialog-3.0")
config:RegisterOptionsTable(self.name, options)
dialog:AddToBlizOptions(self.name)
config:RegisterOptionsTable(self.name .. "Profiles", LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db))
dialog:AddToBlizOptions(self.name .. "Profiles", "Profiles", self.name)
self:SetSinkStorage(self.db.profile)
self.latest = ""
end
local function displayMessage(...)
local _, event, msg, fullname, _, _, _, _, _, ch_no = ...
local name = Ambiguate(fullname, "short")
-- channel check
local channels = {
["CHAT_MSG_CHANNEL"] = "chx",
["CHAT_MSG_SAY"] = "say",
["CHAT_MSG_GUILD"] = "guild",
["CHAT_MSG_OFFICER"] = "officer",
["CHAT_MSG_PARTY"] = "party",
["CHAT_MSG_PARTY_LEADER"] = "party",
["CHAT_MSG_RAID"] = "raid",
["CHAT_MSG_RAID_LEADER"] = "raid",
["CHAT_MSG_INSTANCE_CHAT"] = "raid",
["CHAT_MSG_INSTANCE_CHAT_LEADER"] = "raid",
}
local ch_key = channels[event]
if event == "CHAT_MSG_CHANNEL" and ch_no < 5 then
ch_key = "ch" .. ch_no
end
if not addon.db.profile.channel[ ch_key ] then
return
end
local on = false
if (addon.db.profile.nickname ~= "") then
if (addon.db.profile.nickname_list[ string.lower(name) ]) then
on = true
end
end
if (addon.db.profile.keyword ~= "") then
local msg_lc = string.lower(msg)
for word in pairs(addon.db.profile.keyword_list) do
if msg_lc:find(string.lower(word), 1, true) then
on = true
break
end
end
end
if (addon.db.profile.all_messages) then
on = true
end
if (not on) then
return
end
-- ignore same message
local text = string.format("%s: %s", name, msg)
if addon.latest == text then
return
else
addon.latest = text
end
-- then fire
addon:Pour(text, 1, 1, 0, nil, 24, "OUTLINE", false)
end
function addon:OnEnable()
ChatFrame_AddMessageEventFilter("CHAT_MSG_CHANNEL", displayMessage)
ChatFrame_AddMessageEventFilter("CHAT_MSG_SAY", displayMessage) -- for debug
ChatFrame_AddMessageEventFilter("CHAT_MSG_GUILD", displayMessage)
ChatFrame_AddMessageEventFilter("CHAT_MSG_OFFICER", displayMessage)
ChatFrame_AddMessageEventFilter("CHAT_MSG_PARTY", displayMessage)
ChatFrame_AddMessageEventFilter("CHAT_MSG_PARTY_LEADER", displayMessage)
ChatFrame_AddMessageEventFilter("CHAT_MSG_RAID", displayMessage)
ChatFrame_AddMessageEventFilter("CHAT_MSG_RAID_LEADER", displayMessage)
ChatFrame_AddMessageEventFilter("CHAT_MSG_INSTANCE_CHAT", displayMessage)
ChatFrame_AddMessageEventFilter("CHAT_MSG_INSTANCE_CHAT_LEADER", displayMessage)
end