function DoChatBarFocus()if not ChatWindow:GetCoreGuiEnabled()then return end if not ChatBar:GetEnabled()then return end if not ChatBar:IsFocused()and ChatBar:GetVisible()then moduleApiTable:SetVisible(true)InstantFadeIn()ChatBar:CaptureFocus()moduleApiTable.ChatBarFocusChanged:fire(true)end end chatBarFocusChanged.Event:connect(function(e)moduleApiTable.ChatBarFocusChanged:fire(e)end)function DoSwitchCurrentChannel(e)if ChatWindow:GetChannel(e)then ChatWindow:SwitchCurrentChannel(e)end end function SendMessageToSelfInTargetChannel(e,C,N)local L=ChatWindow:GetChannel(C)if L then local H={ID=-1;FromSpeaker=nil;SpeakerUserId=0,OriginalChannel=C;IsFiltered=true,MessageLength=string.len(e);MessageLengthUtf8=utf8.len(utf8.nfcnormalize(e)),Message=trimTrailingSpaces(e);MessageType=ChatConstants.MessageTypeSystem,Time=os.time();ExtraData=N}L:AddMessageToChannel(H)end end function chatBarFocused()if not mouseIsInWindow then DoBackgroundFadeIn()if textIsFaded then DoTextFadeIn()end end chatBarFocusChanged:Fire(true)end
--////////////////////////////////////////////////////////////////////////////////////////////
--///////////////////////////////////////////////// Code to hook client UI up to server events
--////////////////////////////////////////////////////////////////////////////////////////////

function DoChatBarFocus()
	if not ChatWindow:GetCoreGuiEnabled() then
		return
	end
	if not ChatBar:GetEnabled() then
		return
	end

	if not ChatBar:IsFocused() and ChatBar:GetVisible() then
		moduleApiTable:SetVisible(true)
		InstantFadeIn()
		ChatBar:CaptureFocus()
		moduleApiTable.ChatBarFocusChanged:fire(true)
	end
end

chatBarFocusChanged.Event:connect(function(focused)
	moduleApiTable.ChatBarFocusChanged:fire(focused)
end)

function DoSwitchCurrentChannel(targetChannel)
	if ChatWindow:GetChannel(targetChannel) then
		ChatWindow:SwitchCurrentChannel(targetChannel)
	end
end

function SendMessageToSelfInTargetChannel(message, channelName, extraData)
	local channelObj = ChatWindow:GetChannel(channelName)
	if channelObj then
		local messageData = {
			ID = -1,
			FromSpeaker = nil,
			SpeakerUserId = 0,
			OriginalChannel = channelName,
			IsFiltered = true,
			MessageLength = string.len(message),
			MessageLengthUtf8 = utf8.len(utf8.nfcnormalize(message)),
			Message = trimTrailingSpaces(message),
			MessageType = ChatConstants.MessageTypeSystem,
			Time = os.time(),
			ExtraData = extraData,
		}

		channelObj:AddMessageToChannel(messageData)
	end
end

function chatBarFocused()
	if not mouseIsInWindow then
		DoBackgroundFadeIn()
		if textIsFaded then
			DoTextFadeIn()
		end
	end

	chatBarFocusChanged:Fire(true)
end
