Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Chattynator.toc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Core/Overrides.lua
Core/Initialize.lua
Core/SlashCmd.lua
Core/CommandHistory.lua
Core/TellTarget.lua
Core/Dialogs.lua

API/Main.lua
Expand Down
1 change: 1 addition & 0 deletions Core/Config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ local settings = {
CLASS_COLORS = {key = "class_colors", default = true, refresh = {addonTable.Constants.RefreshReason.MessageModifier}},
LINK_URLS = {key = "link_urls", default = true, refresh = {addonTable.Constants.RefreshReason.MessageModifier}},
REDUCE_REDUNDANT_TEXT = {key = "reduce_redundant_text", default = false, refresh = {addonTable.Constants.RefreshReason.MessageModifier}},
ENABLE_TELL_TARGET = {key = "enable_tell_target", default = true},

NEW_WHISPER_NEW_TAB = {key = "new_whisper_new_tab", default = 0},
BUTTON_POSITION = {key = "button_position", default = "outside_left"},
Expand Down
1 change: 1 addition & 0 deletions Core/Initialize.lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ function addonTable.Core.Initialize()

addonTable.Core.ApplyOverrides()
addonTable.Core.InitializeChatCommandLogging()
addonTable.Core.InitializeTellTarget()
addonTable.Modifiers.InitializeShortenChannels()
addonTable.Modifiers.InitializeClassColors()
addonTable.Modifiers.InitializeURLs()
Expand Down
78 changes: 78 additions & 0 deletions Core/TellTarget.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---@class addonTableChattynator
local addonTable = select(2, ...)

local ChatEdit_UpdateHeader = _G.ChatEdit_UpdateHeader or _G.ChatFrameEditBoxMixin.UpdateHeader

function addonTable.Core.InitializeTellTarget()
local function OnTextChanged(editBox)
if not addonTable.Config.Get(addonTable.Config.Options.ENABLE_TELL_TARGET) then
return
end
local text = editBox:GetText()
local command, msg = text:match("^(/%S+)%s(.*)$")
if command == "/tt" or command == "/telltarget" then
local unitname, realm, fullname
if UnitIsPlayer("target") then
unitname, realm = UnitName("target")
if unitname then
if realm and UnitRealmRelationship("target") ~= LE_REALM_RELATION_SAME then
fullname = unitname .. "-" .. realm
else
fullname = unitname
end
end
end

if fullname then
local target = fullname:gsub(" ", "")
editBox:SetAttribute("chatType", "WHISPER")
editBox:SetAttribute("tellTarget", target)
editBox:SetText(msg or "")
ChatEdit_UpdateHeader(editBox)
else
if not UnitExists("target") then
addonTable.Utilities.Message(addonTable.Locales.TT_NO_TARGET or "No target selected.")
elseif not UnitIsPlayer("target") then
addonTable.Utilities.Message(addonTable.Locales.TT_NOT_PLAYER or "Target is not a player.")
end
editBox:SetText("")
end
end
end

ChatFrame1EditBox:HookScript("OnTextChanged", OnTextChanged)

SlashCmdList["ChattynatorTellTarget"] = function(msg)
if not addonTable.Config.Get(addonTable.Config.Options.ENABLE_TELL_TARGET) then
return
end
local unitname, realm, fullname
if UnitIsPlayer("target") then
unitname, realm = UnitName("target")
if unitname then
if realm and UnitRealmRelationship("target") ~= LE_REALM_RELATION_SAME then
fullname = unitname .. "-" .. realm
else
fullname = unitname
end
end
end

if fullname then
local target = fullname:gsub(" ", "")
ChatFrame1EditBox:SetAttribute("chatType", "WHISPER")
ChatFrame1EditBox:SetAttribute("tellTarget", target)
ChatFrame1EditBox:SetText(msg or "")
ChatEdit_UpdateHeader(ChatFrame1EditBox)
ChatFrame_OpenChat(msg or "", ChatFrame1)
else
if not UnitExists("target") then
addonTable.Utilities.Message(addonTable.Locales.TT_NO_TARGET or "No target selected.")
elseif not UnitIsPlayer("target") then
addonTable.Utilities.Message(addonTable.Locales.TT_NOT_PLAYER or "Target is not a player.")
end
end
end
SLASH_ChattynatorTellTarget1 = "/tt"
SLASH_ChattynatorTellTarget2 = "/telltarget"
end
7 changes: 7 additions & 0 deletions CustomiseDialog/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,13 @@ local function SetupFormatting(parent)
reduceRedundantText:SetPoint("TOP", allFrames[#allFrames], "BOTTOM")
table.insert(allFrames, reduceRedundantText)

local enableTellTarget = addonTable.CustomiseDialog.Components.GetCheckbox(container, addonTable.Locales.ENABLE_TELL_TARGET, 28, function(state)
addonTable.Config.Set(addonTable.Config.Options.ENABLE_TELL_TARGET, state)
end)
enableTellTarget.option = addonTable.Config.Options.ENABLE_TELL_TARGET
enableTellTarget:SetPoint("TOP", allFrames[#allFrames], "BOTTOM")
table.insert(allFrames, enableTellTarget)

container:SetScript("OnShow", function()
for _, f in ipairs(allFrames) do
if f.SetValue then
Expand Down
4 changes: 4 additions & 0 deletions Locales.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ L["SLASH_RESET_HELP"] = "Reset all Chattynator settings, then reload."
L["SLASH_HELP"] = "Open the Chattynator settings."
L["SLASH_UNKNOWN_COMMAND"] = "Unknown command '%s'"

L["TT_NO_TARGET"] = "No target selected."
L["TT_NOT_PLAYER"] = "Target is not a player."
L["ENABLE_TELL_TARGET"] = "Enable /tt command"

local L = Locales.frFR
--@localization(locale="frFR", format="lua_additive_table")@

Expand Down