This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

help with ping.tcl

Old posts that have not been replied to for several years.
Locked
User avatar
mrdr
Halfop
Posts: 42
Joined: Thu Jun 16, 2005 2:20 pm
Location: Lithuania / Vilnius / Underground
Contact:

help with ping.tcl

Post by mrdr »

Here is the code edited by me:

Code: Select all

##########################################
# Ping.tcl 0.1 by #egghelp@efnet (KuNgFo0)
#
set ping_flag "-"
set ping_chans "#egghelp"
set ping_command "ping"

bind msg $ping_flag $ping_command msg_ping
bind pub $ping_flag|$ping_flag $ping_command pub_ping
bind ctcr - PING ctcr_ping

putlog "*** Ping.tcl loaded"

proc msg_ping {nick uhost hand arg} {
 pub_ping $nick $uhost $hand $nick $arg
}

proc pub_ping {nick uhost hand chan arg} {
 global ping_chans ping_data botnick
 if {(([lsearch -exact [string tolower $ping_chans] [string tolower $chan]] != -1) || ($ping_chans == "*") || ([string index $chan 0] != "#")) && (![matchattr $hand b])} {
  if {($arg != "") && ([matchattr $hand o])} {
   set targnick [string tolower [join [lrange [split $arg] 0 0]]]
  } else {
   set targnick [string tolower $nick]
  }
  if {([lsearch -exact $targnick [string tolower [array names ping_data]]] == -1) && ($targnick != [string tolower $botnick])} {
   putserv "PRIVMSG $targnick :\001PING [clock clicks]\001"
   set ping_data($targnick) $chan
   timer 5 "ping_unset $targnick"
  }
 }
}

proc ctcr_ping {nick uhost hand dest keyword arg} {
 global ping_chans ping_data
 set targnick [string tolower $nick]
 if {[info exists ping_data($targnick)]} {
  if {![catch {expr $arg}]} {
   set ping_reply "[expr ([clock clicks] - $arg) / 10000.0]"
  } else {
   set ping_reply $arg
  }
  puthelp "PRIVMSG $ping_data($targnick) :PING - $nick lagina $ping_reply sekunde(-es)"
  unset ping_data($targnick)
  foreach i [timers] {
   if {[lindex $i 1] == "ping_unset $targnick"} { 
    killtimer [lindex $i 2]
   }
  }
 }
}

proc ping_unset {targnick} {
 global ping_data
 unset ping_data($targnick)
}
This script now does only 1 person ping.
(ex:
me; ping
bot; your ping is...)
I need that i write "ping nick" and bot says "nick's ping is..."
IRC: #egghelp @ Aitvaras.NET
IRC: #NASA @ Aitvaras.NET
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I wrote a script like this, ping1.2
User avatar
mrdr
Halfop
Posts: 42
Joined: Thu Jun 16, 2005 2:20 pm
Location: Lithuania / Vilnius / Underground
Contact:

Post by mrdr »

thank you :wink:
IRC: #egghelp @ Aitvaras.NET
IRC: #NASA @ Aitvaras.NET
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

By the way I was wondering how can we, get a reply in microseconds; one more accurately? And I guess it would be only valid for TCL >= 8.4

I just use like:

Code: Select all

[duration [expr [clock seconds] - $time]]
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

you could use something like this

Code: Select all

set starttime [clock clicks -milliseconds]
set length [expr abs([clock clicks -milliseconds] - $starttime) / 1000.0]
putserv "PRIVMSG $chan: It took $length seconds"
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

That returns a rounded value of the reply, while in KungFoo's it returns a value to the nearest million. for example 1.835472 seconds.

Edit: this reply was to awyeah. But I find greenbear's code much better than the one I use in my script as it returns a value to the nearest thousand.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Thanks guys. This is the one I beleive, in KunFoo's ping.tcl located on www.eggfaq.com:

Code: Select all

[expr abs([clock clicks] - $time) / 1000000.0]
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Yes that's it, but as I said greenbear's code is neater IMO.
Locked