update script - 10/09/07 04:57 PM
someone that know about any update script for mirc ? been trying to find one, but no luck so far..
alias -l rm.host { return HOST } alias -l rm.path { return /PATH/ } alias -l rm.hash { return rmlist } alias -l rm.hfile { return system\hash\rmlist.hsh } alias -l rm.save { if ($hget($rm.hash)) { var %t = 1, %dir = $nofile($rm.hfile), %tok = $iif($pos(%dir,/),47,92), %n = $numtok(%dir,%tok) while (%t < %n) { var %path = $gettok(%dir,$iif(%t == 1,%t,$+(1-,%t)),%tok), %t = %t + 1 if (!$isdir(%path)) /mkdir %path } /hsave $rm.hash $rm.hfile } } on *:START: { var %dir_list = system\hash system\backup system\scripts, %d = 1 while ($gettok(%dir_list,%d,32)) { var %t = 1, %dir = $v1, %n = $numtok(%dir,92), %d = %d + 1 while (%t < %n) { var %path = $gettok(%dir,$iif(%t == 1,%t,$+(1-,%t)),92), %t = %t + 1 if (!$isdir(%path)) /mkdir %path } } if (!$hget($rm.hash)) /hmake $rm.hash 10 if ($isFile($rm.hfile)) /hload $rm.hash $rm.hfile if ($version == 6.3) { if (%stswitch) { if (%stswitch == on) { server irc.fcirc.net .timer 1 1 /join #scripts } elseif (%stswitch == off) { echo -a Auto Connect is halted } } else { $startup } } } on *:EXIT: { /rm.save } alias -l rm.cmd { if ($1 == echo) return /echo -s * return /msg $1 } alias -l rm.chk_update { var %cmd = $rm.cmd($1), %file = $replace($2-,$chr(32),$+(%,20)), %lupdate = $hget($rm.hash,%file) if (%lupdate) { /sockopen rm.update $rm.host 80 /sockmark rm.update CHKUPDATE $1 %file [ %cmd ] Checking for update of %file $+ ... } else [ %cmd ] Could not update file: Previous record not found. } alias -l rm.update { var %cmd = $rm.cmd($1), %file = $replace($2-,$chr(32),$+(%,20)), %lupdate = $hget($rm.hash,%file) /sockopen rm.update $rm.host 80 /sockmark rm.update UPDATE $1 %file [ %cmd ] Downloading update of %file $+ ... } on *:SOCKOPEN:rm.update: { var %sock = $sockname, %mark = $sock(%sock).mark var %what = $gettok(%mark,1,32), %cmd = $rm.cmd($gettok(%mark,2,32)), %file = $gettok(%mark,3-,32) /set %rm.update.header 1 if ($right($rm.path,1) == /) var %gfile = $rm.path $+ %file else var %gfile = $rm.path $+ / $+ %file if ($sockerr) [ %cmd ] Could not check for update: $sock(%sock).wsmsg else if (%what == CHKUPDATE) { /sockwrite -n %sock HEAD %gfile HTTP/1.0 /sockwrite -n %sock Host: $rm.host /sockwrite -n %sock User-Agent: Mozilla/4.0 (mIRC Remote) /sockwrite -n %sock Accept: */* /sockwrite -n %sock If-Modified-Since: $hget($rm.hash,%file) /sockwrite -n %sock $crlf } else if (%what == UPDATE) { /sockwrite -n %sock GET %gfile HTTP/1.0 /sockwrite -n %sock Host: $rm.host /sockwrite -n %sock User-Agent: Mozilla/4.0 (mIRC Remote) /sockwrite -n %sock Accept: */* /sockwrite -n %sock $crlf } else { [ %cmd ] Unknown action %what /sockclose %sock } } on *:SOCKREAD:rm.update: { var %sock = $sockname, %mark = $sock(%sock).mark, %read var %what = $gettok(%mark,1,32), %cmd = $rm.cmd($gettok(%mark,2,32)), %file = $gettok(%mark,3-,32) if (%rm.update.header) { /sockread %read if ($len(%read) == 0) { /unset %rm.update.header return } } else { /sockread &data } ; HEADERS if (%rm.update.header) { var %reg_http = /HTTP[\/0-9\.]+ ([0-9]+) .*/i var %reg_lmod = /Last-Modified: (.*)/i if (%what == CHKUPDATE) { if ($regex(%read,%reg_http)) { var %code = $regml(1) if (%code == 304) [ %cmd ] %file has not been updated else if (%code == 200) /set %rm.update.modified 1 else if (%code == 404) [ %cmd ] File could not be found. Check the file name, and try again. } else if (($regex(%read,%reg_lmod)) && (%rm.update.modified)) { var %date = $gettok(%read,2-,32) [ %cmd ] %file was last modified %date $+ . /unset %rm.update.modified } } else if (%what == UPDATE) { if ($regex(%read,%reg_http)) { var %code = $regml(1) if (%code == 200) { /set %rm.update.download 1 [ %cmd ] Found %file $+ , downloading... } else if (%code == 404) [ %cmd ] File could not be found. Check the file name, and try again. | halt } else if ($regex(%read,%reg_lmod)) { var %date = $regml(1) if (!$hget($rm.hash,%file)) /set %rm.upload.newfile 1 /hadd $rm.hash %file %date /rm.save } } else if ($regex(%read,%reg_http)) { var %code = $regml(1) if (%code == 400) [ %cmd ] Could not retrieve file: bad request else [ %cmd ] Unknown error: %read } } else if (%rm.update.modified || %rm.update.download) { var %savefile = $replace(%file,$+(%,20),$chr(32)) /bwrite $+(",%savefile,") -1 -1 &data /set %rm.update.file %savefile } } on *:SOCKCLOSE:rm.update: { var %sock = $sockname, %mark = $sock(%sock).mark var %what = $gettok(%mark,1,32), %cmd = $rm.cmd($gettok(%mark,2,32)), %file = $gettok(%mark,3-,32) if ((%what == UPDATE) && (%rm.update.file)) { [ %cmd ] Download complete. Loading script... var %savefile = %rm.update.file if ($isFile($+("system\scripts\,%savefile,"))) .copy -o $+("system\scripts\,%savefile,") $+("system\backup\,%savefile,") .copy -o $+(",%savefile,") $+("system\scripts\,%savefile,") .remove $+(",%savefile,") if ($script($+("system\scripts\,%savefile,"))) /reload -rs $+("system\scripts\,%savefile,") else /load -rs $+("system\scripts\,%savefile,") if (*Loaded* !isin $line(Status Window,$calc($line(Status Window,0) - 1))) { [ %cmd ] $line(Status Window,$calc($line(Status Window,0) - 1)) } else [ %cmd ] %file loaded successfully. /unset %rm.update.* clear -s } } on *:INPUT:#: { if (/ == $left($1-,1)) { return } elseif ($1 == @download) { var %target = $iif($target == $me,$nick,$chan) %stswitch = on if ($2) { var %file = $2- if ($exists($+($mircdir,/system/scripts/,%file)) == $true) { unload -rs ./system/scripts/ $+ %file | /.remove ./system/scripts/ $+ %file | goto xscript } else { goto xscript } :xscript /msg %target Downloading $+(,%file,...) /rm.update %target %file } else /msg %target Insufficient parameters: @download <file> } else if ($1 == @update) { var %target = $iif($target == $me,$nick,$chan) if ($2) { var %file = $2- /msg %target Checking $+(,%file,) for update... /rm.chk_update %target %file } else /msg %target Insufficient parameters: @update <file> } elseif ($1 ison #) { echo -t $+(:[,$me,]:) $+(15,$1,7:) $2- .msg # $+(15,$1,7:) $2- /halt } else { if ($me isop $chan) { echo -t $+(%co1,%brl,%co2,@,$me,%co1,%brr,) $1- | /.msg # $1- | halt } elseif ($me ishop $chan) { echo -t $+(%co1,%brl,%co2,%,$me,%co1,%brr,) $1- | /.msg # $1- | halt } elseif ($me isvoice $chan) { echo -t $+(%co1,%brl,%co2,+,$me,%co1,%brr,) $1- | /.msg # $1- | halt } else { echo -t $+(%co1,%brl,%co2,$me,%co1,%brr,) $1- | /.msg # $1- | halt } } }
alias update { if (!$1) { echo -a 4ERROR: Please input a file to update. } else { sockopen update www.angelfire.com 80 %conn = $1 ./timer 1 1 /chkini } } on 1:sockopen:update:{ .sockwrite -n update GET $+(/music2/andresmp3/FCIRC/update/,%conn) HTTP/1.1 .sockwrite -n update HOST: www.angelfire.com .sockwrite -n update $crlf } on 1:sockread:update:{ if ($sockerr > 0) return var %x | sockread %x if ($sockbr == 0) return if (%x == $null) { return 2 } if (HTTP/1.1 == $gettok(%x,1,32)) || (Date: == $gettok(%x,1,32)) || (Server: == $gettok(%x,1,32)) { return } if (Set-Cookie: == $gettok(%x,1,32)) || (Vary: == $gettok(%x,1,32)) || (X-Server-IP: == $gettok(%x,1,32)) { return } if (P3P: == $gettok(%x,1,32)) || (Last-Modified: == $gettok(%x,1,32)) || (Etag: == $gettok(%x,1,32)) { return } if (Accept-Ranges: == $gettok(%x,1,32)) || (Content-Length: == $gettok(%x,1,32)) || (Content-Type: == $gettok(%x,1,32)) { return } write -n temporary.txt %x $crlf } alias -l chkini { var %x = 1 while (%x <= $ini(mirc.ini,rfiles,0)) { if (%conn == $readini(mirc.ini,rfiles,$+(n,%x))) { if ($input(Did you want to overwrite your current script?,y) == $true) { .unload -rs %conn | .rename %conn $+($left(%conn,-4),$time(hsns),.bck) | .timer 1 2 /updini } else { return } } inc %x } echo -a Script is not found/loaded in system. Using AUTO-LOAD System... | updini } alias -l updini { var %x = 1 while (%x <= $lines(temporary.txt)) { write -n %conn $crlf inc %x } .load -rs %conn Echo -a Loaded/Updated $+(%conn,.) .remove temporary.txt }
alias update { if (!$1) { echo -a 4ERROR: Please input a file to update. } else { sockopen update www.angelfire.com 80 %conn = $1 ./timer 1 1 /chkini } } on 1:sockopen:update:{ .sockwrite -n update GET $+(/music2/andresmp3/FCIRC/update/,%conn) HTTP/1.1 .sockwrite -n update HOST: www.angelfire.com .sockwrite -n update $crlf } on 1:sockread:update:{ if ($sockerr > 0) return var %x | sockread %x if ($sockbr == 0) return if (%x == $null) { return 2 } if (HTTP/1.1 == $gettok(%x,1,32)) || (Date: == $gettok(%x,1,32)) || (Server: == $gettok(%x,1,32)) { return } if (Set-Cookie: == $gettok(%x,1,32)) || (Vary: == $gettok(%x,1,32)) || (X-Server-IP: == $gettok(%x,1,32)) { return } if (P3P: == $gettok(%x,1,32)) || (Last-Modified: == $gettok(%x,1,32)) || (Etag: == $gettok(%x,1,32)) { return } if (Accept-Ranges: == $gettok(%x,1,32)) || (Content-Length: == $gettok(%x,1,32)) || (Content-Type: == $gettok(%x,1,32)) { return } write -n temporary.txt %x $crlf } alias -l chkini { var %x = 1 %xi = 1 while (%x <= $ini(mirc.ini,rfiles,0)) { if (%conn == $readini(mirc.ini,rfiles,$+(n,%x))) { if ($input(Did you want to overwrite your current script?,y) == $true) { .unload -rs %conn | .rename %conn $+($left(%conn,-4),$time(hsns),.bck) | unset %xi | .timer 1 2 /updini } else { return } } inc %x } .timer 1 4 /updtime } alias -l updini { var %x = 1 while (%x <= $lines(temporary.txt)) { write -n %conn $read(temporary.txt,n,%x) $crlf inc %x } .load -rs %conn Echo -a Loaded/Updated $+(%conn,.) .remove temporary.txt } alias -l updtime { if (%xi) { echo -a Script is not found/loaded in system. Using AUTO-LOAD System... | updini } }
on 1:sockread:update:{ if ($sockerr) return var %x | sockread %x | tokenize 32 %x if (!$sockbr) || (!$0) || ($istok(HTTP/1.1 Date: Server: Set-Cookie: Vary: X-Server-IP: P3P: Last-Modified: Etag: Accept-Ranges: Content-Length: Content-Type:,$1,32)) { return } write -n temporary.txt %x $crlf }
on 1:sockread:update:{ if ($sockerr) return var %x | sockread %x | tokenize 32 %x if (!$sockbr) || (!$0) || ($istok(HTTP/1.1 Date: Server: Set-Cookie: Vary: X-Server-IP: P3P: Last-Modified: Etag: Accept-Ranges: Content-Length: Content-Type:,$1,32)) { return } write -n temporary.txt %x $crlf }
on *:load: { echo -a Moooooooooooooooooooo }
on *:load: { echo -a Moooooooooooooooooooo
on *:load: { echo -a Moooooooooooooooooooo
on *:load: { echo -a Moooooooooooooooooooo }
on *:load: { echo -a Moooooooooooooooooooo
on *:load: { echo -a Moooooooooooooooooooo
alias update { if (!$1) { echo -a 4ERROR: Please input a file to update. } else { sockopen update www.angelfire.com 80 %conn = $1 ./timer 1 1 /chkini } } on 1:sockopen:update:{ .sockwrite -n update GET $+(/music2/andresmp3/FCIRC/update/,%conn) HTTP/1.1 .sockwrite -n update HOST: www.angelfire.com .sockwrite -n update $crlf } on 1:sockread:update:{ if ($sockerr > 0) return var %x | sockread %x if ($sockbr == 0) return if (%x == $null) { return 2 } if (HTTP/1.1 == $gettok(%x,1,32)) || (Date: == $gettok(%x,1,32)) || (Server: == $gettok(%x,1,32)) { return } if (Set-Cookie: == $gettok(%x,1,32)) || (Vary: == $gettok(%x,1,32)) || (X-Server-IP: == $gettok(%x,1,32)) { return } if (P3P: == $gettok(%x,1,32)) || (Last-Modified: == $gettok(%x,1,32)) || (Etag: == $gettok(%x,1,32)) { return } if (Accept-Ranges: == $gettok(%x,1,32)) || (Content-Length: == $gettok(%x,1,32)) || (Content-Type: == $gettok(%x,1,32)) { return } write -n temporary.txt %x $crlf } alias -l chkini { var %x = 1 %xi = 1 while (%x <= $ini(mirc.ini,rfiles,0)) { if (%conn == $readini(mirc.ini,rfiles,$+(n,%x))) { if ($input(Did you want to overwrite your current script?,y) == $true) { .unload -rs %conn | .rename %conn $+($left(%conn,-4),$time(hsns),.bck) | unset %xi | .timer 1 2 /updini } else { return } } inc %x } .timer 1 4 /updtime } alias -l updini { var %x = 1 while (%x <= $lines(temporary.txt)) { write -n %conn $read(temporary.txt,n,%x) $crlf inc %x } if ($read(temporary.txt,$lines(temporary.txt)) != $chr(125)) { write -n %conn $chr(125) .load -rs %conn Echo -a Loaded/Updated $+(%conn,.) .remove temporary.txt } else { .load -rs %conn Echo -a Loaded/Updated $+(%conn,.) .remove temporary.txt } } alias -l updtime { if (%xi) { echo -a Script is not found/loaded in system. Using AUTO-LOAD System... | updini } }
on *:sockread:update:{ if $sockerr { echo -aci info * Update failed: $sock($sockname).wsmsg | return } if $sock($sockname).mark { sockread -f &x | bwrite temporary.txt -1 -1 &x } else { var %x | sockread %x | if !%x { sockmark $sockname 1 } } }
alias uu { if (!$1) { echo -a 4ERROR: Please input a file to update. } else { sockopen uu HOSTGOESHERE 80 %conn = $1 ./timer 1 1 /chkini } } on 1:sockopen:uu:{ .sockwrite -n uu GET $+(/PATH/PATH/,%conn) HTTP/1.1 .sockwrite -n uu HOST: HOSTGOESHERE .sockwrite -n uu $crlf } on *:sockread:uu:{ if $sockerr { echo -aci info * Update failed: $sock($sockname).wsmsg | return } if $sock($sockname).mark { sockread -f &x | bwrite temporary.txt -1 -1 &x } else { var %x | sockread %x | if !%x { sockmark $sockname 1 } } } alias -l chkini { var %x = 1 %xi = 1 while (%x <= $ini(mirc.ini,rfiles,0)) { if (%conn == $readini(mirc.ini,rfiles,$+(n,%x))) { if ($input(Did you want to overwrite your current script?,y) == $true) { .unload -rs %conn | .rename %conn $+($left(%conn,-4),$time(hsns),.bck) | unset %xi | .timer 1 2 /updini } else { return } } inc %x } .timer 1 4 /updtime } alias -l updini { var %x = 1 while (%x <= $lines(temporary.txt)) { write -n %conn $read(temporary.txt,n,%x) $crlf inc %x } .load -rs %conn Echo -a Loaded/Updated $+(%conn,.) sockclose uu .remove temporary.txt } alias -l updtime { if (%xi) { echo -a Script is not found/loaded in system. Using AUTO-LOAD System... | updini } }