egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Check for first char of sentence

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Buffy_25
Halfop


Joined: 22 Nov 2003
Posts: 63

PostPosted: Tue Nov 01, 2005 7:09 am    Post subject: Check for first char of sentence Reply with quote

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
Quote:
[What] do you prefer?

Then my Bot replies:
Quote:
The '[' has been found!


I have the following code, but it doesn't work Sad
Code:

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
Back to top
View user's profile Send private message
avilon
Halfop


Joined: 13 Jul 2004
Posts: 64
Location: Germany

PostPosted: Tue Nov 01, 2005 8:19 am    Post subject: Reply with quote

Code:
bind pubm - * tclcode
proc tclcode {nick uhost hand chan arg} {
   if {[string index $arg 0]=="\["} {
      puthelp "PRIVMSG $chan :The \[ has been found!"
   }
}
Back to top
View user's profile Send private message
Buffy_25
Halfop


Joined: 22 Nov 2003
Posts: 63

PostPosted: Tue Nov 01, 2005 9:50 am    Post subject: Reply with quote

Hi avilon.

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

Is this normal?
Can colours influence this?

Buffy
Back to top
View user's profile Send private message
avilon
Halfop


Joined: 13 Jul 2004
Posts: 64
Location: Germany

PostPosted: Tue Nov 01, 2005 2:30 pm    Post subject: Reply with quote

Yes.
To remove control chars from a string you can use [stripcodes].
Code:
[string index [stripcodes bcruag $arg] 0]

http://www.eggheads.org/support/egghtml/1.6.17/tcl-commands.html
Back to top
View user's profile Send private message
Buffy_25
Halfop


Joined: 22 Nov 2003
Posts: 63

PostPosted: Wed Nov 02, 2005 4:41 am    Post subject: Reply with quote

Thank you very much avilon !

Working great Smile

Buffy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber