-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
314 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
node_modules | ||
package-lock.json | ||
lib/modals/cam.mcscript | ||
# examples | ||
# Nodepad++ Highlighter.xml | ||
# _changelog.md | ||
# Core Modals.md | ||
# *.html | ||
# README-DE.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
var http = require('https'); | ||
var fs = require('fs'); | ||
|
||
exports.addPack = function(name){ | ||
let patt = new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/) | ||
if(patt.test(name)){ | ||
download(name, "external") | ||
} else http.get("https://download1350.mediafire.com/q7aa9e774jug/oyrbdi6fbpqo1bl/mcscri%27%2B%27pt+packages.json", (res) => { | ||
res.setEncoding('utf8'); | ||
res.on('data', function (chunk) { | ||
let packs = JSON.parse(chunk) | ||
let obj = packs.find(obj => obj.name === name.toLowerCase()) | ||
if(obj && obj.url){ | ||
console.log(obj.url.slice(0, 17)) | ||
if(obj.url.slice(0, 17) == "https://github.com" || obj.url.slice(0, 16) == "http://github.com") downloadFromRedirectLink(obj.url, obj.name) | ||
else download(obj.url, obj.name) | ||
} else { | ||
let packStr = "" | ||
packs.forEach((e, i) => { | ||
packStr += e.name | ||
if(i != packs.length - 1) packStr += ", " | ||
}) | ||
console.log("\x1b[31m","Your pack was not found! Please use one of these: ","\x1b[0m") | ||
console.log("\x1b[36m",packStr,"\x1b[0m") | ||
} | ||
}); | ||
|
||
}).on('error', function(e) { | ||
console.log("\x1b[31m","Got error: " + e.message,"\x1b[0m"); | ||
}); | ||
} | ||
var download = function (url, name){ | ||
console.log("\x1b[36m","Downloading "+name+".zip ...","\x1b[0m") | ||
let file = fs.createWriteStream(name + '.zip'); | ||
let request = http.get(url, function(response) { | ||
response.pipe(file) | ||
response.on('end', () => { | ||
console.log("\x1b[32m","Download of "+name+".zip finished!","\x1b[0m") | ||
}); | ||
}).on('error', function(e) { | ||
console.log("\x1b[31m","Got error: " + e.message,"\x1b[0m"); | ||
}); | ||
} | ||
function downloadFromRedirectLink(url, file) { | ||
http.get(url, function(res) { | ||
if(res.statusCode != 302){ | ||
console.log("error: no redirect found"); | ||
return; | ||
} | ||
download(res.headers.location,file); | ||
}).on('error', function(e) { | ||
console.log("\x1b[31m", "Got error: " + e.message,"\x1b[0m"); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.