I have a slight issue with my mod atm and I'm hoping somebody can help as it's just slightly out of my programming capabilities.
Basically my mod automatically replies to specific keywords in Trade, however there is so many of us using the mod now that it creates spam due to 5-10 people automatically replying to the keyword at the same time.
I'd like to lessen the resulting spam so I'm wondering if there's some way I can have the addons communicate with each other so only one person will respond. I'd like to use a hidden channel as this way the sync will be global instead of guild/raid/party only as is my understanding with SendAddonMessage().
Here's my (modified) lua below. (Slakah, you might recognize some of it
)
Code:
local rswears = 80; -- 80%
local swears = { "swear1", "swear2" }
local time
local function CheckMsgMatch(msg, chatType, channel)
local cooldown = (math.random(40, 70));
local roll = (math.random(1, 100));
-- SWEARS
for _, v in ipairs(swears) do
if strmatch(strlower(msg), strlower(v)) then
if not time or GetTime() > time then
SendChatMessage("reported",chatType, nil, channel)
DEFAULT_CHAT_FRAME:AddMessage("[Match:(" .. arg2 .. ": " .. strlower(v) .. ") CD:(" .. cooldown .. ") Roll:(" .. roll .. ")]", 0.0, 1.0, 0.0);
time = floor(GetTime()) + cooldown
return
end
end
end
end
local f = CreateFrame("Frame")
f:RegisterEvent("CHAT_MSG_CHANNEL")
f:RegisterEvent("CHAT_MSG_BATTLEGROUND")
f:SetScript("OnEvent", function (self, event, msg, arg2, _, _, _, _, _, channel, channame)
if (ReportedDB.MonitorTrade == true) then
if (event == "CHAT_MSG_CHANNEL") and (channame == "Trade - City") then
CheckMsgMatch(msg, "CHANNEL", channel)
end
end
end)