function methods.InternalApplyRobloxFilterNewAPI(t,V,E,s)local H=false local Y=false if H or Y then local H=t:GetSpeaker(V)if H==nil then return false,nil,nil end local Y=H:GetPlayer()if Y==nil then return true,false,E end if allSpaces(E)then return true,false,E end local h,C=pcall(function()local V=game:GetService("\084\101\120\116\083\101\114\118\105\099\101")local t=V:FilterStringAsync(E,Y.UserId,s)return t end)if h then return true,true,C else warn("\069\114\114\111\114 \102\105\108\116\101\114\105\110\103 \109\101\115\115\097\103\101\058",E,C)t:InternalNotifyFilterIssue()return false,nil,nil end end wait()return true,false,E end function methods.InternalDoMessageFilter(t,V,E,s)local H=t.FilterMessageFunctions:GetIterator()for t,H,Y in H do local h,C=pcall(function()H(V,E,s)end)if not h then warn(string.format("\068\111\077\101\115\115\097\103\101\070\105\108\116\101\114 \070\117\110\099\116\105\111\110 \'\037\115\' \102\097\105\108\101\100 \102\111\114 \114\101\097\115\111\110\058 \037\115",t,C))end end end function methods.InternalDoProcessCommands(t,V,E,s)local H=t.ProcessCommandsFunctions:GetIterator()for t,H,Y in H do local h,C=pcall(function()local t=H(V,E,s)if type(t)~="\098\111\111\108\101\097\110"then error("\080\114\111\099\101\115\115 \099\111\109\109\097\110\100 \102\117\110\099\116\105\111\110\115 \109\117\115\116 \114\101\116\117\114\110 \097 \098\111\111\108")end return t end)if not h then warn(string.format("\068\111\080\114\111\099\101\115\115\067\111\109\109\097\110\100\115 \070\117\110\099\116\105\111\110 \'\037\115\' \102\097\105\108\101\100 \102\111\114 \114\101\097\115\111\110\058 \037\115",t,C))elseif C then return true end end return false end function methods.InternalGetUniqueMessageId(V)local E=V.MessageIdCounter V.MessageIdCounter=E+1 return E end function methods.InternalAddSpeakerWithPlayerObject(t,V,E,s)if t.Speakers[V:lower()]then error("\083\112\101\097\107\101\114 \""..(V.."\" \097\108\114\101\097\100\121 \101\120\105\115\116\115\033"))end local H=Speaker.new(t,V)H:InternalAssignPlayerObject(E)t.Speakers[V:lower()]=H if s then local E,s=pcall(function()t.eSpeakerAdded:Fire(V)end)if not E and s then print("\069\114\114\111\114 \097\100\100\105\110\103 \115\112\101\097\107\101\114\058 "..s)end end return H end function methods.InternalFireSpeakerAdded(E,V)local s,t=pcall(function()E.eSpeakerAdded:Fire(V)end)if not s and t then print("\069\114\114\111\114 \102\105\114\105\110\103 \115\112\101\097\107\101\114 \097\100\100\101\100\058 "..t)end end

function methods:InternalApplyRobloxFilterNewAPI(speakerName, message, textFilterContext) --// USES FFLAG
	local alwaysRunFilter = false
	local runFilter = false
	if (alwaysRunFilter or runFilter) then

		local fromSpeaker = self:GetSpeaker(speakerName)
		if fromSpeaker == nil then
			return false, nil, nil
		end

		local fromPlayerObj = fromSpeaker:GetPlayer()
		if fromPlayerObj == nil then
			return true, false, message
		end

		if allSpaces(message) then
			return true, false, message
		end

		local success, filterResult = pcall(function()
			local ts = game:GetService("TextService")
			local result = ts:FilterStringAsync(message, fromPlayerObj.UserId, textFilterContext)
			return result
		end)
		if (success) then
			return true, true, filterResult
		else
			warn("Error filtering message:", message, filterResult)
			self:InternalNotifyFilterIssue()
			return false, nil, nil
		end
	end

	--// Simulate filtering latency.
	wait()
	return true, false, message
end

function methods:InternalDoMessageFilter(speakerName, messageObj, channel)
	local filtersIterator = self.FilterMessageFunctions:GetIterator()

	for funcId, func, priority in filtersIterator do
		local success, errorMessage = pcall(function()
			func(speakerName, messageObj, channel)
		end)

		if not success then
			warn(string.format("DoMessageFilter Function '%s' failed for reason: %s", funcId, errorMessage))
		end
	end
end

function methods:InternalDoProcessCommands(speakerName, message, channel)
	local commandsIterator = self.ProcessCommandsFunctions:GetIterator()

	for funcId, func, priority in commandsIterator do
		local success, returnValue = pcall(function()
			local ret = func(speakerName, message, channel)
			if type(ret) ~= "boolean" then
				error("Process command functions must return a bool")
			end
			return ret
		end)

		if not success then
			warn(string.format("DoProcessCommands Function '%s' failed for reason: %s", funcId, returnValue))
		elseif returnValue then
			return true
		end
	end

	return false
end

function methods:InternalGetUniqueMessageId()
	local id = self.MessageIdCounter
	self.MessageIdCounter = id + 1
	return id
end

function methods:InternalAddSpeakerWithPlayerObject(speakerName, playerObj, fireSpeakerAdded)
	if (self.Speakers[speakerName:lower()]) then
		error("Speaker \"" .. speakerName .. "\" already exists!")
	end

	local speaker = Speaker.new(self, speakerName)
	speaker:InternalAssignPlayerObject(playerObj)
	self.Speakers[speakerName:lower()] = speaker

	if fireSpeakerAdded then
		local success, err = pcall(function() self.eSpeakerAdded:Fire(speakerName) end)
		if not success and err then
			print("Error adding speaker: " ..err)
		end
	end

	return speaker
end

function methods:InternalFireSpeakerAdded(speakerName)
	local success, err = pcall(function() self.eSpeakerAdded:Fire(speakerName) end)
	if not success and err then
		print("Error firing speaker added: " ..err)
	end
end
