| View previous topic :: View next topic |
| Author |
Message |
chadchoud Voice
Joined: 20 Sep 2006 Posts: 2
|
Posted: Wed Sep 20, 2006 2:16 pm Post subject: PING script |
|
|
I wrote a tcl ping script. I'm still a newbie in tcl. I hope somebody can help.
Here's the script:
| Code: |
bind PUB - !ping CheckPing
proc CheckPing {nick uhost hand chan text} {
putserv "privmsg $chan : [lindex [split $text] 0]"
if { [lindex [split $text] 0] != "" } {
set ::moo(arg) [lindex [split $text] 0]
} else {
set ::moo(arg) $nick
}
set ::moo(ticks) [clock clicks -milliseconds]
set ::moo(chan) $chan
putserv "privmsg $chan : $moo(arg) "
putserv "privmsg [lindex $moo(arg) :\001PING [clock clicks -milliseconds]\001"
putserv "privmsg $chan :ping sent!"
putserv "privmsg $chan :I'm sending the ping request to $moo(arg) now."
}
bind CTCR - PING* Reply
proc Reply {nick uhost hand dest keyword text} {
global server moo
putserv "privmsg $moo(chan) :$moo(arg)'s ping reply from $server is : [expr [expr [clock clicks] - $moo(ticks)] / 1000]"
}
|
As you see, I added some debuging, and found that $moo(arg) isn't filled.
I didn't check the ctcp reply yet.. |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Sep 20, 2006 2:47 pm Post subject: |
|
|
| Code: |
set pingchans "#mychan #chan2 #etc"
bind pub - .ping pub:ping
bind ctcr - PING ctcr:ping
proc pub:ping {nick uhost hand chan arg} {
global pingreq pingp pingchans
if {[lsearch -exact $pingchans $chan] == -1} {
puthelp "PRIVMSG $nick :ping disabled on $chan"
return
}
set arg [string trim $arg]
if {![info exists pingp($chan)]} {
set pingp($chan) 0
}
utimer 2 [list incr pingp($chan) -1]
if {[incr pingp($chan)] < 3} {
if {[set targ [lindex [split $arg] 0]] == ""} {
putserv "PRIVMSG $chan :Use: .ping <nick> or .ping me"
return
}
if {([string equal -nocase "me" $targ] == 1)} {
putserv "PRIVMSG $nick :\001PING [clock clicks -milliseconds]\001"
set pingreq([string tolower $nick]) "$chan"
return
}
if {[onchan $targ $chan]} {
putserv "PRIVMSG $targ :\001PING [clock clicks -milliseconds]\001"
set pingreq([string tolower $targ]) "$chan"
} else {
puthelp "PRIVMSG $chan :$targ is not in $chan."
}
}
}
proc ctcr:ping {nick uhost hand dest keyword arg} {
global pingreq
if {![info exists pingreq([set nnick [string tolower $nick]])]} {return}
if {[string is integer [set reply [lindex [split $arg] 0]]]} {
putserv "PRIVMSG $pingreq($nnick) :\[\002$nick\002 PING reply\]: [expr {abs([clock clicks -milliseconds] - $reply) / 1000.0}] seconds."
}
unset pingreq($nnick)
}
putlog "Ping.tcl v1.3 by Opposing Loaded..."
|
|
|
| Back to top |
|
 |
chadchoud Voice
Joined: 20 Sep 2006 Posts: 2
|
Posted: Wed Sep 20, 2006 4:42 pm Post subject: sorry |
|
|
| sorry but I didn't ask for a pre-made script. I just asked where's the problem in my own. and the "rules" on this section of the forum are "do no request scripts". |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Wed Sep 20, 2006 5:17 pm Post subject: |
|
|
And it would be polite for you to enclose your code within code tags. _________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Sep 20, 2006 7:56 pm Post subject: Re: sorry |
|
|
| chadchoud wrote: | | sorry but I didn't ask for a pre-made script. I just asked where's the problem in my own. and the "rules" on this section of the forum are "do no request scripts". |
I posted it as an example of a working script. Take it as such, or read it and learn from it. |
|
| Back to top |
|
 |
stdragon Owner

Joined: 23 Sep 2001 Posts: 959
|
Posted: Fri Sep 22, 2006 10:06 pm Post subject: |
|
|
| Code: |
putserv "privmsg [lindex $moo(arg) :\001PING [clock clicks -milliseconds]\001"
|
That's the only obvious error I see so far. When you tested $moo(arg) did you get an error (undeclared) or was it just the wrong value (e.g. empty)? |
|
| Back to top |
|
 |
|