Advertisement
ERROR_CODE

ez bot

Nov 29th, 2024 (edited)
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | None | 0 0
  1. -- Создаём ScreenGui
  2. local screenGui = Instance.new("ScreenGui")
  3. screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  4.  
  5. -- Создаём Frame
  6. local frame = Instance.new("Frame")
  7. frame.Size = UDim2.new(0, 300, 0, 200)
  8. frame.Position = UDim2.new(0.5, -150, 0.5, -100)
  9. frame.Parent = screenGui
  10.  
  11. -- Создаём TextLabel
  12. local textLabel = Instance.new("TextLabel")
  13. textLabel.Size = UDim2.new(1, 0, 0.5, 0)
  14. textLabel.Position = UDim2.new(0, 0, 0, 0)
  15. textLabel.Text = "Ответ бота появится здесь"
  16. textLabel.Parent = frame
  17.  
  18. -- Создаём TextBox
  19. local textBox = Instance.new("TextBox")
  20. textBox.Size = UDim2.new(1, 0, 0.5, 0)
  21. textBox.Position = UDim2.new(0, 0, 0.5, 0)
  22. textBox.PlaceholderText = "Введите текст и нажмите Enter"
  23. textBox.Parent = frame
  24.  
  25. -- Функция для отправки запроса к API Brainshop
  26. local function getBotResponse(message)
  27.     local httpService = game:GetService("HttpService")
  28.     local url = "http://api.brainshop.ai/get?bid=183753&key=psLBmrVBOjdqlZkI&uid=0&msg="..httpService:UrlEncode(message)
  29.     local response = httpService:JSONDecode(game:HttpGetAsync(url)).cnt
  30.     return response
  31. end
  32.  
  33. -- Обработчик события FocusLost для TextBox
  34. textBox.FocusLost:Connect(function(enterPressed)
  35.     if enterPressed then
  36.         local botResponse = getBotResponse(textBox.Text)
  37.         textLabel.Text = botResponse
  38.     end
  39. end)
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement