Advertisement
NoTextForSpeech

test

Sep 12th, 2024
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.60 KB | None | 0 0
  1. -- made by @officiallymelon for celery :3 https://raw.githubusercontent.com/OfficiallyMelon/BetterDecompiler/main/main.lua
  2. --[[
  3.     BetterDecompiler:
  4.     Uses your standard executor decompile function,
  5.     Passes through an AI (such as gpt-3.5 or gpt-4),
  6.     Returns cleaned variable and func named output.
  7.  
  8.     Usage:
  9.  
  10.     decompile(script_instance, bool_value, custom_url)
  11.  
  12.     script_instance: being the LocalScript you want to decompile.
  13.     bool_value: (true or false) whether you want BetterDecompiler enabled or not
  14.     custom_url: (url string) whether you want to use a custom link (or port) for the AI. OPTIONAL PARAMETER
  15. ]]
  16.  
  17. local BetterDecompiler = {}
  18.  
  19. -- Alias the original decompile function
  20. local originalDecompile = decompile
  21.  
  22. -- Sends request to our local port :3
  23. function BetterDecompiler.cleanScript(uncleanScript, custom_url)
  24.     local HttpService = game:GetService("HttpService")
  25.     local url = custom_url or "https://decompilefake.vercel.app/api"
  26.    
  27.     local requestBody = {
  28.         script = uncleanScript
  29.     }
  30.    
  31.     local headers = {
  32.         ["Content-Type"] = "application/json"
  33.     }
  34.    
  35.     local jsonBody = HttpService:JSONEncode(requestBody)
  36.    
  37.     local success, response = pcall(function()
  38.         local result = request({
  39.             Url = url,
  40.             Method = "POST",
  41.             Headers = headers,
  42.             Body = jsonBody
  43.         })
  44.        
  45.         if result and result.StatusCode == 200 then
  46.             local resultData = HttpService:JSONDecode(result.Body)
  47.             return resultData.fixed_script
  48.         else
  49.             warn("Request failed with status code: " .. (result and result.StatusCode or "unknown"))
  50.             warn("Response body: " .. (result and result.Body or "no response body"))
  51.         end
  52.     end)
  53.    
  54.     if not success then
  55.         warn("An error occurred: " .. response)
  56.     end
  57.    
  58.     return uncleanScript -- Return original script if cleaning fails
  59. end
  60.  
  61.  
  62. function BetterDecompiler.decompile(scr, boolval, custom_url)
  63.     local success, srcScript = pcall(function()
  64.         return originalDecompile(scr) -- returns our decompiled script
  65.     end)
  66.    
  67.     if success and boolval then
  68.         success, srcScript = pcall(function()
  69.             return BetterDecompiler.cleanScript(srcScript, custom_url) -- adds function and variables names
  70.         end)
  71.        
  72.         if not success then
  73.             warn("Clean Script Error: " .. srcScript)
  74.         end
  75.     elseif not success then
  76.         warn("Decompiler Error: " .. srcScript)
  77.     end
  78.    
  79.     return srcScript
  80. end
  81.  
  82. return BetterDecompiler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement