Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Создаём ScreenGui
- local screenGui = Instance.new("ScreenGui")
- screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
- -- Создаём Frame
- local frame = Instance.new("Frame")
- frame.Size = UDim2.new(0, 300, 0, 200)
- frame.Position = UDim2.new(0.5, -150, 0.5, -100)
- frame.Parent = screenGui
- -- Создаём TextLabel
- local textLabel = Instance.new("TextLabel")
- textLabel.Size = UDim2.new(1, 0, 0.5, 0)
- textLabel.Position = UDim2.new(0, 0, 0, 0)
- textLabel.Text = "Ответ бота появится здесь"
- textLabel.Parent = frame
- -- Создаём TextBox
- local textBox = Instance.new("TextBox")
- textBox.Size = UDim2.new(1, 0, 0.5, 0)
- textBox.Position = UDim2.new(0, 0, 0.5, 0)
- textBox.PlaceholderText = "Введите текст и нажмите Enter"
- textBox.Parent = frame
- -- Функция для отправки запроса к API Brainshop
- local function getBotResponse(message)
- local httpService = game:GetService("HttpService")
- local url = "http://api.brainshop.ai/get?bid=183753&key=psLBmrVBOjdqlZkI&uid=0&msg="..httpService:UrlEncode(message)
- local response = httpService:JSONDecode(game:HttpGetAsync(url)).cnt
- return response
- end
- -- Обработчик события FocusLost для TextBox
- textBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- local botResponse = getBotResponse(textBox.Text)
- textLabel.Text = botResponse
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement