; First type /getJFM to load SReject's JSON-4-mIRC
; Afterwards you can type /getInfo as many times as you like
alias getInfo {
var %url = https://api.github.com/repos/svdermant/MinecraftBot/commits/master
var %jsonname = lcommit
JSONOPEN -u %jsonname %url
if ($json(%jsonname).httpStatus == 200) {
echo -ag Latest commit information:
echo -ag Author: $json(%jsonname,commit,author,name).value - Date: $json(%jsonname,commit,author,date).value
echo -ag Additions: $json(%jsonname,stats,additions).value - Deletions: $json(%jsonname,stats,deletions).value
echo -ag Commit message: $json(%jsonname,commit,message).value
}
}
alias getJFM {
; sha-512 of JSON For mIRC.mrc v1.0.4000
var %sha512-1 b29de8c964b002d089fa030a9a5357e3c737f17cd16309c0fa82142120a590db2223d4703cafe97f37b65de170bb4d9dbf7bb508f4052a47a2127fc74c10a6d6
; group enabled hash
var %sha512-2 183153806705c99fce8fb3003ea7e5522e9f67c40b3e064280ad83111e3d8f92b4cfae106b8827a9d99c2377c32d6d6892fe878a027bcaea24a466450cfeead8
; check if JSON For mIRC is loaded
if ($isalias(JSONVersion)) {
; script is loaded, but what version?
var %file $isalias(JSONVersion).fname
if (!$istok(%sha512-1 %sha512-2,$sha512(%file,2),32)) {
echo -ag Unloading $JSONVersion ...
.unload -rs $qt(%file) | .timer -mio 1 0 getJFM
}
else echo -ag JFM already loaded!
}
elseif ($1 isnum) {
if ($urlget($1).state == fail) { echo 4 -ag Downloading JSON For mIRC failed. Are you connected to the internet? | halt }
elseif ($zip($urlget($1).target,eo,scripts)) {
var %file $qt($findfile(scripts\JSON-For-Mirc-1.0.4000,JSON For mIRC.mrc,1))
if ($sha512(%file,2) == %sha512-1) echo -ag Loading JSON For mIRC ver1.0.4000 | .load -rs %file
else echo 4 -ag Wrong sha512 hash for %file $+ !
.remove $urlget($1).target
}
else { echo 4 -ag Something went wrong unzipping $:t($urlget($1).target) }
}
else {
var %url https://github.com/SReject/JSON-For-Mirc/archive/v1.0.4000.zip
var %target JFM.zip
echo -ag Obtaining JSON For mIRC...
return $urlget(%url,gf,%target,getJFM)
}
}