Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; /GetMcStatus - Messages active channel with the current statuses
- ;; $GetMcStatus - returns the current statuses
- ;; //echo -a $GetMcStatus - Echos the current statuses
- alias getMcStatus {
- var %status = $mcStatus
- var %state = $gettok(%status, 1, 32)
- var %val = $gettok(%status, 2-, 32)
- var %msg
- var %n = 1
- var %site
- if (%state != 1 || !%val) {
- return 04[MOJANG STATUS] An error occured while checking mojang server statuses $+ $iif(%val,: %val)
- }
- else {
- %msg = 03[MOJANG STATUS]
- tokenize 124 %val
- while (%n <= $0) {
- %site = $gettok($(,$ $+ %n), 1, 58)
- %status = $gettok($(,$ $+ %n), 2, 58)
- if (%status == 0) {
- %status = 04Down
- }
- elseif (%status == 1) {
- %status = 07Intermitten
- }
- elseif (%status == 2) {
- %status = 03Up
- }
- else {
- %status = %status
- }
- %msg = %msg %site $+ : %status
- if (%n < $0) {
- %msg = %msg -
- }
- inc %n
- }
- $iif($isid, return, msg $active) %msg
- }
- }
- alias -l mcstatus {
- ; basic variables
- var %error, %status, %resp, %statVar = status={status:0,error:"Services not polled"}, %regex, %n = 1
- ; js to add to scripting shell
- var %getStatus = function getStatus(){for(var a=['MSXML2.SERVERXMLHTTP.6.0','MSXML2.SERVERXMLHTTP.3.0','MSXML2.SERVERXMLHTTP','MSXML2.XMLHTTP.6.0','MSXML2.XMLHTTP.3.0','Microsoft.XMLHTTP'],b,c=0;c<a.length;c+=1){try{b=new ActiveXObject(a[c])}catch(e){}}if(b!==undefined){b.open("GET","http://status.mojang.com/check",false);b.setRequestHeader("Cache-Control","no-cache");b.send();status={status:b.status,error:null,resp:b.responseText}}else{status={status:0,error:"XMLHTTPRequest object not found"}}}
- ; initialize COM object
- if (!$com(mcStatus)) {
- ; Create instance of MSScriptControl.ScriptControl
- .comopen mcStatus MSScriptControl.ScriptControl
- if (!$com(mcStatus) || $comerr) {
- %error = Unable to locate MSScriptControl.ScriptControl
- }
- ; Set script language to JScript
- elseif (!$com(mcStatus, language, 4, bstr, jscript) || $comerr) {
- %error = Unable to set script language to JScript for MSScriptControl.ScriptControl
- }
- ; Add getStatus() function to the ScriptControl
- elseif (!$com(mcStatus, addcode, 1, bstr, %getStatus) || $comerr) {
- %error = Unable to add getStatus() function to the ScriptControl
- }
- ; Create status variable within the ScriptControl instance
- elseif (!$com(mcStatus, ExecuteStatement, 1, bstr, %statVar) || $comerr) {
- %error = Unable to initalize status variable
- }
- ; Goto error if one was encountered
- if (%error) {
- goto error
- }
- }
- ; Call getStatus()
- if (!$com(mcStatus, ExecuteStatement, 1, bstr, getStatus $+ $chr(40) $+ $chr(41)) || $comerr) {
- %error = Unable to execute getStatus()
- }
- else {
- if (!$com(mcStatus, eval, 1, bstr, status.status) || $comerr) {
- %error = Unable to retrieve status from getStatus()
- goto error
- }
- var %status = $com(mcStatus).result
- if (%status == 0) {
- return 0 XMLHTTPRequest object not found
- }
- elseif (%status !== 200) {
- return 0 Server Error %status
- }
- elseif (!$com(mcStatus, eval, 1, bstr, status.resp) || $comerr) {
- %error = Unable to retrieve response from getStatus()
- goto error
- }
- noop $regex(mcStatus, $com(mcStatus).result, /"([^"]+)":"([^"]+)"/g)
- while (%n <= $regml(mcStatus, 0)) {
- var %site = $regml(mcStatus, %n)
- if (%site == minecraft.net) {
- %site = Minecraft.net
- }
- elseif (%site == session.minecraft.net) {
- %site = Session Tracker
- }
- elseif (%site == account.mojang.com) {
- %site = Account Tracker
- }
- elseif (%site == auth.mojang.com) {
- %site = Auth Tracker
- }
- elseif (%site == skins.minecraft.net) {
- %site = Skin Server
- }
- elseif (%site == authserver.mojang.com) {
- %site = Auth Server
- }
- elseif (%site == sessionserver.mojang.com) {
- %site = Session Server
- }
- elseif (%site == api.mojang.com) {
- %site = API Server
- }
- elseif (%site == textures.minecraft.net) {
- %site = Texture Server
- }
- inc %n
- var %value = $regml(mcStatus, %n)
- if (%value == red) {
- %value = 0
- }
- elseif (%value == yellow) {
- %value = 1
- }
- elseif (%value == green) {
- %value = 2
- }
- inc %n
- %resp = $addtok(%resp, %site $+ : $+ %value, 124)
- }
- return 1 %resp
- }
- :error
- %error = $iif($error, $error, %error)
- if (%error) {
- reseterror
- if ($com(mcstatus)) { .comclose mcstatus }
- if ($isid) return 0 %error
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement