--CHAT_MSG_LOOT REMOVE_ITEM ADD_ITEM
function(allstates, e, msg, howmuch)
	if e == "CHAT_MSG_LOOT" then
		if msg then
			local who = msg:match("%w+")
			if who == "You" then
				local howmuch = msg:match("(x%d+).$")
				local what
				for itemLink in msg:gmatch("|%x+|Hitem:.-|h.-|h|r") do
					what = itemLink
				end
				--WeakAuras.ScanEvents("ADD_ITEM", what, howmuch)
				C_Timer.After(0.05, function() WeakAuras.ScanEvents("ADD_ITEM", what, howmuch) end)
			end
		end
	elseif e == "ADD_ITEM" then
		local what = msg
		if what then
			local rarity = select(3, GetItemInfo(what))
			local icon = 0
			local name = GetItemInfo(what)
			if not WeakAurasSaved.CustomTrash.IconDatabase[name] then icon = select(10, GetItemInfo(name)) else icon = WeakAurasSaved.CustomTrash.IconDatabase[name] end
			if name and icon and not WeakAurasSaved.CustomTrash.IconDatabase[name] then WeakAurasSaved.CustomTrash.IconDatabase[name] = icon; print("Adding|cff78cb00 ", name, " |rto the icon database") end
			local color = "ffffffff"
			if rarity then
				color = select(4, GetItemQualityColor(rarity))
			end
			color = "|c" .. color
			local indexid = #allstates + 1
			local ID
			if WeakAurasSaved.CustomTrash.IDDatabase[name] then ID = WeakAurasSaved.CustomTrash.IDDatabase[name] end
			allstates[indexid] = 
			{
				show = true,
				changed = true,
				expirationTime = GetTime() + 1,
				index = GetTime(),
				autoHide = true,
				resort = true,
				icon = icon,
				name = what,
				color = color,
				amount = howmuch,
			}
			if ID then
				allstates[indexid].itemId = ID
			end
			C_Timer.After(1, function() WeakAuras.ScanEvents("REMOVE_ITEM", indexid) end)
			return true
		end
	elseif e == "REMOVE_ITEM" then
		if allstates[msg] then
			allstates[msg].show = false
			allstates[msg].changed = true
			return true
		end
	end
end