Fix for auto joining services channel (10.2.6)

Edit: Here’s an addon to workaround this bug. Read posts below if you want more info.

https://www.curseforge.com/wow/addons/leave-spam-channels

3 Likes

If you want a DIY addon you can use this for the moment. Curse is slow. Next post will have a downloadable link, probably.

https://addon.bool.no

local spamWindow 	= 1 -- general/spam window
local tradeWindow 	= 1 --  trade window
local leaveGeneral 	= false
local leaveTrade 	= false
local leaveDefense 	= true
local leaveServices = true
local announce	 	= true
local addon 		= ...
local f 			= CreateFrame("Frame")
local msgcolor 		= BLUE_FONT_COLOR
local chatframe 	= SELECTED_CHAT_FRAME
local disable 		= false

local function printf(msg)
	if not msg then return end
	local output = (addon..": "..msg)
	local colorstring = msgcolor:WrapTextInColorCode(output)
	chatframe:AddMessage(colorstring)
end

local function initchannels()
	local c,d,e = EnumerateServerChannels()
	if c == "General" and not leaveGeneral then JoinPermanentChannel(c) end
	if d == "Trade" and not leaveTrade then JoinPermanentChannel(d) end
	if e == "LocalDefense" and not leaveDefense then JoinPermanentChannel(e) end
end

local function defaults()
	f:SetScript("OnEvent", nil)
	f:UnregisterEvent("CHANNEL_UI_UPDATE")
	JoinChannelByName("General")
	JoinChannelByName("Trade")
	JoinChannelByName("LocalDefense")
	JoinChannelByName("Services")
	for i = 1, 10 do
		local cf = _G["ChatFrame"..i]
		if i == 1 then
			ChatFrame_AddChannel(cf, "General")
			ChatFrame_AddChannel(cf, "Trade")
			ChatFrame_AddChannel(cf, "LocalDefense")
			ChatFrame_AddChannel(cf, "Services")
		else
			ChatFrame_RemoveChannel(cf, "General")
			ChatFrame_RemoveChannel(cf, "Trade")
			ChatFrame_RemoveChannel(cf, "LocalDefense")
			ChatFrame_RemoveChannel(cf, "Services")
		end
	end
end

local function fixwindows()
	if leaveServices then LeaveChannelByName("Services") end
	if leaveDefense then LeaveChannelByName("LocalDefense") end
	if leaveTrade then LeaveChannelByName("Trade") end
	if leaveGeneral then LeaveChannelByName("General") end
	for i = 1, 10 do
		local cf = _G["ChatFrame"..i]
		if i == spamWindow then
			if not leaveGeneral then ChatFrame_AddChannel(cf, "General") end
			if not leaveTrade then ChatFrame_AddChannel(cf, "Trade") end
			if not leaveDefense then ChatFrame_AddChannel(cf, "LocalDefense") end
			if not leaveServices then ChatFrame_AddChannel(cf, "Services") end
			ChatFrame_AddChannel(cf, "NewcomerChat")
		else
			ChatFrame_RemoveChannel(cf, "General")
			ChatFrame_RemoveChannel(cf, "Trade")
			ChatFrame_RemoveChannel(cf, "LocalDefense")
			ChatFrame_RemoveChannel(cf, "Services")
			ChatFrame_RemoveChannel(cf, "NewcomerChat")
		end
	end
	if not leaveTrade then
		if tradeWindow ~= spamWindow then
			local tf = _G["ChatFrame"..tradeWindow]
			local cf = _G["ChatFrame"..spamWindow]
			ChatFrame_AddChannel(tf, "Trade")
			ChatFrame_RemoveChannel(cf, "Trade")
		end
	end
end

local function OnEvent(self, event, arg1, ...)
	if event == "CHANNEL_UI_UPDATE" then
		initchannels()
		fixwindows()
	end
	if event == "PLAYER_ENTERING_WORLD" then
		if arg1 then -- login
			C_Timer.After(7, function()
				initchannels()
				fixwindows()
			end)
			if announce then printf("Type /lsc then /reload if you have any issues.") end
			if disable then -- disable addon via update
				DisableAddOn(addon, UnitName("player"))
				f:UnregisterAllEvents()
				f:SetScript("OnEvent", nil)
				printf("Addon has been disabled.")
			end
		else -- reload/instance change
			C_Timer.After(7, function()
				initchannels()
				fixwindows()
			end)
		end
	end
end

SlashCmdList["LEAVESPAMCHANNELS"] = function()
	printf("Restoring default channel layout.")
	defaults() -- restore default channels
end
SLASH_LEAVESPAMCHANNELS1 = '/lsc'

f:SetScript("OnEvent", OnEvent)
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:RegisterEvent("CHANNEL_UI_UPDATE")

There’s probably a smarter way to check if you’re joined to channels on login but this will work for now.

1 Like

This addon leaves the ‘Services’ channel permanently but retains ‘Trade’ and ‘General’.

These two channels are filtered OFF for all chat windows apart from the specified ‘spam’ window; which in this case is chat frame 1 (configurable).

https://www.curseforge.com/wow/addons/leave-spam-channels

If you used a version of this addon from earlier today just overwrite it with the updated one above.

If you need to re-enable any missing channels just type:

/join General
/Join Trade
/Join Services

Or type /lsc.

2 Likes

if since the recent patch you are having an issue with all channels showing again every time you log in, I found a workaround using the Prat addon https://www.curseforge.com/wow/addons/prat-3-0

Install the Prat addon, setup your chat as you like it then go to Options>Addons>Prat>Extra Stuff>Memory
Click Save Settings and tick Load Settings Automatically
(for alts set them all to the same profile e.g. default)

Note: when logging in it takes a couple of seconds for the settings to load so you will get some initial spam but then its fine

5 Likes

Yeah, it took me a few tries to eliminate that initial spam with my addon. I think I nailed it though and it’s on curse now too.

https://www.curseforge.com/wow/addons/leave-spam-channels

Addon updated.

Some bugfixes to restore channels that were manually removed/missing on first login. Typing /lsc will restore default channels. The code in the post above has also been updated.

If you have any issues just type /lsc and then /reload. Or, you can type /lsc, logout and remove my addon. The channel layout will be back to new player default (channels in window 1)

1 Like

Great Fix! -
Setting load Auto removed the intial spam i got after relogging.

Thanks for the addon!

If we wish to have General & LocalDefense in the default main chat box, but have Trade in its own window – what changes will need to be made to the source code?

I’ve hacked in a quick method in the latest version(6). Just change the trade window number variable at the top of the .lua file to whatever you want.

2 Likes

bump this dude pls, literraly lifesaver.

1 Like

The bug is now fixed I believe.

You can delete this addon or just update to the latest version(7) and it will disable itself whenever you log in.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.