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.

need help with my tcl script

Old posts that have not been replied to for several years.
Locked
c
cupid-

need help with my tcl script

Post by cupid- »

Can someone tell me whats wrong with my code?
this is the error i got.

TCL error [pub_slap]: no value given for parameter "keyword" to "pub_slap"


#### Revenge - Slap - Start ####

bind ctcp - "ACTION" pub_slap

set slapreply {
"reply 1"
"reply 2"
"reply 3"
"reply 4"
"reply 5"
}

proc pub_slap { nick uhost hand dest chan keyword text } {
global botnick
global slapreply
if {[string index $dest 0] != "#"} { return 0 }
if {[lindex $text 1] == "slaps"} {
if {[lindex $text 1] == $botnick} {
putserv "PRIVMSG $chan :[lindex $slapreply [rand [llength $slapreply]]]"
}
}
}

#### Revenge - Slap - End ####
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

proc pub_slap { nick uhost hand dest chan keyword text } { 
this line is wrong, read the tcl-commands.doc about binds

Code: Select all

proc pub_slap { nick uhost hand dest keyword text } { 
Elen sila lúmenn' omentielvo
c
cupid-

Post by cupid- »

doesnt work still :(
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Please re-read your logic.

Code: Select all

proc pub_slap { nick uhost hand dest chan keyword text } { 
global botnick 
global slapreply 
if {[string index $dest 0] != "#"} { return 0 } 
if {[lindex $text 1] == "slaps"} { 
if {[lindex $text 1] == $botnick} { 
putserv "PRIVMSG $chan :[lindex $slapreply [rand [llength $slapreply]]]" 
} 
} 
}
The above requores that the 2nd word be slaps, and that your botnick be slaps.

My guess is you want the index to be 0 for the slaps match.

Aditionaly, you are using list commands (lindex) on a string ($text). You need to convert the string into a list first using [split]
Locked