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.

Variable interpolation

Old posts that have not been replied to for several years.
Locked
a
amazingwilf

Variable interpolation

Post by amazingwilf »

Hello,

I would like to get my bot to greet people as they enter the channel, but using a random string from a list. The code I'm using is as follows:-

Code: Select all

set greets {
     "Hi $nick, good to see you"
     "$nick, come on in and warm your feet"
     "Look guys, it's $nick!"
}

proc user_join {nick uhost hand chan args} {
     global greets
     putchan $chan "[lindex $greets [rand [llength $greets]]]"
}

bind join * "*" user_join

It's working fine, except that the $nick variable is being parsed literally, with the greet coming out as "Look guys, it's $nick!" rather than "Look guys, it's AmazingWilf!". I've been browsing through tcl documentation for a couple of days now to try to figure out how I can get the interpreter to interpolate the value of $nick rather than the literal, but to no avail.

Can anyone help with this?

Thanks in advance,

David
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Try subst?
Locked