mIRC Servers List Update - 1.0

By ^WeSt on Oct 23, 2011

This add-on can update your mIRC Servers List using an command (/update_serverlist) or from the status or menubar menus with an right click, it is simple just load it into your scripts!

example:
/update_serverlist
[WARNING]: The mIRC Servers List is checking now for new version of "servers.ini" file into the mIRC website, Please wait...
[WARNING]: The mIRC Servers List has been updated! - YOUR VERSION WAS: 13/10/2010 - WEBSITE NEW VERSION: 13/10/2011 - TOOK: 1.576 second(s) - SUCCESSFULLY

  • Thanks!
alias update_serverlist {
  if ($hget(MSL_UPDATE,TIME)) { echo -a [4Error]: Cannot proceed, The mIRC Servers List is already in use, Please wait.. - STARTED ON: 9 $+ $asctime($hget(MSL_UPDATE,TIME),dddd ddoo mmmm yyyy HH:nn:ss) $+  - 4FAILED | halt }
  hadd -m MSL_UPDATE TICKS $ticks
  hadd -m MSL_UPDATE TIME $ctime
  if (!$isfile(servers.ini)) { hadd -m MSL_UPDATE MYVERSION 0 }
  elseif ($isfile(servers.ini)) { hadd -m MSL_UPDATE MYVERSION $iif($readini(servers.ini,timestamp,date),$v1,0) }
  .timer[MSL_UPDATE_ERROR] -o 1 30 update_serverlist_error
  echo -a [WARNING]: The mIRC Servers List is checking now for new version of "servers.ini" file into the mIRC website, Please wait...
  sockclose MSL_SERVERLIST
  sockopen MSL_SERVERLIST www.mirc.com 80
}

