Lag check

From Scriptwiki
Jump to: navigation, search

Two simple scripts to check your lag with the 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.

Script 1

; 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.
; The difference between $ticks and the returned value is the response time in milliseconds.
; Echo this to the status window and halt the default output.
on ^*:PONG:{
  if ($2 == lag) && ($3 isnum) {
    echo -s Response time: $calc($ticks - $3) ms

Script 2

;Create alias that will notice us with $ticks
alias lagcheck {
  ; Tells the user we are checking his lag with whichever server he typed it on
  echo -atg Checking ping with $server $+ ...
  ; Set a variable to the time we ran this command
  set -u300 %ping. $+ $ticks $ticks
  ; Notice ourself
  .notice $me ping $ticks
; Receive our notice
on ^*:NOTICE:ping &:?: {
  ; make sure this notice is our script
  if $nick == $me && %ping. [ $+ [ $2 ] ] {
   ; keep us from seeing our notice
    ; calculate our lag with the server
    echo -atg Current ping with $server $+ : $calc($ticks - $2) miliseconds.
    ; cleanup 
   unset %ping. $+ $2

Put this in remote (alt+r), and use /lagcheck to check the response time from the IRC server.

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.