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.

Check for first char of sentence

Help for those learning Tcl or writing their own scripts.
Post Reply
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Check for first char of sentence

Post by Buffy_25 »

Hello,

What i would like to do is:
When a person types a msg in the room, i would like that my bot detects when the first char of the first word of the sentence is a "["

For example
[What] do you prefer?
Then my Bot replies:
The '[' has been found!
I have the following code, but it doesn't work :(

Code: Select all

bind pub - * tclcode
proc tclcode {nick uhost hand chan arg} {
set firstword [lindex [split $arg] 0]
if {[string index $firstword 0]=="["} {puthelp "PRIVMSG #channel : The [ has been found! "}
}
Thank you for your help.

Buffy
User avatar
avilon
Halfop
Posts: 64
Joined: Tue Jul 13, 2004 6:58 am
Location: Germany

Post by avilon »

Code: Select all

bind pubm - * tclcode
proc tclcode {nick uhost hand chan arg} {
	if {[string index $arg 0]=="\["} {
		puthelp "PRIVMSG $chan :The \[ has been found!"
	}
}
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

Hi avilon.

This is working perfect if i use no colours.
If the [What] is in colour, it's not being recognized :(

Is this normal?
Can colours influence this?

Buffy
User avatar
avilon
Halfop
Posts: 64
Joined: Tue Jul 13, 2004 6:58 am
Location: Germany

Post by avilon »

Yes.
To remove control chars from a string you can use [stripcodes].

Code: Select all

[string index [stripcodes bcruag $arg] 0]
http://www.eggheads.org/support/egghtml ... mands.html
B
Buffy_25
Halfop
Posts: 63
Joined: Sat Nov 22, 2003 6:36 am

Post by Buffy_25 »

Thank you very much avilon !

Working great :)

Buffy
Post Reply