Code: Select all
set slaps {
"I love you, $nick!"
"\001ACTION slaps $nick back\001"
}
Code: Select all
set slaps [list
"I love you, \$nick!"
"\001ACTION slaps \$nick back\001"
]
Code: Select all
set slaps {
"I love you, $nick!"
"\001ACTION slaps $nick back\001"
}
bind CTCP - ACTION slaps
proc slaps {nick host handle chan keyword text} {
global slaps
global botnick
if {[lindex $text 2] == "slaps"} {
if {[lindex $text 1] == $botnick} {
putserv "PRIVMSG $chan : [lindex $slaps [rand [llength $slaps]]] ."
}
}
}
Code: Select all
if {[lindex $text 2] == "slaps"} {
Code: Select all
if {[strlwr [lindex [split $text] 2]] == "slaps"} {
Code: Select all
set slaps {
"I love you, $nick!"
"\001ACTION slaps $nick back\001"
}
bind CTCP - ACTION action:slaps
proc action:slaps {nick host handle chan keyword text} {
global slaps
global botnick
if { [string tolower [lindex $text 0]] == "slaps" } {
if { [string tolower [lindex $text 1]] == [string tolower $botnick]} {
putchan $chan "[lindex $slaps [rand [llength $slaps]]]"
}
}
}
Code: Select all
set slaps {
"I love you, $nick!"
"\001ACTION slaps $nick back\001"
}
bind CTCP - ACTION action:slaps
proc action:slaps {nick host handle chan keyword text} {
global slaps botnick
if { [string tolower [lindex $text 0]] == "slaps" } {
if { [string tolower [lindex $text 1]] == [string tolower $botnick]} {
putchan $chan "[string map "\$nick $nick" [lindex $slaps [rand [llength $slaps]]]]"
}
}
}
I suggested this method because it's more flexible than using static keyword->value translations, but if the nick is the only variable you'll ever use in the messages the string map solution is fineuser wrote:...The message at this point is just a string, so the $nick part will not be replaced by the current 'nick' variable's content unless we tell tcl to parse the message for us. 'subst' is a good way to do this.