# PINGRELAY Script ------------------------------- [ Usage: /ping <nick> ] ---
# Stores time of ping in message itself instead of in a single local variable.
#
# Original Idea: Robey POINTER     (Robey@IRC - robey@wright.sarc.msstate.edu)
# Inspiration:   Klaus ZEUGE              (sojge@IRC - sojge@Minsk.DoCS.UU.SE)
#                Nicolas PIOCH         (Nap@IRC - pioch@poly.polytechnique.fr)
# ircII2.2pre6:  Ian FRECHETTE       (Daemon@IRC - frechett@spot.Colorado.EDU)
# This version:  Jeremy Nelson                 (hop@IRC - jnelson@rush.cc.edu)
# Collaboration: Peter HELLMONDS (snoopy@IRC - hellmond@phoenix.Princeton.EDU)
# ----------------------------------------------------------------------------
# CONVERTED for ircII2.3.17+10

# Launch time is piggybacked on the PING RELAY request and sent out to the net.
# (The echo *** PING ... line can be taken out, it's just for your information.)

# NOTICE NOTICE NOTICE   the ping alias is now called OPING

eval echo *** Notice:  The ping alias has been changed to OPING
eval echo *** ircII2.2 has a built in PING command.  You can use it.

alias oping {
	@ ping.tmp = 0
        fe ($*) px
	{
		ctcp $px ERRMSG PING RELAY $TIME()
		echo *** PING to $px launched \( $STIME($TIME()) \)
	}
}

# When the PING RELAY comes back, print the time difference (now-launch time)

on ^ctcp_reply "* ERRMSG PING RELAY *" {
        echo *** PONG Time to $0: ${time()-[$4]} seconds roundtrip.
}

# To be warned that you're being pinged, uncomment the following line:
on ^ctcp "* ERRMSG PING RELAY *" {
        echo *** PING Received a relay ping from $0
}
# end of script: PINGRELAY
