Advertisement
WhenNightFalls

ROBLOX Chat Filter BYPASS V0.0.1

Feb 11th, 2022
7,108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.72 KB | None | 0 0
  1. _G.Bypass = true
  2. local chatService = game:GetService("Chat")
  3.  
  4. local path = chatService.ChatServiceRunner.ChatService
  5.  
  6. local clone = path:Clone()
  7. clone.Parent = game.ReplicatedStorage
  8. if _G.Bypass == true then
  9.     path:Destroy()
  10.     script.Parent = chatService.ChatServiceRunner
  11. else
  12.     clone.Parent = chatService.ChatServiceRunner
  13.     script:Destroy()
  14. end
  15.  
  16. --  // FileName: ChatService.lua
  17. --  // Written by: Xsitsu
  18. --  // Description: Manages creating and destroying ChatChannels and Speakers.
  19.  
  20. local MAX_FILTER_RETRIES = 3
  21. local FILTER_BACKOFF_INTERVALS = {50/1000, 100/1000, 200/1000}
  22. local MAX_FILTER_DURATION = 60
  23.  
  24. --- Constants used to decide when to notify that the chat filter is having issues filtering messages.
  25. local FILTER_NOTIFCATION_THRESHOLD = 3 --Number of notifcation failures before an error message is output.
  26. local FILTER_NOTIFCATION_INTERVAL = 60 --Time between error messages.
  27. local FILTER_THRESHOLD_TIME = 60 --If there has not been an issue in this many seconds, the count of issues resets.
  28.  
  29. local module = {}
  30.  
  31. local RunService = game:GetService("RunService")
  32. local Chat = game:GetService("Chat")
  33. local ReplicatedModules = Chat:WaitForChild("ClientChatModules")
  34.  
  35. local modulesFolder = script.Parent
  36. local ReplicatedModules = Chat:WaitForChild("ClientChatModules")
  37. local ChatSettings = require(ReplicatedModules:WaitForChild("ChatSettings"))
  38.  
  39. local errorTextColor = ChatSettings.ErrorMessageTextColor or Color3.fromRGB(245, 50, 50)
  40. local errorExtraData = {ChatColor = errorTextColor}
  41.  
  42. --////////////////////////////// Include
  43. --//////////////////////////////////////
  44. local ChatConstants = require(ReplicatedModules:WaitForChild("ChatConstants"))
  45.  
  46. local ChatChannel = require(modulesFolder:WaitForChild("ChatChannel"))
  47. local Speaker = require(modulesFolder:WaitForChild("Speaker"))
  48. local Util = require(modulesFolder:WaitForChild("Util"))
  49.  
  50. local ChatLocalization = nil
  51. pcall(function() ChatLocalization = require(game:GetService("Chat").ClientChatModules.ChatLocalization :: any) end)
  52. ChatLocalization = ChatLocalization or {}
  53.  
  54. if not ChatLocalization.FormatMessageToSend or not ChatLocalization.LocalizeFormattedMessage then
  55.     function ChatLocalization:FormatMessageToSend(key,default) return default end
  56. end
  57.  
  58. local function allSpaces(inputString)
  59.     local testString = string.gsub(inputString, " ", "")
  60.     return string.len(testString) == 0
  61. end
  62.  
  63. --////////////////////////////// Methods
  64. --//////////////////////////////////////
  65. local methods = {}
  66. methods.__index = methods
  67.  
  68. function methods:AddChannel(channelName, autoJoin)
  69.     if (self.ChatChannels[channelName:lower()]) then
  70.         error(string.format("Channel %q alrady exists.", channelName))
  71.     end
  72.  
  73.     local function DefaultChannelCommands(fromSpeaker, message)
  74.         if (message:lower() == "/leave") then
  75.             local channel = self:GetChannel(channelName)
  76.             local speaker = self:GetSpeaker(fromSpeaker)
  77.             if (channel and speaker) then
  78.                 if (channel.Leavable) then
  79.                     speaker:LeaveChannel(channelName)
  80.                     local msg = ChatLocalization:FormatMessageToSend(
  81.                         "GameChat_ChatService_YouHaveLeftChannel",
  82.                         string.format("You have left channel '%s'", channelName),
  83.                         "RBX_NAME",
  84.                         channelName)
  85.                     speaker:SendSystemMessage(msg, "System")
  86.                 else
  87.                     speaker:SendSystemMessage(ChatLocalization:FormatMessageToSend("GameChat_ChatService_CannotLeaveChannel","You cannot leave this channel."), channelName)
  88.                 end
  89.             end
  90.  
  91.             return true
  92.         end
  93.         return false
  94.     end
  95.  
  96.  
  97.     local channel = ChatChannel.new(self, channelName)
  98.     self.ChatChannels[channelName:lower()] = channel
  99.  
  100.     channel:RegisterProcessCommandsFunction("default_commands", DefaultChannelCommands, ChatConstants.HighPriority)
  101.  
  102.     local success, err = pcall(function() self.eChannelAdded:Fire(channelName) end)
  103.     if not success and err then
  104.         print("Error addding channel: " ..err)
  105.     end
  106.  
  107.     if autoJoin ~= nil then
  108.         channel.AutoJoin = autoJoin
  109.         if autoJoin then
  110.             for _, speaker in pairs(self.Speakers) do
  111.                 speaker:JoinChannel(channelName)
  112.             end
  113.         end
  114.     end
  115.  
  116.     return channel
  117. end
  118.  
  119. function methods:RemoveChannel(channelName)
  120.     if (self.ChatChannels[channelName:lower()]) then
  121.         local n = self.ChatChannels[channelName:lower()].Name
  122.  
  123.         self.ChatChannels[channelName:lower()]:InternalDestroy()
  124.         self.ChatChannels[channelName:lower()] = nil
  125.  
  126.         local success, err = pcall(function() self.eChannelRemoved:Fire(n) end)
  127.         if not success and err then
  128.             print("Error removing channel: " ..err)
  129.         end
  130.     else
  131.         warn(string.format("Channel %q does not exist.", channelName))
  132.     end
  133. end
  134.  
  135. function methods:GetChannel(channelName)
  136.     return self.ChatChannels[channelName:lower()]
  137. end
  138.  
  139.  
  140. function methods:AddSpeaker(speakerName)
  141.     if (self.Speakers[speakerName:lower()]) then
  142.         error("Speaker \"" .. speakerName .. "\" already exists!")
  143.     end
  144.  
  145.     local speaker = Speaker.new(self, speakerName)
  146.     self.Speakers[speakerName:lower()] = speaker
  147.  
  148.     local success, err = pcall(function() self.eSpeakerAdded:Fire(speakerName) end)
  149.     if not success and err then
  150.         print("Error adding speaker: " ..err)
  151.     end
  152.  
  153.     return speaker
  154. end
  155.  
  156. function methods:InternalUnmuteSpeaker(speakerName)
  157.     for channelName, channel in pairs(self.ChatChannels) do
  158.         if channel:IsSpeakerMuted(speakerName) then
  159.             channel:UnmuteSpeaker(speakerName)
  160.         end
  161.     end
  162. end
  163.  
  164. function methods:RemoveSpeaker(speakerName)
  165.     if (self.Speakers[speakerName:lower()]) then
  166.         local n = self.Speakers[speakerName:lower()].Name
  167.  
  168.         self:InternalUnmuteSpeaker(n)
  169.  
  170.         self.Speakers[speakerName:lower()]:InternalDestroy()
  171.         self.Speakers[speakerName:lower()] = nil
  172.  
  173.         local success, err = pcall(function() self.eSpeakerRemoved:Fire(n) end)
  174.         if not success and err then
  175.             print("Error removing speaker: " ..err)
  176.         end
  177.  
  178.     else
  179.         warn("Speaker \"" .. speakerName .. "\" does not exist!")
  180.     end
  181. end
  182.  
  183. function methods:GetSpeaker(speakerName)
  184.     return self.Speakers[speakerName:lower()]
  185. end
  186.  
  187. function methods:GetSpeakerByUserOrDisplayName(speakerName)
  188.     local speakerByUserName = self.Speakers[speakerName:lower()]
  189.  
  190.     if speakerByUserName then
  191.         return speakerByUserName
  192.     end
  193.  
  194.     for _, potentialSpeaker in pairs(self.Speakers) do
  195.         local player = potentialSpeaker:GetPlayer()
  196.  
  197.         if player and player.DisplayName:lower() == speakerName:lower() then
  198.             return potentialSpeaker
  199.         end
  200.     end
  201. end
  202.  
  203. function methods:GetChannelList()
  204.     local list = {}
  205.     for i, channel in pairs(self.ChatChannels) do
  206.         if (not channel.Private) then
  207.             table.insert(list, channel.Name)
  208.         end
  209.     end
  210.     return list
  211. end
  212.  
  213. function methods:GetAutoJoinChannelList()
  214.     local list = {}
  215.     for i, channel in pairs(self.ChatChannels) do
  216.         if channel.AutoJoin then
  217.             table.insert(list, channel)
  218.         end
  219.     end
  220.     return list
  221. end
  222.  
  223. function methods:GetSpeakerList()
  224.     local list = {}
  225.     for i, speaker in pairs(self.Speakers) do
  226.         table.insert(list, speaker.Name)
  227.     end
  228.     return list
  229. end
  230.  
  231. function methods:SendGlobalSystemMessage(message)
  232.     for i, speaker in pairs(self.Speakers) do
  233.         speaker:SendSystemMessage(message, nil)
  234.     end
  235. end
  236.  
  237. function methods:RegisterFilterMessageFunction(funcId, func, priority)
  238.     if self.FilterMessageFunctions:HasFunction(funcId) then
  239.         error(string.format("FilterMessageFunction '%s' already exists", funcId))
  240.     end
  241.     self.FilterMessageFunctions:AddFunction(funcId, func, priority)
  242. end
  243.  
  244. function methods:FilterMessageFunctionExists(funcId)
  245.     return self.FilterMessageFunctions:HasFunction(funcId)
  246. end
  247.  
  248. function methods:UnregisterFilterMessageFunction(funcId)
  249.     if not self.FilterMessageFunctions:HasFunction(funcId) then
  250.         error(string.format("FilterMessageFunction '%s' does not exists", funcId))
  251.     end
  252.     self.FilterMessageFunctions:RemoveFunction(funcId)
  253. end
  254.  
  255. function methods:RegisterProcessCommandsFunction(funcId, func, priority)
  256.     if self.ProcessCommandsFunctions:HasFunction(funcId) then
  257.         error(string.format("ProcessCommandsFunction '%s' already exists", funcId))
  258.     end
  259.     self.ProcessCommandsFunctions:AddFunction(funcId, func, priority)
  260. end
  261.  
  262. function methods:ProcessCommandsFunctionExists(funcId)
  263.     return self.ProcessCommandsFunctions:HasFunction(funcId)
  264. end
  265.  
  266. function methods:UnregisterProcessCommandsFunction(funcId)
  267.     if not self.ProcessCommandsFunctions:HasFunction(funcId) then
  268.         error(string.format("ProcessCommandsFunction '%s' does not exist", funcId))
  269.     end
  270.     self.ProcessCommandsFunctions:RemoveFunction(funcId)
  271. end
  272.  
  273. local LastFilterNoficationTime = 0
  274. local LastFilterIssueTime = 0
  275. local FilterIssueCount = 0
  276. function methods:InternalNotifyFilterIssue()
  277.     if (tick() - LastFilterIssueTime) > FILTER_THRESHOLD_TIME then
  278.         FilterIssueCount = 0
  279.     end
  280.     FilterIssueCount = FilterIssueCount + 1
  281.     LastFilterIssueTime = tick()
  282.     if FilterIssueCount >= FILTER_NOTIFCATION_THRESHOLD then
  283.         if (tick() - LastFilterNoficationTime) > FILTER_NOTIFCATION_INTERVAL then
  284.             LastFilterNoficationTime = tick()
  285.             local systemChannel = self:GetChannel("System")
  286.             if systemChannel then
  287.                 systemChannel:SendSystemMessage(
  288.                     ChatLocalization:FormatMessageToSend(
  289.                         "GameChat_ChatService_ChatFilterIssues",
  290.                         "The chat filter is currently experiencing issues and messages may be slow to appear."
  291.                     ),
  292.                     errorExtraData
  293.                 )
  294.             end
  295.         end
  296.     end
  297. end
  298.  
  299. local StudioMessageFilteredCache = {}
  300.  
  301. --///////////////// Internal-Use Methods
  302. --//////////////////////////////////////
  303. --DO NOT REMOVE THIS. Chat must be filtered or your game will face
  304. --moderation.
  305.  
  306.  
  307. function methods:InternalDoProcessCommands(speakerName, message, channel)
  308.     local commandsIterator = self.ProcessCommandsFunctions:GetIterator()
  309.  
  310.     for funcId, func, priority in commandsIterator do
  311.         local success, returnValue = pcall(function()
  312.             local ret = func(speakerName, message, channel)
  313.             if type(ret) ~= "boolean" then
  314.                 error("Process command functions must return a bool")
  315.             end
  316.             return ret
  317.         end)
  318.  
  319.         if not success then
  320.             warn(string.format("DoProcessCommands Function '%s' failed for reason: %s", funcId, returnValue))
  321.         elseif returnValue then
  322.             return true
  323.         end
  324.     end
  325.  
  326.     return false
  327. end
  328.  
  329. function methods:InternalGetUniqueMessageId()
  330.     local id = self.MessageIdCounter
  331.     self.MessageIdCounter = id + 1
  332.     return id
  333. end
  334.  
  335. function methods:InternalAddSpeakerWithPlayerObject(speakerName, playerObj, fireSpeakerAdded)
  336.     if (self.Speakers[speakerName:lower()]) then
  337.         error("Speaker \"" .. speakerName .. "\" already exists!")
  338.     end
  339.  
  340.     local speaker = Speaker.new(self, speakerName)
  341.     speaker:InternalAssignPlayerObject(playerObj)
  342.     self.Speakers[speakerName:lower()] = speaker
  343.  
  344.     if fireSpeakerAdded then
  345.         local success, err = pcall(function() self.eSpeakerAdded:Fire(speakerName) end)
  346.         if not success and err then
  347.             print("Error adding speaker: " ..err)
  348.         end
  349.     end
  350.  
  351.     return speaker
  352. end
  353.  
  354. function methods:InternalFireSpeakerAdded(speakerName)
  355.     local success, err = pcall(function() self.eSpeakerAdded:Fire(speakerName) end)
  356.     if not success and err then
  357.         print("Error firing speaker added: " ..err)
  358.     end
  359. end
  360.  
  361. --///////////////////////// Constructors
  362. --//////////////////////////////////////
  363.  
  364. function module.new()
  365.     local obj = setmetatable({}, methods)
  366.  
  367.     obj.MessageIdCounter = 0
  368.  
  369.     obj.ChatChannels = {}
  370.     obj.Speakers = {}
  371.  
  372.     obj.FilterMessageFunctions = Util:NewSortedFunctionContainer()
  373.     obj.ProcessCommandsFunctions = Util:NewSortedFunctionContainer()
  374.  
  375.     obj.eChannelAdded = Instance.new("BindableEvent")
  376.     obj.eChannelRemoved = Instance.new("BindableEvent")
  377.     obj.eSpeakerAdded = Instance.new("BindableEvent")
  378.     obj.eSpeakerRemoved = Instance.new("BindableEvent")
  379.  
  380.     obj.ChannelAdded = obj.eChannelAdded.Event
  381.     obj.ChannelRemoved = obj.eChannelRemoved.Event
  382.     obj.SpeakerAdded = obj.eSpeakerAdded.Event
  383.     obj.SpeakerRemoved = obj.eSpeakerRemoved.Event
  384.  
  385.     obj.ChatServiceMajorVersion = 0
  386.     obj.ChatServiceMinorVersion = 5
  387.  
  388.     return obj
  389. end
  390.  
  391. return module.new()
  392.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement