<commit_before>local mod = EPGP:NewModule("EPGP_Loot", "AceEvent-3.0")

local L = LibStub:GetLibrary("AceLocale-3.0"):GetLocale("EPGP")
local deformat = LibStub:GetLibrary("Deformat-2.0")

local ignored_items = {
  [20725] = true, -- Nexus Crystal
  [22450] = true, -- Void Crystal
  [29434] = true, -- Badge of Justice
  [30311] = true, -- Warp Slicer
  [30312] = true, -- Infinity Blade
  [30313] = true, -- Staff of Disintegration
  [30314] = true, -- Phaseshift Bulwark
  [30316] = true, -- Devastation
  [30317] = true, -- Cosmic Infuser
  [30318] = true, -- Netherstrand Longbow
  [30319] = true, -- Nether Spikes
  [30320] = true, -- Bundle of Nether Spikes
}

local function IsRLorML()
  if UnitInRaid("player") then
    local loot_method, ml_party_id, ml_raid_id = GetLootMethod()
    if loot_method == "master" and ml_party_id == 0 then return true end
    if loot_method ~= "master" and IsRaidLeader() then return true end
  end
  return false
end

function mod:RAID_ROSTER_UPDATE()
  if IsRLorML() then
    self:RegisterEvent("CHAT_MSG_LOOT")
  else
    self:UnregisterEvent("CHAT_MSG_LOOT")
  end
end

local function ParseLootMessage(msg)
  local player = UnitName("player")
  local item, quantity = deformat(msg, LOOT_ITEM_SELF_MULTIPLE)
  if item and quantity then
    return player, item, tonumber(quantity)
  end
  quantity = 1
  item = deformat(msg, LOOT_ITEM_SELF)
  if item then
    return player, item, tonumber(quantity)
  end
  
  player, item, quantity = deformat(msg, LOOT_ITEM_MULTIPLE)
  if player and item and quantity then
    return player, item, tonumber(quantity)
  end

  quantity = 1
  player, item = deformat(msg, LOOT_ITEM)
  return player, item, tonumber(quantity)
end

function mod:CHAT_MSG_LOOT(msg)
  local player, item, quantity = ParseLootMessage(msg)
  if not player or not item then return end

  local item_name, item_link, item_rarity = GetItemInfo(item)
  local item_id = select(3, item_link:find("item:(%d+):"))
  if not item_id then return end
  item_id = tonumber(item_id:trim())
  if not item_id then return end

  if ignored_items[item_id] then return end
  -- TODO(alkis): Add quality threshold variable
  self:SendMessage("LootReceived", player, item_link, quantity)
end
<commit_msg>Only track GP for epic items.<commit_after>local mod = EPGP:NewModule("EPGP_Loot", "AceEvent-3.0")

local L = LibStub:GetLibrary("AceLocale-3.0"):GetLocale("EPGP")
local deformat = LibStub:GetLibrary("Deformat-2.0")

local ignored_items = {
  [20725] = true, -- Nexus Crystal
  [22450] = true, -- Void Crystal
  [29434] = true, -- Badge of Justice
  [30311] = true, -- Warp Slicer
  [30312] = true, -- Infinity Blade
  [30313] = true, -- Staff of Disintegration
  [30314] = true, -- Phaseshift Bulwark
  [30316] = true, -- Devastation
  [30317] = true, -- Cosmic Infuser
  [30318] = true, -- Netherstrand Longbow
  [30319] = true, -- Nether Spikes
  [30320] = true, -- Bundle of Nether Spikes
}

local function IsRLorML()
  if UnitInRaid("player") then
    local loot_method, ml_party_id, ml_raid_id = GetLootMethod()
    if loot_method == "master" and ml_party_id == 0 then return true end
    if loot_method ~= "master" and IsRaidLeader() then return true end
  end
  return false
end

function mod:RAID_ROSTER_UPDATE()
  if IsRLorML() then
    self:RegisterEvent("CHAT_MSG_LOOT")
  else
    self:UnregisterEvent("CHAT_MSG_LOOT")
  end
end

local function ParseLootMessage(msg)
  local player = UnitName("player")
  local item, quantity = deformat(msg, LOOT_ITEM_SELF_MULTIPLE)
  if item and quantity then
    return player, item, tonumber(quantity)
  end
  quantity = 1
  item = deformat(msg, LOOT_ITEM_SELF)
  if item then
    return player, item, tonumber(quantity)
  end
  
  player, item, quantity = deformat(msg, LOOT_ITEM_MULTIPLE)
  if player and item and quantity then
    return player, item, tonumber(quantity)
  end

  quantity = 1
  player, item = deformat(msg, LOOT_ITEM)
  return player, item, tonumber(quantity)
end

function mod:CHAT_MSG_LOOT(msg)
  local player, item, quantity = ParseLootMessage(msg)
  if not player or not item then return end

  local item_name, item_link, item_rarity = GetItemInfo(item)
  if item_rarity < 4 then return end
  local item_id = select(3, item_link:find("item:(%d+):"))
  if not item_id then return end
  item_id = tonumber(item_id:trim())
  if not item_id then return end

  if ignored_items[item_id] then return end
  self:SendMessage("LootReceived", player, item_link, quantity)
end

{'fraction_non_alphanumeric': 0.10741402411790978, 'fraction_numerical': 0.03148727110317106, 'mean_word_length': 4.184027777777778, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4677163', 'n_tokens_mistral': 1671, 'n_tokens_neox': 1563, 'n_words': 452}