mSLDev (mIRC scripting language IDE) latest dev build downloader

By Yawhatnever on Mar 29, 2013

I wrote this simple download script because the development build of the mSL IDE I use is updated frequently enough that manually going to the site and getting the latest dev build got annoying.

"mSLDev is a free, state-of-the-art, integrated development environment for mSL specifically designed for mSL scripters." - Quoted from www.msldev.com for anyone who has no idea what I'm downloading.
Note: This downloads the development build! Bugs are a lot more common than in the stable release of the program.

About the script:
/msldev will check and download a newer version if available
/cancel will close the socket early

The default save directory can be edited in alias _devDir. It's saved to $mircdirmSLDev\ by default.

alias msldev {
  if (!$sock(msldev.latestbuild)) sockopen msldev.latestbuild www.msldev.com 80
}
alias cancel {
  sockclose msldev.latestbuild
}
alias -l _devDir {
  if (!$isdir($qt($mircdirmSLDev\))) mkdir $qt($mircdirmSLDev\)
  return $qt($mircdirmSLDev\ $+ $noqt($1-))
}
on *:start:{
  if (!$hget(msldev)) {
    hmake msldev
   if ($isfile($_devDir(downloader.hsh))) hload msldev $_devDir(downloader.hsh)
  }
}
on *:sockopen:msldev.latestbuild:{
  sockwrite -nt $sockname GET /download/win/latest_build.zip HTTP/1.1
  sockwrite -nt $sockname Host: www.msldev.com
  sockwrite -nt $sockname $crlf
  if ($isfile($_devDir(latest_build.zip.tmp))) remove -b $_devDir(latest_build.zip.tmp)
}
on *:sockread:msldev.latestbuild:{
  if (!$sock($sockname).mark) {
    ;header
    var %r
    sockread %r
    if (Last-Modified: * iswm %r) {
      if (%r == $hget(msldev,lastmod)) && ($isfile($_devDir(latest_build.zip))) {
        echo -sg mSLDev latest_build.zip not modified.
        sockclose $sockname
      }
      else hadd -m msldev lastmod %r
    }
    elseif (%r == $null) sockmark $sockname 1
    elseif ($regex(%r,Content-Length: (\d+))) {
      hadd msldev filesize $regml(1)
      hadd msldev downloaded 0
    }
  }
  else {
    ;content body
    sockread &latest
    hinc msldev downloaded $bvar(&latest,0)
    bwrite $_devDir(latest_build.zip.tmp) -1 -1 &latest
    if (!$r(0,400)) echo -sg Downloading latest_build.zip $round($calc($hget(msldev,downloaded) / $hget(msldev,filesize) * 100),0) $+ % complete.
    if ($hget(msldev,filesize) == $hget(msldev,downloaded)) {
      ;download complete
      echo -sg Download complete.
      if ($isfile($_devDir(latest_build.zip))) remove -b $_devDir(latest_build.zip)
      .rename $_devDir(latest_build.zip.tmp) $_devDir(latest_build.zip)
      hsave msldev $_devDir(downloader.hsh)
      run $_devDir
    }
  }
}

Comments

Sign in to comment.
alabama   -  Apr 21, 2013

this looks like some advertisement propaganda

Yawhatnever  -  Apr 22, 2013

I suppose it does look like that. I could change the wording a bit, but I included the description (and the quote) for the sake of anyone who has no idea what it's downloading. I wrote the script for myself after manually downloading one too many dev builds, but I cleaned it up and posted it for anyone else who might be too lazy to write their own (I can just share the link and make edits if I need to). It's also a nice clean example of a simple download script.

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.