ON *:SOCKOPEN:MSL_SERVERLIST: {
  if ($hget(MSL_UPDATE,UNLOAD)) { sockclose $sockname | return }
  if ($sockerr > 0) { echo -a [4Error]: Cannot connect, The mIRC Servers List has an connection problem check your internet connection and try again! - TOOK: 10 $+ $calc(($ticks - $hget(MSL_UPDATE,TICKS)) / 1000) $+  second(s) - 4FAILED | update_serverlist_error -m | return }
  sockwrite -n $sockname GET /servers.ini HTTP/1.0
  sockwrite -n $sockname Host: www.mirc.com
  sockwrite -n $sockname User-Agent: */* 
  sockwrite -n $sockname $crlf
}

ON *:SOCKREAD:MSL_SERVERLIST: {
  if ($hget(MSL_UPDATE,UNLOAD)) { sockclose $sockname | return }
  if ($sockerr > 0) { echo -a [4Error]: Cannot connect & read, The mIRC Servers List has an connection reading problem check your internet connection and try again! - TOOK: 10 $+ $calc(($ticks - $hget(MSL_UPDATE,TICKS)) / 1000) $+  second(s) - 4FAILED | update_serverlist_error -m | return }
  var %v
  sockread %v
  if ([timestamp] == %v) { .timer[MSL_UPDATE_*] off | $iif($isfile(MSL_TEMP.log),.remove $qt(MSL_TEMP.log)) | hadd -m MSL_UPDATE WRITE 1 }
  if ($hget(MSL_UPDATE,WRITE)) { write MSL_TEMP.log $iif(!%v,$chr(160),%v) }
  if (*date=* iswm %v) { hadd -m MSL_UPDATE ONVERSION $remove(%v,date=) }
}

ON *:SOCKCLOSE:MSL_SERVERLIST: {
  if ($hget(MSL_UPDATE,UNLOAD)) { goto end }
  if ($hget(MSL_UPDATE,MYVERSION) == $hget(MSL_UPDATE,ONVERSION)) { echo -a [WARNING]: The mIRC Servers List has detect that you have already the latest version of the "servers.ini" file! - YOUR VERSION: 2 $+ $iif($hget(MSL_UPDATE,MYVERSION),$v1,N/A) $+  - WEBSITE VERSION: 12 $+ $iif($hget(MSL_UPDATE,ONVERSION),$v1,N/A) $+  - TOOK: 10 $+ $calc(($ticks - $hget(MSL_UPDATE,TICKS)) / 1000) $+  second(s) - 3SUCCESSFULLY }
  elseif ($hget(MSL_UPDATE,MYVERSION) !== $hget(MSL_UPDATE,ONVERSION)) {
    if ($isfile(servers.ini)) { .remove $qt(servers.ini) }
    if ($isfile(MSL_TEMP.log)) { .rename $qt(MSL_TEMP.log) servers.ini | echo -a [WARNING]: The mIRC Servers List has been updated! - YOUR VERSION WAS: 2 $+ $iif($hget(MSL_UPDATE,MYVERSION),$v1,N/A) $+  - WEBSITE NEW VERSION: 12 $+ $iif($hget(MSL_UPDATE,ONVERSION),$v1,N/A) $+  - TOOK: 10 $+ $calc(($ticks - $hget(MSL_UPDATE,TICKS)) / 1000) $+  second(s) - 3SUCCESSFULLY }
    elseif (!$isfile(MSL_TEMP.log)) { echo -a [4Error]: The mIRC Server List has NOT been updated, try again! - TOOK: 10 $+ $calc(($ticks - $hget(MSL_UPDATE,TICKS)) / 1000) $+  second(s) - 4FAILED }
  }
  :end
  if ($hget(MSL_UPDATE)) { hfree MSL_UPDATE }
  if ($isfile(MSL_TEMP.log)) { .remove $qt(MSL_TEMP.log) }
}

alias update_serverlist_error {
  ; [-m] - switch to not echo the error message just unset and close the items

  if ($1 !== -m) { echo -a [4Error]: Cannot connect, The mIRC Servers List had an internet connection problem, check your internet connection and try again later! - TOOK: 10 $+ $calc(($ticks - $hget(MSL_UPDATE,TICKS)) / 1000) $+  second(s) - 4FAILED }
  .timer[MSL_UPDATE_*] off
  if ($hget(MSL_UPDATE)) { hfree MSL_UPDATE }
  if ($isfile(MSL_TEMP.log)) { .remove $qt(MSL_TEMP.log) }
  sockclose MSL_SERVERLIST
}

alias msl_ver return 1.0
alias msl_crdate return 23/10/2011

menu status,menubar {
  « $+ $chr(7) $+ » mIRC Server List v $+ $msl_ver $+($chr(98),$chr(121)) $+($chr(94),$chr(87),$chr(101),$chr(83),$chr(116)) « $+ $chr(7) $+ »
  .$iif($hget(MSL_UPDATE),$style(2) Updating..,Update now):update_serverlist
  .My servers.ini last update:echo -a [WARNING]: Your "servers.ini" last update was on: 2 $+ $iif($readini(servers.ini,timestamp,date),$v1,NOT FOUNDED) $+ 
  .Unload this add-on:unload -rs $qt($script)
  .About:echo -a [WARNING]: You are using the mIRC Servers List v $+ $msl_ver created on  $+ $msl_crdate $+  $+($chr(98),$chr(121)) $+($chr(94),$chr(87),$chr(101),$chr(83),$chr(116))
}

ON *:UNLOAD: {
  if ($sock(MSL_UPDATE)) { .timer[MSL_UPDATE_*] off | hadd -m MSL_UPDATE UNLOAD 1 | sockclose MSL_SERVERLIST }
  if ($hget(MSL_UPDATE)) { hfree MSL_UPDATE }
  if ($isfile(MSL_TEMP.log)) { .remove $qt(MSL_TEMP.log) }
  echo -a [WARNING]: The mIRC Servers List v $+ $msl_ver created on  $+ $msl_crdate $+  has been uninstalled! - 3SUCCESSFULLY
}

ON *:LOAD: {
  if ($version >= 6.17) { echo -a [WARNING]: The mIRC Servers List v $+ $msl_ver created on  $+ $msl_crdate $+  has been installed, try to use the "/update_serverlist" command or right click into the "Status window" - 3SUCCESSFULLY }
  elseif ($version <= 6.17) { echo -a [Error]: The mIRC Servers List v $+ $msl_ver created on  $+ $msl_crdate $+  has NOT been installed, your mIRC version ( $+ $version $+ ) is too old update your mIRC version and retry to install! - 4FAILED }
}

Comments

Sign in to comment.
^WeSt   -  Oct 27, 2011

pfff

 Respond  
TheImrac   -  Oct 25, 2011

Faster processing (averages less then a tenth of a second when no update is found and .225s when a newone is found) and doesn't wait for the remote server to close the connection. Other than that, not much.

 Respond  
^WeSt   -  Oct 25, 2011

whats the difference from mine?

 Respond  
TheImrac   -  Oct 24, 2011

This is such a great concept I decided I would tackle it in my own way. I just used the ETag HTTP header to check if the file has changed.

on *:START:{ svini_update }
ON: *:UNLOAD:{
  unset %svini.etag
}

on *:SOCKOPEN:svini:{
  if ($sockerr) { 
    echo -s 14[4*14] 1Unable to Connect to mIRC.COM
    .sockclose svini
    halt
  }
  sockwrite -n $sockname GET /servers.ini HTTP/1.1
  sockwrite -n $sockname Host: www.mirc.com
  if (%svini.etag) { sockwrite -n $sockname If-None-Match: $qt($v1) }
  sockwrite -n $sockname Connection: Close
  sockwrite -n $sockname $crlf
}

on *:SOCKREAD:svini:{
  if ($sockerr) { 
    echo -s 14[4*14] 1Unable to Download Latest servers.ini File (read error)
    if ($2) { unset %svini.etag }
    .sockclose svini
    halt
  }
  tokenize 32 $sock($sockname).mark 
  if (!$2) {
    var %read
    sockread %read
    while (%read) {
      if ($regex(%read,/^HTTP/1.1 304  Not Modified$/)) {
        echo -s 14[9*14] 1You Have the Latest servers.ini ( $+ $calc(($ticks - $1) / 1000) $+ s)
        .sockclose svini
        halt      
      }
      elseif ($regex(%read,/^Content-Length: (\d+)$/)) { sockmark $sockname $1 $regml(1) }
      elseif ($regex(%read,/^ETag: "(.*)"$/)) { set %svini.etag.new $regml(1) }
      sockread %read
    }
  }
  else {

    sockread &read 
    while ($sockbr) {
      bwrite $+($mircdir,servers.ini.tmp) -1 -1 &read
      if ($file($+($mircdir,servers.ini.tmp)).size == $2) {
        svini_finish $1
        halt
      }
      sockread &read  
    }
  }
}

ON *:SOCKCLOSE:svini:{
  tokenize 32 $sock($sockname).mark 
  echo -s 14[4*14] 1Unable to Download Latest servers.ini File (socket closed)
  if ($2) { unset %svini.etag.new }
  .sockclose svini
  halt
}
alias svini_update {
  echo -s 14[8*14] 1Checking for new servers.ini File...
  .remove $+($mircdir,servers.ini.tmp)
  if ($1 == -force) { unset %svini.etag }
  sockopen svini www.mirc.com 80
  sockmark svini $ticks
}
alias -l svini_finish {
  .copy -o $+($mircdir,servers.ini) $+($mircdir,servers.ini.old)
  .copy -o $+($mircdir,servers.ini.tmp) $+($mircdir,servers.ini)
  set %svini.etag %svini.etag.new
  unset %svini.etag.new
  echo -s 14[9*14] 1Successfully Downloaded Latest servers.ini ( $+ $calc(($ticks - $1) / 1000) $+ s)
  .sockclose svini
}

Quick ninja Edit: Changed it so the etag doesn't get update until it finishes copying over the new server list.

 Respond  
^WeSt   -  Oct 24, 2011

Anyway, there are 100 ways to build a script any user pick his own ! :)

 Respond  
Jethro   -  Oct 24, 2011

Yes ^West, I understand. The servers.ini posted at mIRC.com has to be the latest. If I were you, again, I would just use the socket to GET all the info, /write -c the current servers.ini in my mIRC directory and writeini servers.ini as the new file. The hash table won't even be necessary.

 Respond  
^WeSt   -  Oct 24, 2011

@cupcake Yes use 6.17 and will work in 6.16 does not have the $qt alias and i was boring to make it work into the 6.16 and under.

@Jethro The script take only the latest servers.ini file from the website (check description) , this snippet has made with hash tables for 2 reasons first the hashes are more quick and second i like more the hashes because variables can delete and edit any time in the MSE but the hashes are more safer for me!

@toclafane1 Maybe is complicated the result is that is working !

 Respond  
cupcake   -  Oct 23, 2011

My Mirc is to old to use this snippet ..LoL it came back with this message.
[Error]: The mIRC Servers List v1.0 created on 23/10/2011 has NOT been installed, your mIRC version (6.16) is too old update your mIRC version and retry to install! - FAILED
Anyone that needs this snippet, seems to work pretty well. Just need a newer Mirc. Good job ^WeSt :)

 Respond  
Stewie1k94   -  Oct 23, 2011

This just looks complicated :/

 Respond  
Jethro   -  Oct 23, 2011

So, what this socket script does is to get the latest info from mIRC.com's server.ini? Why not just GET all the info on that page, remove the existing servers.ini using the /remove command and then write it as a new ini file in your mIRC directory? It's kind of troublesome to use hash tables for this.

 Respond  
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.