Redirect system messages?

in the chat settings i have a frame named “misc” - it gets all system messages (you completed whatever quest) etc, reputation and skillups.

i would like to (if possible) redirect one message - or maybe its two - guild members logon/off to the frame i actually pay attention to as i play. possible, maybe?

thanks in advance

You can print specifically those messages to the default chat frame

local OFFLINE_MSG = ERR_FRIEND_OFFLINE_S:gsub("%%s", ".+")
local ONLINE_MSG = ERR_FRIEND_ONLINE_SS:gsub("|Hplayer:%%s|h%[%%s%]|h", "|Hplayer:.+|h%%[.+%%]|h")

local function IsOnlineMsg(s)
	return s:find(OFFLINE_MSG) or s:find(ONLINE_MSG)
end

-- print to main chat frame
local function OnEvent(self, event, msg)
	if IsOnlineMsg(msg) then
		DEFAULT_CHAT_FRAME:AddMessage(msg, 1, 1, 0)
	end
end

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

-- filter default one
local function filter(self, event, msg)
	return IsOnlineMsg(msg)
end

ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", filter)

Turn it into an addon with https://addon.bool.no/ or https://www.curseforge.com/wow/addons/rehack

1 Like

in order to clarify in case i misunderstand:

this code will print online/offline messages to the general tab which is by default frame 1. i have a separate window for guild which according to chat-cache.txt is window 6. this is where i would like those messages to go.

sorry if i caused confusion … thanks :wink:

Change DEFAULT_CHAT_FRAME to ChatFrame6

ok, going here: https://addon.bool.no/ i pasted the above code, named the addon “Redirect” and the extracted the zip file to my classic addon folder.

after my clarification above i changed this line:

DEFAULT_CHAT_FRAME:AddMessage(msg, 1, 1, 0)

to

ChatFrame6:AddMessage(msg, 1, 1, 0)

the online/offline message still goes to the catch-all tab that i had any system message go to. is there something simple that i am missing??

thank you :wink:

That should work, if you edited the file while in-game make sure you did a /reload or relog to see any changes. Get BugSack/Swatter to debug any Lua errors

The addon is sending a copy of the message to ChatFrame6 while the original still goes to the default.

As the online/offline messages are just some of the many that come under the message group “CHAT_MSG_SYSTEM” there are only two approaches to having an absolute re-direct.

Send all messages in that group to another chat frame and remove that group from the default frame or Intercept the processing of messages in the chat system to weed out /kill off/re-direct just one or two.

Option one, easy. Option two, not so much (at least time-wise). I’m not sure if something like Prat has this sort of thing build-in.

… Some thoughts later, Option 3, fairly straight forward, (a little from column A, a little from column B)
Using Ketho’s method, remove the system group from ChatFrame1 and have the addon send everything but the re-directed messages back to ChatFrame 1. Untested ssooo…

Doesn’t appear to.

1 Like

It’s fairly niche so I’m not surprised.

Thanks Elvenbane.

I completely missed the last 4 lines of Kethos code yesterday. It should indeed work as required. :woozy_face:

diff character (please wait for others to participate before replying) or something similar - 11 days later…

i copied/pasted the code given above by ketho with the change from default to chatframe6. offline copies to the correct frame, online does not. honestly i wouldn’t care if offline didn’t work, but online would be better.

thanks

Oops my bad, this should work

local ONLINE_MSG = ERR_FRIEND_ONLINE_SS:gsub("|Hplayer:%%s|h%[%%s%]|h", "|Hplayer:.+|h%%[.+%%]|h")

Any chance, Ketho, that you could provide additional code for also moving Guild promos/kicks/joins to a separate window? The above code for online/offline is awesome and thanks!

Try this (untested)

local messages = {
	OFFLINE_MSG = ERR_FRIEND_OFFLINE_S:gsub("%%s", ".+"),
	ONLINE_MSG = ERR_FRIEND_ONLINE_SS:gsub("|Hplayer:%%s|h%[%%s%]|h", "|Hplayer:.+|h%%[.+%%]|h"),
	GUILD_PROMOTE_MSG = ERR_GUILD_PROMOTE_SSS:gsub("%%s", ".+"),
	GUILD_REMOVE_MSG = ERR_GUILD_REMOVE_SS:gsub("%%s", ".+"),
	GUILD_JOIN_MSG = ERR_GUILD_JOIN_S:gsub("%%s", ".+"),
}

local function IsFilteredMsg(s)
	for _, msg in pairs(messages) do
		if s:find(msg) then
			return true
		end
	end
end

-- print to main chat frame
local function OnEvent(self, event, msg)
	if IsFilteredMsg(msg) then
		DEFAULT_CHAT_FRAME:AddMessage(msg, 1, 1, 0)
	end
end

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

-- filter default one
local function filter(self, event, msg)
	return IsFilteredMsg(msg)
end

ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", filter)
1 Like

Getting there! Promotion and Guild join worked, but Demotion and Leave guild still showed up in General window. Thank you so very much for helping with this! I’ll try to troubleshoot on my own, but if you had suggestions, they’d certainly be more than welcome!

** update** Think I found what I needed - ERR_GUILD_DEMOTE_SS and ERR_GUILD_LEAVE_S. I’ll post results after more testing.

1 Like