function methods.InternalApplyRobloxFilterNewAPI(y,g,e,V)local b=false local p=false if b or p then local b=y:GetSpeaker(g)if b==nil then return false,nil,nil end local p=b:GetPlayer()if p==nil then return true,false,e end if allSpaces(e)then return true,false,e end local M,E=pcall(function()local g=game:GetService("\084\101\120\116\083\101\114\118\105\099\101")local y=g:FilterStringAsync(e,p.UserId,V)return y end)if M then return true,true,E 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,E)y:InternalNotifyFilterIssue()return false,nil,nil end end wait()return true,false,e end function methods.InternalDoMessageFilter(y,g,e,V)local b=y.FilterMessageFunctions:GetIterator()for y,b,p in b do local M,E=pcall(function()b(g,e,V)end)if not M 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",y,E))end end end function methods.InternalDoProcessCommands(y,g,e,V)local b=y.ProcessCommandsFunctions:GetIterator()for y,b,p in b do local M,E=pcall(function()local y=b(g,e,V)if type(y)~="\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 y end)if not M 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",y,E))elseif E then return true end end return false end function methods.InternalGetUniqueMessageId(g)local e=g.MessageIdCounter g.MessageIdCounter=e+1 return e end function methods.InternalAddSpeakerWithPlayerObject(y,g,e,V)if y.Speakers[g:lower()]then error("\083\112\101\097\107\101\114 \""..(g.."\" \097\108\114\101\097\100\121 \101\120\105\115\116\115\033"))end local b=Speaker.new(y,g)b:InternalAssignPlayerObject(e)y.Speakers[g:lower()]=b if V then local e,V=pcall(function()y.eSpeakerAdded:Fire(g)end)if not e and V then print("\069\114\114\111\114 \097\100\100\105\110\103 \115\112\101\097\107\101\114\058 "..V)end end return b end function methods.InternalFireSpeakerAdded(e,g)local V,y=pcall(function()e.eSpeakerAdded:Fire(g)end)if not V and y 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 "..y)end end
--// Return values: bool filterSuccess, bool resultIsFilterObject, variant result
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
