Why is this code afu?

want to filter messages to a chat pane

-- this chat filter only runs for CHAT_MSG_SYSTEM
local function filter(self, event, msg, ...)
    if self:GetName() == getAuctionTab():GetName() then
       if hasAuctionText(msg) then
          local color = ChatTypeInfo["SYSTEM"]
          auctionTab:AddMessage(msg,color.r,color.g,color.b)
	      return false,msg,...
       else
          return true
	  end
   end
   return false,msg,...
end

-- create filter
ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM",filter)

Are you sure that event is being fired for AH messages?

Yea I am,it is filtering all mesaages cept for knowledge messages,here is the entire script

-- This file is loaded from "AuctionHouseMessages.toc"

-- this addon will redirect auction system messages to a temporary
-- chat tab named "AH"

local tabName = "AH" -- name for temporary tab 

-- fill auctionStrings with pattern matches for auction events
auctionStrings = {}
for k,v in pairs({
    -- delete any lines here you don't want redirected
    ERR_AUCTION_EXPIRED_S, -- "Your auction of %s has expired."
    ERR_AUCTION_OUTBID_S, -- "You have been outbid on %s."
    ERR_AUCTION_REMOVED_S, -- "Your auction of %s has been cancelled by the seller."
    ERR_AUCTION_SOLD_S, -- "A buyer has been found for your auction of %s."
    ERR_AUCTION_WON_S, -- "You won an auction for %s"
    ERR_AUCTION_BID_PLACED, -- "Bid accepted."
    ERR_AUCTION_REMOVED, -- "Auction cancelled."
    ERR_AUCTION_STARTED, -- "Auction created."
  }) do
  v = v:gsub("%.","%%."):gsub("%%s",".-")
  tinsert(auctionStrings,v)
end

-- returns the Auctions temporary chat tab if it exists
-- if create is true, creates one if needed
local function getAuctionTab(create)
  -- look for existing tab with "Auctions" as a name
  for _,name in pairs(CHAT_FRAMES) do
    local frame = _G[name]
    if frame.name == tabName then
      return frame
    end
  end
end

-- returns true if msg matches any of the known auctionStrings
local function hasAuctionText(msg)
  for i=1,#auctionStrings do
    if msg:match(auctionStrings[i]) then
      return true
    end
  end
end

-- this chat filter only runs for CHAT_MSG_SYSTEM
local function filter(self, event, msg, ...)
    if self:GetName() == getAuctionTab():GetName() then
       if hasAuctionText(msg) then
          local color = ChatTypeInfo["SYSTEM"]
          auctionTab:AddMessage(msg,color.r,color.g,color.b)
	      return false,msg,...
       else
          return true
	  end
   end
   return false,msg,...
end

-- create filter
ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM",filter)

I don’t see anything to do with knowledge in your auctionStrings table so when you say

is filtering

do you mean some of the messages listed in auctionStrings are going to your “AH” frame but not others or, ALL messages are going the current chatframe and none are going to your “AH” frame?

the ah frame is being filtered all of the system messages cept for knowledge ones,i donno why

again, what knowledge ones? Or do you mean the strings in the auctionStrings table (and we have a language difference)?

The code doesn’t filter the frame with the name “AH”, it filters the normal chat frames looking for whatever the filter is looking for (in this case, texts listed in your auctionStrings table).

The quickest test of your filter at least being used would be to change the filter function to something like:

local function filter(self, event, msg, ...)

  print("Filtering:", event, msg, ...) -- test to see "CHAT_MSG_SYSTEM" is used for AH messages.

    if self:GetName() == getAuctionTab():GetName() then
       if hasAuctionText(msg) then
          local color = ChatTypeInfo["SYSTEM"]
          auctionTab:AddMessage(msg,color.r,color.g,color.b)
	      return false,msg,...
       else
          return true
	  end
   end
   return false,msg,...
end

Go to AH and place/cancel an auction and see you get Filtering: at the beginning of the message responses.

If not then chat did not get a “CHAT_MSG_SYSTEM” event for those actions (I haven’t looked at the auction house code since the new one came into effect, not my area of interest atm).

its firing for everything but the ah defined ones :frowning:

Which would likely mean they are no longer sent using the CHAT_MSG_SYSTEM event.

Maybe someone who knows about the new AH knows how/where they are being sent.

tried this no worky

local function getAuctionTab
  local tabName = "AH"
  for _,name in pairs(CHAT_FRAMES) do
    local frame = _G[name]
    if frame.name == tabName then
      return frame
    end
  end
end

local function OnEvent(self, event, errorType, msg)
    local color = ChatTypeInfo["SYSTEM"]
	local auctionTab == getAuctionTab
	if msg == ERR_AUCTION_EXPIRED_S then -- "Your auction of %s has expired."
       auctionTab:AddMessage(msg,color.r,color.g,color.b)
    end 
	if msg == ERR_AUCTION_OUTBID_S then  -- "You have been outbid on %s."
       auctionTab:AddMessage(msg,color.r,color.g,color.b)
    end 
	if msg == ERR_AUCTION_REMOVED_S then  -- "Your auction of %s has been cancelled by the seller."
       auctionTab:AddMessage(msg,color.r,color.g,color.b)
    end 
	if msg == ERR_AUCTION_SOLD_S then  -- "A buyer has been found for your auction of %s."
       auctionTab:AddMessage(msg,color.r,color.g,color.b)
    end 
	if msg == ERR_AUCTION_WON_S then  -- "You won an auction for %s"
       auctionTab:AddMessage(msg,color.r,color.g,color.b)
    end 
	if msg == ERR_AUCTION_BID_PLACED then  -- "Bid accepted."
       auctionTab:AddMessage(msg,color.r,color.g,color.b)
    end 
	if msg == ERR_AUCTION_REMOVED then  -- "Auction cancelled."
        auctionTab:AddMessage(msg,color.r,color.g,color.b)
    end 
	if msg == ERR_AUCTION_STARTED then  -- "Auction created."
       auctionTab:AddMessage(msg,color.r,color.g,color.b)
    end 
end

local f = CreateFrame("Frame")
f:RegisterEvent("UI_ERROR_MESSAGE")
f:SetScript("OnEvent", OnEvent)

Maybe this will help:

or:

It looks like other message (Placed, Cancelled etc.) are directly added via Chat_AddSystemMessage(...)

AH events UIParent registers:

-- Events for auction UI handling
	self:RegisterEvent("AUCTION_HOUSE_SHOW");
	self:RegisterEvent("AUCTION_HOUSE_CLOSED");
	self:RegisterEvent("AUCTION_HOUSE_DISABLED");
	self:RegisterEvent("AUCTION_HOUSE_SHOW_FORMATTED_NOTIFICATION");
	self:RegisterEvent("AUCTION_HOUSE_SHOW_NOTIFICATION")