Files
ShaguTweaks-ClassicAPI/mods/world-chat-hider.lua
T
OEVGandClaude Opus 5.5 2c58ce2aa3 Merge the ShaguTweaks Extras ClassicAPI modules into ShaguTweaks (3.7)
Bring in 27 module files from Dusk/ShaguTweaks-Extras-ClassicAPI
(8e14bb4): action bar, chat, loot, macro, merchant (Buy Em All),
minimap & world map, tooltip and unit frame modules, with their
textures. Titles are unchanged, so saved toggles carry over.

- Categories: Chat -> Chat & Social, World Map -> Minimap & World Map,
  Merchant & Auction -> Merchant; Macro is a new category.
- Texture paths point at ShaguTweaks\img.
- Not merged: Raid Frames, Bag Item Click and Bag Search Bar (Bagshui
  covers them), Auction Alt-Buy (aux covers it).
- Chat note when the old ShaguTweaks-extras addon is still enabled.
- English translation keys, notices, license copy, asset provenance,
  README, changelog and version 3.7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019W3rwusM4i1CYaHQAYixJ7
2026-11-02 21:52:53 +00:00

60 lines
1.6 KiB
Lua
Executable File

-- Adapted from TokensWorth/ShaguTweaks-mods (MIT, original copyright GryllsAddons).
local T = ShaguTweaks.T
local Filter = ShaguTweaks.ExtrasChatFilter
local module = ShaguTweaks:register({
title = T["World Chat Hider"],
description = T["Hides World channel messages while inside an instance without leaving the channel."],
expansions = { ["vanilla"] = true, ["tbc"] = nil },
category = T["Chat & Social"],
enabled = nil,
})
local function IsInsideInstance()
if type(IsInInstance) ~= "function" then return false end
local inside = IsInInstance()
return inside == 1 or inside == true
end
local function IsWorldChannel()
-- Vanilla 1.12 CHAT_MSG_CHANNEL exposes the base channel name in arg9.
-- Custom channel names are not localized, so comparing the actual event is
-- both cheaper and safer than querying GetChannelName("world") every time.
if arg9 and string.lower(arg9) == "world" then
return true
end
-- Conservative fallback for clients that omit arg9: arg4 is the numbered
-- channel label (for example "5. World").
if arg4 then
local full = string.lower(arg4)
if full == "world" then return true end
local _, _, base = string.find(full, "^%d+%.%s*(.+)$")
if base == "world" then return true end
end
return false
end
local function FilterWorldChat(event)
if event ~= "CHAT_MSG_CHANNEL" then return false end
if not IsInsideInstance() then return false end
return IsWorldChannel()
end
module.enable = function(self)
if Filter then
Filter:Register("WorldChatHider", FilterWorldChat)
end
end
module.disable = function(self)
if Filter then
Filter:Unregister("WorldChatHider")
end
end