only share data if not full scan, add off toggle

This commit is contained in:
gretchen
2024-01-08 22:18:40 +01:00
parent 02b9dfa88a
commit 87c8cf421e
4 changed files with 11 additions and 13 deletions
+1
View File
@@ -65,6 +65,7 @@ function handle.LOAD()
auctionable_items = {},
merchant_buy = {},
merchant_sell = {},
sharing = true,
})
do
local key = format('%s|%s', GetCVar'realmName', UnitName'player')
+4 -12
View File
@@ -76,7 +76,7 @@ AUXplayerName = UnitName("player")
AUX_data_sharer:SetScript("OnEvent", function()
if event == "CHAT_MSG_CHANNEL" then
if event == "CHAT_MSG_CHANNEL" and aux.account_data.sharing == true then
local _,_,source = string.find(arg4,"(%d+)%.")
if source then
_,name = GetChannelName(source)
@@ -85,8 +85,6 @@ AUX_data_sharer:SetScript("OnEvent", function()
local msg, item_key, munit_buyout_price = AuxAddon_strsplit(",", arg1) --using , as a seperator because item_key contains a :
if msg == "AuxData" then
if arg2 ~= AUXplayerName then
--print(arg2)
--print(AUXplayerName)
local unit_buyout_price = tonumber (munit_buyout_price)
--print("received data:" .. msg .. "," .. item_key .. "," .. unit_buyout_price); --for testing (print comes from PFUI)
local item_record = read_record(item_key)
@@ -101,12 +99,7 @@ AUX_data_sharer:SetScript("OnEvent", function()
end
end)
local lastMessageTime = 0
local messageCooldown = 0.01 --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
function M.process_auction(auction_record)
local currentTime = GetTime()
local elapsedTime = currentTime - lastMessageTime
function M.process_auction(auction_record, pages)
local item_record = read_record(auction_record.item_key)
local unit_buyout_price = ceil(auction_record.buyout_price / auction_record.aux_quantity)
local item_key = auction_record.item_key
@@ -114,13 +107,12 @@ AUX_data_sharer:SetScript("OnEvent", function()
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 pages < 15 and aux.account_data.sharing == true then
if GetChannelName("LFT") ~= 0 then
SendChatMessage("AuxData," .. item_key .."," .. unit_buyout_price , "CHANNEL", nil, GetChannelName("LFT"))
--print("sent")
end
lastMessageTime = currentTime
end
--print("sent/wrote data"); --for testing
end
end
+2 -1
View File
@@ -138,6 +138,7 @@ function scan_page(i)
end
end
local pages = last_page(get_state().total_auctions)
local auction_info = info.auction(i, get_state().params.type)
if auction_info and (auction_info.owner or get_state().params.ignore_owner or aux.account_data.ignore_owner) then
auction_info.index = i
@@ -145,7 +146,7 @@ function scan_page(i)
auction_info.blizzard_query = get_query().blizzard_query
auction_info.query_type = get_state().params.type
history.process_auction(auction_info)
history.process_auction(auction_info, pages)
if (get_state().params.auto_buy_validator or pass)(auction_info) and auction_info.buyout_price >0 and auction_info.owner ~= UnitName("player") then
local send_signal, signal_received = aux.signal()
+4
View File
@@ -58,6 +58,9 @@ function SlashCmdList.AUX(command)
aux.print('Item cache cleared.')
elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then
info.populate_wdb()
elseif arguments[1] == 'sharing' then
aux.account_data.sharing = not aux.account_data.sharing
aux.print('sharing ' .. status(aux.account_data.sharing))
else
aux.print('Usage:')
aux.print('- scale [' .. aux.color.blue(aux.account_data.scale) .. ']')
@@ -74,5 +77,6 @@ function SlashCmdList.AUX(command)
aux.print('- tooltip disenchant distribution [' .. status(tooltip_settings.disenchant_distribution) .. ']')
aux.print('- clear item cache')
aux.print('- populate wdb')
aux.print('- sharing [' .. status(aux.account_data.sharing) .. ']')
end
end