Add chatSniffer localization and configuration UI
This commit is contained in:
@@ -1,391 +1,390 @@
|
|||||||
local _, shared = ...
|
local _, shared = ...
|
||||||
---@cast shared HeimdallShared
|
---@cast shared HeimdallShared
|
||||||
local ModuleName = "Commander"
|
local ModuleName = "Commander"
|
||||||
|
|
||||||
---@class HeimdallCommanderConfig
|
---@class HeimdallCommanderConfig
|
||||||
---@field enabled boolean
|
---@field enabled boolean
|
||||||
---@field debug boolean
|
---@field debug boolean
|
||||||
---@field channels string[]
|
---@field channels string[]
|
||||||
---@field commander string
|
---@field commander string
|
||||||
---@field commands table<string, boolean>
|
---@field commands table<string, boolean>
|
||||||
|
|
||||||
local helpMessages = {
|
local helpMessages = {
|
||||||
ru = {
|
ru = {
|
||||||
"1) who - пишет вам никнеймы текущих врагов и локу.",
|
"1) who - пишет вам никнеймы текущих врагов и локу.",
|
||||||
"2) classes - покажет классы врагов и число.",
|
"2) classes - покажет классы врагов и число.",
|
||||||
"3) howmany - общее число врагов (дурик 4 . огри 2 ) ",
|
"3) howmany - общее число врагов (дурик 4 . огри 2 ) ",
|
||||||
"4) + - атоинвайт в сбор пати и сброса кд.",
|
"4) + - атоинвайт в сбор пати и сброса кд.",
|
||||||
"5) ++ -автоинвайт в пати аликов (если нужен рефрак)",
|
"5) ++ -автоинвайт в пати аликов (если нужен рефрак)",
|
||||||
"6 ) note Никнейм текст - добавление заметки.",
|
"6 ) note Никнейм текст - добавление заметки.",
|
||||||
"7) note Никнейм - посмотреть последние заметки.",
|
"7) note Никнейм - посмотреть последние заметки.",
|
||||||
"8) note Никнейм 5 - посмотреть конкретную заметку.",
|
"8) note Никнейм 5 - посмотреть конкретную заметку.",
|
||||||
"9) note Никнейм 1..5 - посмотреть заметки от 1 до 5",
|
"9) note Никнейм 1..5 - посмотреть заметки от 1 до 5",
|
||||||
"10) note Никнейм delete 1 - удалить заметку номер 1",
|
"10) note Никнейм delete 1 - удалить заметку номер 1",
|
||||||
"11) note Никнейм delete 1..5 - удалить заметки 1 до 5",
|
"11) note Никнейм delete 1..5 - удалить заметки 1 до 5",
|
||||||
},
|
},
|
||||||
en = {
|
en = {
|
||||||
"1) who - reports currently tracked stinkies in orgrimmar and durotar",
|
"1) who - reports currently tracked stinkies in orgrimmar and durotar",
|
||||||
"2) classes - reports stinkies grouped by class",
|
"2) classes - reports stinkies grouped by class",
|
||||||
"3) howmany - reports stinkies grouped by zone",
|
"3) howmany - reports stinkies grouped by zone",
|
||||||
"4) + - automatically invites to group with duel rogue for cd reset",
|
"4) + - automatically invites to group with duel rogue for cd reset",
|
||||||
"5) ++ - automatically invites to alliance group",
|
"5) ++ - automatically invites to alliance group",
|
||||||
"6) note <name> <note> - adds a note for the specified character.",
|
"6) note <name> <note> - adds a note for the specified character.",
|
||||||
"7) note <name> - lists the last N notes for the character.",
|
"7) note <name> - lists the last N notes for the character.",
|
||||||
"8) note <name> i - lists the i-th note for the character.",
|
"8) note <name> i - lists the i-th note for the character.",
|
||||||
"9) note <name> i..j - lists notes from i to j for the character.",
|
"9) note <name> i..j - lists notes from i to j for the character.",
|
||||||
"10) note <name> delete i - deletes the i-th note for the character.",
|
"10) note <name> delete i - deletes the i-th note for the character.",
|
||||||
"11) note <name> delete i..j - deletes notes from i to j for the character.",
|
"11) note <name> delete i..j - deletes notes from i to j for the character.",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
---@class Commander
|
---@class Commander
|
||||||
shared.Commander = {
|
shared.Commander = {
|
||||||
Init = function()
|
Init = function()
|
||||||
---@param text string
|
---@param text string
|
||||||
---@param size number
|
---@param size number
|
||||||
---@return string[]
|
---@return string[]
|
||||||
local function Partition(text, size)
|
local function Partition(text, size)
|
||||||
local words = {}
|
local words = {}
|
||||||
for word in text:gmatch("[^,]+") do
|
for word in text:gmatch("[^,]+") do
|
||||||
words[#words + 1] = word
|
words[#words + 1] = word
|
||||||
end
|
end
|
||||||
|
|
||||||
local ret = {}
|
local ret = {}
|
||||||
local currentChunk = ""
|
local currentChunk = ""
|
||||||
|
|
||||||
for _, word in ipairs(words) do
|
for _, word in ipairs(words) do
|
||||||
if #currentChunk + #word + 1 <= size then
|
if #currentChunk + #word + 1 <= size then
|
||||||
currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word)
|
currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word)
|
||||||
else
|
else
|
||||||
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end
|
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end
|
||||||
currentChunk = word
|
currentChunk = word
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end
|
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
---@param arr table<string, Player>
|
---@param arr table<string, Player>
|
||||||
---@return string[]
|
---@return string[]
|
||||||
local function Count(arr)
|
local function Count(arr)
|
||||||
local ret = {}
|
local ret = {}
|
||||||
for _, player in pairs(arr) do
|
for _, player in pairs(arr) do
|
||||||
if shared.Whoer.ShouldNotifyForZone(player.zone) then ret[player.zone] = (ret[player.zone] or 0) + 1 end
|
if shared.Whoer.ShouldNotifyForZone(player.zone) then ret[player.zone] = (ret[player.zone] or 0) + 1 end
|
||||||
end
|
end
|
||||||
local text = {}
|
local text = {}
|
||||||
for zone, count in pairs(ret) do
|
for zone, count in pairs(ret) do
|
||||||
text[#text + 1] = string.format("%s: %d", zone, count)
|
text[#text + 1] = string.format("%s: %d", zone, count)
|
||||||
end
|
end
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
---@param arr table<string, Player>
|
---@param arr table<string, Player>
|
||||||
---@return string[]
|
---@return string[]
|
||||||
local function CountPartitioned(arr)
|
local function CountPartitioned(arr)
|
||||||
local count = Count(arr)
|
local count = Count(arr)
|
||||||
local text = {}
|
local text = {}
|
||||||
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
|
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
|
||||||
for _, line in pairs(Partition(strjoin(", ", unpack(count)), 200)) do
|
for _, line in pairs(Partition(strjoin(", ", unpack(count)), 200)) do
|
||||||
text[#text + 1] = line
|
text[#text + 1] = line
|
||||||
end
|
end
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
---@param arr table<string, Player>
|
---@param arr table<string, Player>
|
||||||
---@return string[]
|
---@return string[]
|
||||||
local function Who(arr)
|
local function Who(arr)
|
||||||
local ret = {}
|
local ret = {}
|
||||||
for _, player in pairs(arr) do
|
for _, player in pairs(arr) do
|
||||||
if shared.Whoer.ShouldNotifyForZone(player.zone) then
|
if shared.Whoer.ShouldNotifyForZone(player.zone) then
|
||||||
ret[#ret + 1] = string.format(
|
ret[#ret + 1] = string.format(
|
||||||
"%s/%s (%s) %s",
|
"%s/%s (%s) %s",
|
||||||
player.name,
|
player.name,
|
||||||
player.class,
|
player.class,
|
||||||
player.zone,
|
player.zone,
|
||||||
player.stinky and "(!!!!)" or ""
|
player.stinky and "(!!!!)" or ""
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Command result: %s", ModuleName, strjoin(", ", unpack(ret))))
|
print(string.format("[%s] Command result: %s", ModuleName, strjoin(", ", unpack(ret))))
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
---@param arr table<string, Player>
|
---@param arr table<string, Player>
|
||||||
---@return string[]
|
---@return string[]
|
||||||
local function WhoPartitioned(arr)
|
local function WhoPartitioned(arr)
|
||||||
local who = Who(arr)
|
local who = Who(arr)
|
||||||
local text = {}
|
local text = {}
|
||||||
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
|
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
|
||||||
for _, line in pairs(Partition(strjoin(", ", unpack(who)), 200)) do
|
for _, line in pairs(Partition(strjoin(", ", unpack(who)), 200)) do
|
||||||
text[#text + 1] = "who: " .. line
|
text[#text + 1] = "who: " .. line
|
||||||
end
|
end
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
---@param arr table<string, Player>
|
---@param arr table<string, Player>
|
||||||
---@return string[]
|
---@return string[]
|
||||||
local function CountClass(arr)
|
local function CountClass(arr)
|
||||||
local ret = {}
|
local ret = {}
|
||||||
for _, player in pairs(arr) do
|
for _, player in pairs(arr) do
|
||||||
if shared.Whoer.ShouldNotifyForZone(player.zone) then
|
if shared.Whoer.ShouldNotifyForZone(player.zone) then
|
||||||
ret[player.class] = (ret[player.class] or 0) + 1
|
ret[player.class] = (ret[player.class] or 0) + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local text = {}
|
local text = {}
|
||||||
for class, count in pairs(ret) do
|
for class, count in pairs(ret) do
|
||||||
text[#text + 1] = string.format("%s: %d", class, count)
|
text[#text + 1] = string.format("%s: %d", class, count)
|
||||||
end
|
end
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Message text: %s", ModuleName, strjoin(", ", unpack(text))))
|
print(string.format("[%s] Message text: %s", ModuleName, strjoin(", ", unpack(text))))
|
||||||
end
|
end
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
---@param arr table<string, Player>
|
---@param arr table<string, Player>
|
||||||
---@return string[]
|
---@return string[]
|
||||||
local function CountClassPartitioned(arr)
|
local function CountClassPartitioned(arr)
|
||||||
local countClass = CountClass(arr)
|
local countClass = CountClass(arr)
|
||||||
local text = {}
|
local text = {}
|
||||||
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
|
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
|
||||||
for _, line in pairs(Partition(strjoin(", ", unpack(countClass)), 200)) do
|
for _, line in pairs(Partition(strjoin(", ", unpack(countClass)), 200)) do
|
||||||
text[#text + 1] = line
|
text[#text + 1] = line
|
||||||
end
|
end
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
local function CountClassPartitionedStinkies()
|
local function CountClassPartitionedStinkies()
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Executing: CountClassPartitionedStinkies", ModuleName))
|
print(string.format("[%s] Executing: CountClassPartitionedStinkies", ModuleName))
|
||||||
end
|
end
|
||||||
local res = CountClassPartitioned(HeimdallStinkies)
|
local res = CountClassPartitioned(HeimdallStinkies)
|
||||||
if #res == 0 then return { "No stinkies found" } end
|
if #res == 0 then return { "No stinkies found" } end
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
local function WhoPartitionedStinkies()
|
local function WhoPartitionedStinkies()
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName))
|
print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName))
|
||||||
shared.dump(HeimdallStinkies)
|
shared.dump(HeimdallStinkies)
|
||||||
end
|
end
|
||||||
local res = WhoPartitioned(HeimdallStinkies)
|
local res = WhoPartitioned(HeimdallStinkies)
|
||||||
if #res == 0 then return { "No stinkies found" } end
|
if #res == 0 then return { "No stinkies found" } end
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
local function CountPartitionedStinkies()
|
local function CountPartitionedStinkies()
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName))
|
print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName))
|
||||||
end
|
end
|
||||||
local res = CountPartitioned(HeimdallStinkies)
|
local res = CountPartitioned(HeimdallStinkies)
|
||||||
if #res == 0 then return { "No stinkies found" } end
|
if #res == 0 then return { "No stinkies found" } end
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
local function HelpRu()
|
local function HelpRu()
|
||||||
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: HelpRu", ModuleName)) end
|
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: HelpRu", ModuleName)) end
|
||||||
return helpMessages.ru
|
return helpMessages.ru
|
||||||
end
|
end
|
||||||
local function HelpEn()
|
local function HelpEn()
|
||||||
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: HelpEn", ModuleName)) end
|
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: HelpEn", ModuleName)) end
|
||||||
return helpMessages.en
|
return helpMessages.en
|
||||||
end
|
end
|
||||||
local groupInviteFrame = CreateFrame("Frame")
|
local groupInviteFrame = CreateFrame("Frame")
|
||||||
groupInviteFrame:SetScript("OnEvent", function(self, event, ...)
|
groupInviteFrame:SetScript("OnEvent", function(self, event, ...)
|
||||||
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Event received", ModuleName)) end
|
if Heimdall_Data.config.commander.debug then print(string.format("[%s] Event received", ModuleName)) end
|
||||||
AcceptGroup()
|
AcceptGroup()
|
||||||
groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST")
|
groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST")
|
||||||
C_Timer.NewTimer(0.1, function()
|
C_Timer.NewTimer(0.1, function()
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Click event triggered", ModuleName))
|
print(string.format("[%s] Click event triggered", ModuleName))
|
||||||
end
|
end
|
||||||
_G["StaticPopup1Button1"]:Click()
|
_G["StaticPopup1Button1"]:Click()
|
||||||
end, 1)
|
end, 1)
|
||||||
end)
|
end)
|
||||||
local function JoinGroup()
|
local function JoinGroup()
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] JoinGroup command received", ModuleName))
|
print(string.format("[%s] JoinGroup command received", ModuleName))
|
||||||
end
|
end
|
||||||
groupInviteFrame:RegisterEvent("PARTY_INVITE_REQUEST")
|
groupInviteFrame:RegisterEvent("PARTY_INVITE_REQUEST")
|
||||||
C_Timer.NewTimer(10, function() groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") end, 1)
|
C_Timer.NewTimer(10, function() groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") end, 1)
|
||||||
return { "+" }
|
return { "+" }
|
||||||
end
|
end
|
||||||
local function LeaveGroup()
|
local function LeaveGroup()
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] LeaveGroup command received", ModuleName))
|
print(string.format("[%s] LeaveGroup command received", ModuleName))
|
||||||
end
|
end
|
||||||
LeaveParty()
|
LeaveParty()
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
---@param target string
|
---@param target string
|
||||||
local function FollowTarget(target)
|
local function FollowTarget(target)
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Following target: %s", ModuleName, target))
|
print(string.format("[%s] Following target: %s", ModuleName, target))
|
||||||
end
|
end
|
||||||
if not target then return end
|
if not target then return end
|
||||||
FollowUnit(target)
|
FollowUnit(target)
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param args string[]
|
---@param args string[]
|
||||||
local function MacroTarget(args)
|
local function MacroTarget(args)
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
|
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
|
||||||
print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args))))
|
print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args))))
|
||||||
end
|
end
|
||||||
if #args < 2 or #args % 2 ~= 0 then
|
if #args < 2 or #args % 2 ~= 0 then
|
||||||
if #args < 2 or #args % 2 ~= 0 then
|
if #args < 2 or #args % 2 ~= 0 then
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Invalid number of arguments for MacroTarget", ModuleName))
|
print(string.format("[%s] Invalid number of arguments for MacroTarget", ModuleName))
|
||||||
end
|
end
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.remove(args, 1)
|
table.remove(args, 1)
|
||||||
|
|
||||||
for i = 1, #args do
|
for i = 1, #args do
|
||||||
local stinky = strtrim(args[i])
|
local stinky = strtrim(args[i])
|
||||||
local name = stinky:match("([^/]+)")
|
local name = stinky:match("([^/]+)")
|
||||||
local class = stinky:match("/([^ $]+)")
|
local class = stinky:match("/([^ $]+)")
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Adding stinky: %s/%s", ModuleName, name, tostring(class)))
|
print(string.format("[%s] Adding stinky: %s/%s", ModuleName, name, tostring(class)))
|
||||||
end
|
end
|
||||||
shared.StinkyTracker.Track({
|
shared.StinkyTracker.Track({
|
||||||
name = name,
|
name = name,
|
||||||
class = class or "unknown",
|
class = class or "unknown",
|
||||||
seenAt = GetTime(),
|
seenAt = GetTime(),
|
||||||
hostile = true,
|
hostile = true,
|
||||||
})
|
})
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Added stinky: %s/%s", ModuleName, name, tostring(class)))
|
print(string.format("[%s] Added stinky: %s/%s", ModuleName, name, tostring(class)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param args string[]
|
---@param args string[]
|
||||||
local function IgnoreMacroTarget(args)
|
local function IgnoreMacroTarget(args)
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
|
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
|
||||||
print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args))))
|
print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args))))
|
||||||
end
|
end
|
||||||
if #args < 1 then
|
if #args < 1 then
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Invalid number of arguments for IgnoreMacroTarget", ModuleName))
|
print(string.format("[%s] Invalid number of arguments for IgnoreMacroTarget", ModuleName))
|
||||||
end
|
end
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
table.remove(args, 1)
|
table.remove(args, 1)
|
||||||
|
|
||||||
for i = 1, #args do
|
for i = 1, #args do
|
||||||
local stinky = strtrim(args[i])
|
local stinky = strtrim(args[i])
|
||||||
local name = stinky:match("([^/]+)")
|
local name = stinky:match("([^/]+)")
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Ignoring stinky: %s", ModuleName, name))
|
print(string.format("[%s] Ignoring stinky: %s", ModuleName, name))
|
||||||
end
|
end
|
||||||
shared.StinkyTracker.Ignore(name)
|
shared.StinkyTracker.Ignore(name)
|
||||||
end
|
end
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
---@class Command
|
---@class Command
|
||||||
---@field keywordRe string
|
---@field keywordRe string
|
||||||
---@field commanderOnly boolean
|
---@field commanderOnly boolean
|
||||||
---@field callback fun(...: any): string[]
|
---@field callback fun(...: any): string[]
|
||||||
|
|
||||||
local commands = {
|
local commands = {
|
||||||
{ keywordRe = "^who$", commanderOnly = false, callback = WhoPartitionedStinkies },
|
{ keywordRe = "^who$", commanderOnly = false, callback = WhoPartitionedStinkies },
|
||||||
{ keywordRe = "^howmany$", commanderOnly = false, callback = CountPartitionedStinkies },
|
{ keywordRe = "^howmany$", commanderOnly = false, callback = CountPartitionedStinkies },
|
||||||
{ keywordRe = "^classes$", commanderOnly = false, callback = CountClassPartitionedStinkies },
|
{ keywordRe = "^classes$", commanderOnly = false, callback = CountClassPartitionedStinkies },
|
||||||
{ keywordRe = "^help$", commanderOnly = false, callback = HelpRu },
|
{ keywordRe = "^help$", commanderOnly = false, callback = HelpRu },
|
||||||
{ keywordRe = "^helpen$", commanderOnly = false, callback = HelpEn },
|
{ keywordRe = "^helpen$", commanderOnly = false, callback = HelpEn },
|
||||||
{ keywordRe = "^joingroup$", commanderOnly = false, callback = JoinGroup },
|
{ keywordRe = "^joingroup$", commanderOnly = false, callback = JoinGroup },
|
||||||
{ keywordRe = "^leavegroup$", commanderOnly = false, callback = LeaveGroup },
|
{ keywordRe = "^leavegroup$", commanderOnly = false, callback = LeaveGroup },
|
||||||
{ keywordRe = "^follow$", commanderOnly = false, callback = FollowTarget },
|
{ keywordRe = "^follow$", commanderOnly = false, callback = FollowTarget },
|
||||||
{ keywordRe = "^macro", commanderOnly = false, callback = MacroTarget },
|
{ keywordRe = "^macro", commanderOnly = false, callback = MacroTarget },
|
||||||
{ keywordRe = "^ignore", commanderOnly = false, callback = IgnoreMacroTarget },
|
{ keywordRe = "^ignore", commanderOnly = false, callback = IgnoreMacroTarget },
|
||||||
}
|
}
|
||||||
|
|
||||||
local commanderChannelFrame = CreateFrame("Frame")
|
local commanderChannelFrame = CreateFrame("Frame")
|
||||||
commanderChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
|
commanderChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||||
commanderChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
commanderChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||||
--if Heimdall_Data.config.commander.debug then
|
--if Heimdall_Data.config.commander.debug then
|
||||||
-- print(string.format("[%s] Event received", ModuleName))
|
-- print(string.format("[%s] Event received", ModuleName))
|
||||||
-- shared.dump(Heimdall_Data.config.commander)
|
-- shared.dump(Heimdall_Data.config.commander)
|
||||||
--end
|
--end
|
||||||
if not Heimdall_Data.config.commander.enabled then
|
if not Heimdall_Data.config.commander.enabled then
|
||||||
--if Heimdall_Data.config.commander.debug then
|
--if Heimdall_Data.config.commander.debug then
|
||||||
-- print(string.format("[%s] Module disabled, ignoring event", ModuleName))
|
-- print(string.format("[%s] Module disabled, ignoring event", ModuleName))
|
||||||
--end
|
--end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local channelId = select(6, ...)
|
local channelId = select(6, ...)
|
||||||
local _, channelname = GetChannelName(channelId)
|
local _, channelname = GetChannelName(channelId)
|
||||||
local ok = false
|
local ok = false
|
||||||
for _, channel in pairs(Heimdall_Data.config.commander.channels) do
|
for _, channel in pairs(Heimdall_Data.config.commander.channels) do
|
||||||
if channel == channelname then
|
if channel == channelname then
|
||||||
ok = true
|
ok = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not ok then
|
if not ok then
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(
|
print(
|
||||||
string.format(
|
string.format(
|
||||||
"[%s] Channel name '%s' does not match any of the channels '%s'",
|
"[%s] Channel name '%s' does not match any of the channels '%s'",
|
||||||
ModuleName,
|
ModuleName,
|
||||||
channelname,
|
channelname,
|
||||||
table.concat(Heimdall_Data.config.commander.channels, ", ")
|
table.concat(Heimdall_Data.config.commander.channels, ", ")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
sender = string.match(sender, "^[^-]+")
|
sender = string.match(sender, "^[^-]+")
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Message from: %s", ModuleName, sender))
|
print(string.format("[%s] Message from: %s", ModuleName, sender))
|
||||||
shared.dump(Heimdall_Data.config.commander)
|
shared.dump(Heimdall_Data.config.commander)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, command in ipairs(commands) do
|
for _, command in ipairs(commands) do
|
||||||
local enabled = Heimdall_Data.config.commander.commands[command.keywordRe] == true or false
|
local enabled = Heimdall_Data.config.commander.commands[command.keywordRe] == true or false
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(
|
print(
|
||||||
string.format("[%s] Command match: %s = %s", ModuleName, command.keywordRe, tostring(enabled))
|
string.format("[%s] Command match: %s = %s", ModuleName, command.keywordRe, tostring(enabled))
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
if
|
if
|
||||||
enabled
|
enabled
|
||||||
and (
|
and (
|
||||||
not command.commanderOnly
|
not command.commanderOnly
|
||||||
-- if Heimdall_Data.config.commander.debug then print(string.format("[%s] Ignoring command, sender %s not commander %s", ModuleName, sender, Heimdall_Data.config.commander.commander)) end
|
-- if Heimdall_Data.config.commander.debug then print(string.format("[%s] Ignoring command, sender %s not commander %s", ModuleName, sender, Heimdall_Data.config.commander.commander)) end
|
||||||
|
|
||||||
or (command.commanderOnly and sender == Heimdall_Data.config.commander.commander)
|
or (command.commanderOnly and sender == Heimdall_Data.config.commander.commander)
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
if msg:match(command.keywordRe) then
|
if msg:match(command.keywordRe) then
|
||||||
---@diagnostic disable-next-line: redundant-parameter Currently luals does not support variadic functions as a @field
|
---@diagnostic disable-next-line: redundant-parameter Currently luals does not support variadic functions as a @field
|
||||||
local messages = command.callback({ strsplit(",", msg) })
|
local messages = command.callback({ strsplit(",", msg) })
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Messages to send: %s", ModuleName, #messages))
|
print(string.format("[%s] Messages to send: %s", ModuleName, #messages))
|
||||||
shared.dump(messages)
|
shared.dump(messages)
|
||||||
end
|
end
|
||||||
for _, message in ipairs(messages) do
|
for _, message in ipairs(messages) do
|
||||||
---@type Message
|
---@type Message
|
||||||
local returnmsg = {
|
local returnmsg = {
|
||||||
channel = "C",
|
channel = "C",
|
||||||
data = channelname,
|
data = channelname,
|
||||||
message = message,
|
message = message,
|
||||||
}
|
}
|
||||||
if Heimdall_Data.config.commander.debug then
|
if Heimdall_Data.config.commander.debug then
|
||||||
print(string.format("[%s] Queuing message", ModuleName))
|
print(string.format("[%s] Queuing message", ModuleName))
|
||||||
shared.dump(msg)
|
shared.dump(msg)
|
||||||
end
|
end
|
||||||
if Heimdall_Data.config.networkMessenger.enabled then
|
if Heimdall_Data.config.networkMessenger.enabled then
|
||||||
shared.NetworkMessenger.Enqueue(returnmsg)
|
shared.NetworkMessenger.Enqueue(returnmsg)
|
||||||
elseif Heimdall_Data.config.messenger.enabled then
|
elseif Heimdall_Data.config.messenger.enabled then
|
||||||
shared.Messenger.Enqueue(returnmsg)
|
shared.Messenger.Enqueue(returnmsg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
print(string.format("[%s] Module initialized", ModuleName))
|
print(string.format("[%s] Module initialized", ModuleName))
|
||||||
end,
|
end,
|
||||||
}
|
|
||||||
|
|||||||
@@ -2660,6 +2660,46 @@ shared.Config = {
|
|||||||
channelLocaleConfigFrame:Add(channelLocale, 8, 12)
|
channelLocaleConfigFrame:Add(channelLocale, 8, 12)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- ChatSniffer
|
||||||
|
do
|
||||||
|
local r, g, b, a = GetNextColor()
|
||||||
|
local chatSnifferConfigFrame = GridFrame.new("HeimdallChatSnifferConfig", UIParent, 12, 20)
|
||||||
|
chatSnifferConfigFrame.frame:SetBackdropColor(r, g, b, 0.3)
|
||||||
|
configFrame:Add(chatSnifferConfigFrame, 4, 1)
|
||||||
|
|
||||||
|
title = CreateFancyText(
|
||||||
|
"HeimdallChatSnifferConfigTitle",
|
||||||
|
chatSnifferConfigFrame.frame,
|
||||||
|
shared._L("chatSniffer", Heimdall_Data.config.locale),
|
||||||
|
{ r, g, b, a }
|
||||||
|
)
|
||||||
|
chatSnifferConfigFrame:Add(title, 1, 8)
|
||||||
|
|
||||||
|
local debugButton = CreateBasicButton(
|
||||||
|
"HeimdallChatSnifferConfigDebugButton",
|
||||||
|
chatSnifferConfigFrame.frame,
|
||||||
|
shared._L("debug", Heimdall_Data.config.locale),
|
||||||
|
function()
|
||||||
|
Heimdall_Data.config.chatSniffer.debug = not Heimdall_Data.config.chatSniffer.debug
|
||||||
|
return Heimdall_Data.config.chatSniffer.debug
|
||||||
|
end
|
||||||
|
)
|
||||||
|
debugButton:UpdateColor(Heimdall_Data.config.chatSniffer.debug)
|
||||||
|
chatSnifferConfigFrame:Add(debugButton, 1, 4)
|
||||||
|
|
||||||
|
local enableButton = CreateBasicButton(
|
||||||
|
"HeimdallChatSnifferConfigEnableButton",
|
||||||
|
chatSnifferConfigFrame.frame,
|
||||||
|
shared._L("enabled", Heimdall_Data.config.locale),
|
||||||
|
function()
|
||||||
|
Heimdall_Data.config.chatSniffer.enabled = not Heimdall_Data.config.chatSniffer.enabled
|
||||||
|
return Heimdall_Data.config.chatSniffer.enabled
|
||||||
|
end
|
||||||
|
)
|
||||||
|
enableButton:UpdateColor(Heimdall_Data.config.chatSniffer.enabled)
|
||||||
|
chatSnifferConfigFrame:Add(enableButton, 1, 12)
|
||||||
|
end
|
||||||
|
|
||||||
configFrame.frame:Hide()
|
configFrame.frame:Hide()
|
||||||
print("[Heimdall] Config loaded")
|
print("[Heimdall] Config loaded")
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -83,10 +83,7 @@ shared.Messenger = {
|
|||||||
|
|
||||||
if not message.channel or message.channel == "" then
|
if not message.channel or message.channel == "" then
|
||||||
if Heimdall_Data.config.messenger.debug then
|
if Heimdall_Data.config.messenger.debug then
|
||||||
shared.dump(
|
shared.dump(message, string.format("[%s] Invalid message: no channel specified", ModuleName))
|
||||||
message,
|
|
||||||
string.format("[%s] Invalid message: no channel specified", ModuleName)
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -150,10 +147,7 @@ shared.Messenger = {
|
|||||||
shared.dump(message, string.format("[%s] Sending message:", ModuleName))
|
shared.dump(message, string.format("[%s] Sending message:", ModuleName))
|
||||||
end
|
end
|
||||||
if string.len(message.message) > 255 then
|
if string.len(message.message) > 255 then
|
||||||
shared.dump(
|
shared.dump(message, string.format("[%s] Message too long!!!!: %s", ModuleName, message.message))
|
||||||
message,
|
|
||||||
string.format("[%s] Message too long!!!!: %s", ModuleName, message.message)
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
SendChatMessage(message.message, message.channel, nil, message.data)
|
SendChatMessage(message.message, message.channel, nil, message.data)
|
||||||
|
|||||||
2
_L.lua
2
_L.lua
@@ -90,6 +90,7 @@ shared._Locale = {
|
|||||||
updateInterval = "Update Interval",
|
updateInterval = "Update Interval",
|
||||||
networkMessenger = "Network Messenger",
|
networkMessenger = "Network Messenger",
|
||||||
queries = "Who queries",
|
queries = "Who queries",
|
||||||
|
chatSniffer = "Chat Sniffer",
|
||||||
},
|
},
|
||||||
ru = {
|
ru = {
|
||||||
bonkDetected = "%s ударил %s (%s)",
|
bonkDetected = "%s ударил %s (%s)",
|
||||||
@@ -175,6 +176,7 @@ shared._Locale = {
|
|||||||
updateInterval = "Интервал Обновления",
|
updateInterval = "Интервал Обновления",
|
||||||
networkMessenger = "Сетевой Мессенджер",
|
networkMessenger = "Сетевой Мессенджер",
|
||||||
queries = "Запросы Who",
|
queries = "Запросы Who",
|
||||||
|
chatSniffer = "Сниффер Чата",
|
||||||
["Orgrimmar"] = "Оргриммар",
|
["Orgrimmar"] = "Оргриммар",
|
||||||
["Valley of Strength"] = "Долина Силы",
|
["Valley of Strength"] = "Долина Силы",
|
||||||
["Valley of Trials"] = "Долина Испытаний",
|
["Valley of Trials"] = "Долина Испытаний",
|
||||||
|
|||||||
Reference in New Issue
Block a user