comparison Core.lua @ 144:03e108d12ef1

Ticket 45 - Added the ability suppress COD warnings when mailing to characters on other accounts in Altoholic/DataStore. Instead of sending COD, ItemAuditor will send tracking info in the message. Thanks to Zerotorescue for giving me the solution to detect whether or not Postal or MailOpener is processing. It was the last step holding this back from being released.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Sat, 09 Oct 2010 00:21:06 -0700
parents 15a259503d63
children b15c19200af8
comparison
equal deleted inserted replaced
143:4d7955b2d240 144:03e108d12ef1
1 local ItemAuditor = select(2, ...) 1 local ItemAuditor = select(2, ...)
2 local Utils 2 local Utils
3 ItemAuditor = LibStub("AceAddon-3.0"):NewAddon(ItemAuditor, "ItemAuditor", "AceEvent-3.0", "AceBucket-3.0") 3 ItemAuditor = LibStub("AceAddon-3.0"):NewAddon(ItemAuditor, "ItemAuditor", "AceEvent-3.0", "AceBucket-3.0", "AceSerializer-3.0", "AceTimer-3.0")
4 --@debug@ 4 --@debug@
5 _G['ItemAuditor'] = ItemAuditor 5 _G['ItemAuditor'] = ItemAuditor
6 --@end-debug@ 6 --@end-debug@
7 7
8 if not DevTools_Dump then 8 if not DevTools_Dump then
9 function DevTools_Dump() 9 function DevTools_Dump()
10 end 10 end
11 end 11 end
12
13 ItemAuditor.TRACKING_DATA_DIVIDER = "\n==ItemAuditor Tracking Data==\n"
12 14
13 local allMailboxes = {} 15 local allMailboxes = {}
14 local myMailbox = {} 16 local myMailbox = {}
15 17
16 ItemAuditor.Options = { 18 ItemAuditor.Options = {
51 auction_threshold = 0.15, 53 auction_threshold = 0.15,
52 auction_threshold_value = 0, 54 auction_threshold_value = 0,
53 qa_extra = 0, 55 qa_extra = 0,
54 output_chat_frame = nil, 56 output_chat_frame = nil,
55 cod_warnings = true, 57 cod_warnings = true,
58 incoming_tracking_ids = {}
56 }, 59 },
57 profile = { 60 profile = {
58 messages = { 61 messages = {
59 cost_updates = true, 62 cost_updates = true,
60 queue_skip = false, 63 queue_skip = false,
265 local inboundCOD = {} 268 local inboundCOD = {}
266 local skipMail = {} 269 local skipMail = {}
267 function ItemAuditor:ScanMail() 270 function ItemAuditor:ScanMail()
268 local results = {} 271 local results = {}
269 local CODPaymentRegex = gsub(COD_PAYMENT, "%%s", "(.*)") 272 local CODPaymentRegex = gsub(COD_PAYMENT, "%%s", "(.*)")
273 local ia_tracking = {}
270 274
271 for mailIndex = 1, GetInboxNumItems() or 0 do 275 for mailIndex = 1, GetInboxNumItems() or 0 do
272 local sender, msgSubject, msgMoney, msgCOD, daysLeft, msgItem, _, _, msgText, _, isGM = select(3, GetInboxHeaderInfo(mailIndex)) 276 local sender, msgSubject, msgMoney, msgCOD, daysLeft, msgItem, _, _, msgText, _, isGM = select(3, GetInboxHeaderInfo(mailIndex))
273 local mailType = self:GetMailType(msgSubject) 277 local mailType = self:GetMailType(msgSubject)
274 278
354 local count = select(3, GetInboxItem(mailIndex,1)) 358 local count = select(3, GetInboxItem(mailIndex,1))
355 results[mailType][itemName].count = results[mailType][itemName].count + count 359 results[mailType][itemName].count = results[mailType][itemName].count + count
356 elseif mailType == "AHExpired" or mailType == "AHCancelled" or mailType == "AHOutbid" then 360 elseif mailType == "AHExpired" or mailType == "AHCancelled" or mailType == "AHOutbid" then
357 -- These should be handled when you pay the deposit at the AH 361 -- These should be handled when you pay the deposit at the AH
358 else 362 else
359 -- self:Debug("Unhandled mail type: " .. mailType) 363
360 -- self:Debug(msgSubject) 364 local body = GetInboxText(mailIndex)
365 if body and body:find(ItemAuditor.TRACKING_DATA_DIVIDER) then
366 local serialized = body:gsub('.*'..ItemAuditor.TRACKING_DATA_DIVIDER, '')
367 local body = body:gsub(ItemAuditor.TRACKING_DATA_DIVIDER..'.*', '')
368 local success, trackingID, data = ItemAuditor:Deserialize(serialized)
369 if success then
370 if not self.db.char.incoming_tracking_ids[trackingID] then
371 for link, d in pairs(data) do
372 self:SaveValue(link, d.costEach * d.count, d.count)
373 end
374 end
375 if body == '' and msgItem == nil then
376 self.deleteQueue = self.deleteQueue or {}
377 local ni = #(self.deleteQueue)+1
378 print(deleteQueue, ni, mailIndex)
379 self.deleteQueue[ni] = mailIndex
380 end
381 ia_tracking[trackingID] = true
382 self.db.char.incoming_tracking_ids[trackingID] = true
383 end
384 end
385
361 end 386 end
362 387
363 end 388 end
364 389
365 wipe(myMailbox) 390 wipe(myMailbox)
371 count = data.count, 396 count = data.count,
372 } 397 }
373 -- self:Print(format("|cFF00FF00MailScan|r: %s - %s - %s x %s", mailType, item, data.total, data.count)) 398 -- self:Print(format("|cFF00FF00MailScan|r: %s - %s - %s x %s", mailType, item, data.total, data.count))
374 end 399 end
375 end 400 end
401 if self:tcount(ia_tracking) > 0 then
402 for id, _ in pairs(self.db.char.incoming_tracking_ids) do
403 self.db.char.incoming_tracking_ids[id] = ia_tracking[id]
404 end
405 end
406
376 return results 407 return results
377 end 408 end
378 409
379 local realm = GetRealmName() 410 local realm = GetRealmName()
380 local ds_account = 'Default' 411 local ds_account = 'Default'