Lag check

From Scriptwiki
Revision as of 16:36, 14 February 2008 by Wiebe (talk | contribs) (initial version)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Here is a simple example of how to measure the response time from the IRC server.

Response time being the time it takes to travel from your client to the IRC server, be processed by the IRC server, and send back to your client.

; First we create an alias lagcheck, that sends out a "PING :lag <ticks>" to the server.
alias lagcheck {
  .quote PING :lag $ticks
}

; Second we create an on PONG event, to catch the reply and halt the default output.
; We then calculate the difference between the value of ticks that is returned
; and the current value of $ticks and echo the result to the status window.
on ^*:PONG:{
  if ($2 == lag) && ($3 isnum) {
    echo -s Response time: $calc($ticks - $3) ms
    haltdef
  }
}

You could also save the result to a variable and use this info in any other place, and run a timer to refresh this value at an interval.

If you use a bouncer, the bouncer may be responding to the PING request instead of the IRC server, or even return the wrong reply.