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 for those learning Tcl or writing their own scripts.
chadchoud
Voice
Posts: 2 Joined: Wed Sep 20, 2006 2:07 pm
Post
by chadchoud » Wed Sep 20, 2006 2:16 pm
I wrote a tcl ping script. I'm still a newbie in tcl. I hope somebody can help.
Here's the script:
Code: Select all
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..
rosc2112
Revered One
Posts: 1454 Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania
Post
by rosc2112 » Wed Sep 20, 2006 2:47 pm
Code: Select all
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..."
chadchoud
Voice
Posts: 2 Joined: Wed Sep 20, 2006 2:07 pm
Post
by chadchoud » Wed Sep 20, 2006 4:42 pm
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".
Alchera
Revered One
Posts: 3344 Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:
Post
by Alchera » Wed Sep 20, 2006 5:17 pm
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
rosc2112
Revered One
Posts: 1454 Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania
Post
by rosc2112 » Wed Sep 20, 2006 7:56 pm
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.
stdragon
Owner
Posts: 959 Joined: Sun Sep 23, 2001 8:00 pm
Contact:
Post
by stdragon » Fri Sep 22, 2006 10:06 pm
Code: Select all
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)?