chat rate limit (should only impact "full scans")

This commit is contained in:
gretchen
2024-01-08 15:33:04 +01:00
parent 43ed6bc564
commit 4eacf1943f
+21 -14
View File
@@ -100,22 +100,29 @@ AUX_data_sharer:SetScript("OnEvent", function()
end end
end end
end) end)
function M.process_auction(auction_record) local lastMessageTime = 0
local item_record = read_record(auction_record.item_key) local messageCooldown = 0.001 --time between messages in seconds. Arbitrary value to stop people from getting chat restricted when doing full scans. Could probably be lower but that would lead to so much spam, full scan bad
local unit_buyout_price = ceil(auction_record.buyout_price / auction_record.aux_quantity)
local item_key = auction_record.item_key function M.process_auction(auction_record)
if unit_buyout_price > 0 and unit_buyout_price < (item_record.daily_min_buyout or aux.huge) then local currentTime = GetTime()
item_record.daily_min_buyout = unit_buyout_price local elapsedTime = currentTime - lastMessageTime
write_record(auction_record.item_key, item_record) local item_record = read_record(auction_record.item_key)
--AuxAddon:SendCommMessage("GUILD", item_key, unit_buyout_price) relies on acecomm local unit_buyout_price = ceil(auction_record.buyout_price / auction_record.aux_quantity)
if GetChannelName("LFT") ~= 0 then local item_key = auction_record.item_key
SendChatMessage("AuxData," .. item_key .."," .. unit_buyout_price , "CHANNEL", nil, GetChannelName("LFT")) if unit_buyout_price > 0 and unit_buyout_price < (item_record.daily_min_buyout or aux.huge) then
item_record.daily_min_buyout = unit_buyout_price
write_record(auction_record.item_key, item_record)
--AuxAddon:SendCommMessage("GUILD", item_key, unit_buyout_price) relies on acecomm
if elapsedTime >= messageCooldown then
if GetChannelName("LFT") ~= 0 then
SendChatMessage("AuxData," .. item_key .."," .. unit_buyout_price , "CHANNEL", nil, GetChannelName("LFT"))
end
lastMessageTime = currentTime
end end
--print("sent/wrote data"); --for testing --print("sent/wrote data"); --for testing
end end
end end
--[[ function AuxAddon:OnCommReceive(prefix, sender, distribution, item_key, unit_buyout_price) --copied code from process_auction. <- code for when using acecomm --[[ function AuxAddon:OnCommReceive(prefix, sender, distribution, item_key, unit_buyout_price) --copied code from process_auction. <- code for when using acecomm
print("received data"); --for testing (print comes from PFUI) print("received data"); --for testing (print comes from PFUI)