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.

[SOLVED YO] Help with a bind

Help for those learning Tcl or writing their own scripts.
Post Reply
H
Hamish
Voice
Posts: 25
Joined: Mon Mar 27, 2006 1:20 pm

[SOLVED YO] Help with a bind

Post by Hamish »

bind pub - ! random:stuff

But it only works when someone types !
I want it to work when someone types
!randomthing
!stuff
!lollllers
Basically when someone types anything after it.
Last edited by Hamish on Tue Oct 17, 2006 12:03 pm, edited 1 time in total.
Thanks, Hamish.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Try with 'pubm' then.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Code: Select all

bind pub - !randomthing random:stuff
... etc
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
H
Hamish
Voice
Posts: 25
Joined: Mon Mar 27, 2006 1:20 pm

Post by Hamish »

Yes but there is lots of different possible !commands I could have. I used this:

bind pubm - "% !*" proc:stuff

And that worked.
But I need a way so I can store all the possible commands after that, I tried in a text file but It didn't quite work, can someone help?
Thanks, Hamish.
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

You're better off using if's to test the input for specific keywords, otherwise people will type all kinds of random junk and you'll soon find your bot behaving badly.

There are plenty of example scripts for making triggers, using either a specific comamnd with pub, or using wildcards with pubm. Check the tcl archive.
H
Hamish
Voice
Posts: 25
Joined: Mon Mar 27, 2006 1:20 pm

Post by Hamish »

I made a list out of the possible triggers then used lsearch to check if what the user entered was a trigger.

But now.

I have two triggers:

bind pubm - "% !*" stuff:private
bind pubm - "% @*" stuff:public

But when someone types !something - It activates both procedures! :?

Also is there a command like, setchaninfo but to set a user's default info line instead of just the info line for that channel?
Thanks, Hamish.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Hamish wrote:But when someone types !something - It activates both procedures! :?
Sounds like you have some old binds left over from an earlier experiment.
.restart your bot to get rid of the old binds.

Here's another way to do what you're doing using an array (not tested as usual :P)

Code: Select all

# don't inclide the prefix character in the array keys
# because it is trimmed off in the stuff proc to allow
# having several prefixes for the same command
array set stuff {
	omg {what did your god do?}
	lol {what are you laughing at?}
	help {help yourself.}
	hello {hi there!}
}

bind pubm - "% !*" stuff
bind pubm - "% @*" stuff

proc stuff {n u h t a} {
	global stuff
	if {[scan $a "%*c%s" w]&&[info exists stuff($w)]} {
		puthelp "PRIVMSG $t :$stuff($w)"
	}
}


# to make it work with private messages, add this:
bind msgm - !* pstuff
proc pstuff {n u h a} {stuff $n $u $h $n $a}
Hamish wrote:Also is there a command like, setchaninfo but to set a user's default info line instead of just the info line for that channel?

Code: Select all

setuser $hand info "whatever"
EDIT: messed up scan pattern :P
Last edited by user on Tue Oct 10, 2006 4:05 pm, edited 1 time in total.
Have you ever read "The Manual"?
H
Hamish
Voice
Posts: 25
Joined: Mon Mar 27, 2006 1:20 pm

Post by Hamish »

Dude, you rock!
Thanks.
Thanks, Hamish.
H
Hamish
Voice
Posts: 25
Joined: Mon Mar 27, 2006 1:20 pm

Post by Hamish »

Ok I did what you said but now when I type:

@trigger It simply does nothing.
!trigger Works great, ofcourse.
Thanks, Hamish.
Post Reply