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 with response to CTCP ACTION

Old posts that have not been replied to for several years.
Locked
User avatar
darkmare
Voice
Posts: 12
Joined: Mon Apr 12, 2004 12:55 pm
Location: Beaverton, OR
Contact:

Help with response to CTCP ACTION

Post by darkmare »

OK, after searching the last few hours through at least 15 pages of search returns, I'm still having trouble. First off,here's the part of the scipt:

bind CTCP - action act:scritches

proc act:scritches {nick mask hand chan arg} {
global scritches
if {[lindex $arg 1] == "scritches"} {
if {[lindex $arg 2] == "Max"} {
putserv "PRIVMSG $chan :\001ACTION [lindex $scritches [rand [llength $scritches]]] at $nick."
}
}
}

set scritches {
"purrs loudly"
"fires up the rumble machine"
"looks up"
"mrrrps"
}

I'm trying to get a cat to respond to actions (and have random responses). The basic one above is responding to "ACTION Brendan scritches Max" (or MaxCat). I'm fairly new to tcl, and this is my second bot. Eventually he'll respond to other things and queue them up for eating, and well, this'll be a complicated bot by the time I get done with it :) You'll probably see me here often. I'm obviously missing something here, because it's not working, and I'm still not attuned to the nuances of tcl syntax.

I'd appreciate any help with this.
Image
Brendan K Callahan Undernet: MaryFinn & PixelCat on #Mary'sPlace | http://3whack.org/brendan/ Theft by Deception DnB music (Released under the CreativeCommons License)
User avatar
YooHoo
Owner
Posts: 939
Joined: Thu Feb 13, 2003 10:07 pm
Location: Redwood Coast

Post by YooHoo »

You might wish to take a look at a script Nerfbendr wrote called ActionResponder.tcl. It does almost the same thing.

Nerfbendr's Site
:mrgreen:
User avatar
darkmare
Voice
Posts: 12
Joined: Mon Apr 12, 2004 12:55 pm
Location: Beaverton, OR
Contact:

Post by darkmare »

Late last night, this is what I got working. One of the biggest errors was that the CTCP ACTION requires 6, not 5, variables to be passed.

bind CTCP - action act:scritches

proc act:scritches {nick mask hand chan keyword arg} {
global scritches
if {[lindex $arg 0] == "scritches"} {
if {[lindex $arg 1] == "Max" || [lindex $arg 1] == "MaxCat" || [lindex $arg 1] == "max" || [lindex $arg 1] == "maxcat"} {
putserv "PRIVMSG $chan :\001ACTION [lindex $scritches [rand [llength $scritches]]] $nick.\001"
}
}
global pets
if {[lindex $arg 0] == "pets"} {
if {[lindex $arg 1] == "Max" || [lindex $arg 1] == "MaxCat" || [lindex $arg 1] == "max" || [lindex $arg 1] == "maxcat"} {
putserv "PRIVMSG $chan :\001ACTION [lindex $pets [rand [llength $pets]]] $nick.\001"
}
}
global rubs
if {[lindex $arg 0] == "rubs"} {
if {[lindex $arg 1] == "Max" || [lindex $arg 1] == "MaxCat" || [lindex $arg 1] == "max" || [lindex $arg 1] == "maxcat"} {
putserv "PRIVMSG $chan :\001ACTION [lindex $rubs [rand [llength $rubs]]] $nick.\001"
}
}
}

Someone also gave me a hint about using string -nocase to take care of the case issues. Now one thing this will not do, is accept wildcards [lindex $arg 1] == "Max*" and not sure why, it "breaks" it to do so (runs, loads, just won't respond), but it does. I'll take a look at that script you suggested.
Image
Brendan K Callahan Undernet: MaryFinn & PixelCat on #Mary'sPlace | http://3whack.org/brendan/ Theft by Deception DnB music (Released under the CreativeCommons License)
User avatar
caesar
Mint Rubber
Posts: 3777
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Instead of lots of if's use switch to "evaluate one of several scripts, depending on a given value"
Once the game is over, the king and the pawn go back in the same box.
Locked