Script updater
Posted by Rustynails
Tuesday, May 02, 2006
Description: Updates your script off the internet
Usage: Add this snippet to your script at the TOP! Whenever you make updates, upload to your website the new script with a different version. Upon signaling the script it compares the versions, checks if it's a new release then overwrites the current one in your .mrc
Type the following to signal the script: /signal MyScript.Update <Website URL (No http://)> <Port> <File Name>
It should update if there's a new version available.
PS Make the version one word!
Usage: Add this snippet to your script at the TOP! Whenever you make updates, upload to your website the new script with a different version. Upon signaling the script it compares the versions, checks if it's a new release then overwrites the current one in your .mrc
Type the following to signal the script: /signal MyScript.Update <Website URL (No http://)> <Port> <File Name>
It should update if there's a new version available.
PS Make the version one word!
alias -l MyScript.Version return 0.1
on *:signal:MyScript.Update:{
sockopen MyScript.Update $1 $2
sockmark MyScript.Update $1 $3-
}
on *:sockopen:MyScript.Update:{
sockwrite -n $sockname GET $+(/,$gettok($sock($sockname).mark,2-,32)) HTTP/1.0
sockwrite -n $sockname Host: $gettok($sock($sockname).mark,1,32)
sockwrite -n $sockname Connection: Close
sockwrite -n $sockname $crlf
sockmark $sockname 0 0
}
on *:sockread:MyScript.Update:{
var %MyScript.Read | sockread %MyScript.Read | tokenize 32 %MyScript.Read
if ($sock($sockname).mark == 0 0) && (!$1) { sockmark $sockname 1 0 }
if ($sock($sockname).mark == 1 0) && (alias -l MyScript.Version return isin $1-) && ($gettok($1-,$gettok($1-,0,32),32) != $MyScript.Version) { .write -c $+(",$script,") | sockmark $sockname 1 1 }
if ($sock($sockname).mark == 1 0) && (alias -l MyScript.Version return isin $1-) && ($gettok($1-,$gettok($1-,0,32),32) == $MyScript.Version) { sockclose $sockname }
if ($sock($sockname).mark == 1 1) { .write $+(",$script,") $1- }
}
on *:sockclose:MyScript.Update:{
.load -rs $+(",$script,")
}