########### PiNG THiNGiE 1.0 ############
# designed and programmed by FlyBoyUSA  #
# for original use in #emuroms Undernet #
#########################################
# Bug reports and ideas goto flyboyus@modex.com
# I love comments, complaints, death threats, and suggestions :-)

bind pub - !ping ping_me
bind pub - ping ping_me
bind ctcr - PING ping_me_reply

proc ping_me {nick uhost hand chan arg} {
     global pingchan pingwho
     set arg [string toupper $arg]
     if {$arg == "HELP" || $arg == "" || [string match "#*" $arg]} {
          puthelp "NOTICE $nick :PiNG THiNGiE SYNTAX - !ping or ping <NICK (NO channels) or ME to have it PING YOU>"
          return 0
     } elseif {$arg == "ME"} {
          putserv "PRIVMSG $nick :\001PING [unixtime]\001"
          set pingwho 0
          return 1
     } else { 
          putserv "PRIVMSG $arg :\001PING [unixtime]\001"
          set pingwho 1
          set pingchan $chan
          return 1
     }
}

proc ping_me_reply {nick uhost hand dest key arg} {
     global pingchan pingwho
     if {$pingwho == 0} {
          puthelp "NOTICE $nick :PiNG THiNGiE - Your ping reply took [expr [unixtime] - $arg] seconds"
          return 0
     } elseif {$pingwho == 1} {
          puthelp "PRIVMSG $pingchan :PiNG THiNGiE - $nick's ping reply took [expr [unixtime] - $arg] seconds"
          return 0
     }
}

putlog "=__ PiNG THiNGiE 1.0 by FlyBoyUSA Loaded __="
