local chat = peripheral.find("chatBox") local socket = http.websocket(settings.get("bridge_url"), { ["X-Token"] = settings.get("bridge_token") }) while true do local eventData = os.pullEvent() local event = eventData[1] if event == "websocket_message" then local data = textutils.unserializeJSON(eventData[3]) chat.sendMessage(data.message, data.user) elseif event == "chat" then if not eventData[5] then local username = eventData[2] local message = eventData[3] local uuid = eventData[4] local serialized = textutils.serialiseJSON({ user = username, message = message, user_id = string.gsub(uuid, "-", "") }) socket.send(serialized) end end end