Well i have been making a script that does this:
example:
Gnome says: I am cool
bot echoes: cool
the thing is that i want it to only echo one string of a line. the string will chance tho.
i managed to get it echo all fine but i havnt found a way to filter 'I am' away!
set trigger "*-TEST"
bind pubm - * check
proc check {nick uhost hand chan text} {
global trigger
if {[validuser $hand]} {
if {[string match -nocase $trigger $text]} {
putchan $chan "$text"
This script echos if some says like:
I NEED HELP.HERE-TEST
it echos that, BUT i want to cut
'I NEED' away from the echo! so that it echo's all text before -TEST as HELP.HERE-TEST.
ppslim;
well i cant tell the exact purpose for the script on public here.
the 'I NEED' IS same all the time(bot announce)
example:
user/bot announces: i am oh so nice that i will go to Mtv music awards at 1.1.2002 oh yes.
now i want the bot to cut all other expect Mtv music awards and output it to the channel. 'Mtv music awards' is a changing part expect for the last word(awards). In this case it is 'awards' so this explains why i putted ' set trigger "*-TEST" ' on the orignal code, in this case it would be: set trigger "*-awards"
The problem with your examples is that in the first one, you wanted only the word that contains the trigger. In the second one, you wanted the trigger, plus the two preceding words. With the information you have given, the computer can't know whether to extract 1, 2, 3, or more words.
So, you need to provide more information to the script, namely a "header" and a "trailer" for it to look for. "I NEED " would be your header, and "-TEST" would be your trailer.
set header "I NEED "
set trailer "-TEST"
set text "I NEED HELP.HERE-TEST"
set start [string first $header $text]
if {$start < 0} {return 0}
set end [string first $trailer $text]
if {$end < 0} {return 0}
incr start [string length $header]
incr end -1
if {$start > $end} {return 0}
set match [string range $text $start $end]
On 2001-12-01 19:42, stdragon wrote:
The problem with your examples is that in the first one, you wanted only the word that contains the trigger. In the second one, you wanted the trigger, plus the two preceding words. With the information you have given, the computer can't know whether to extract 1, 2, 3, or more words.
So, you need to provide more information to the script, namely a "header" and a "trailer" for it to look for. "I NEED " would be your header, and "-TEST" would be your trailer.
set header "I NEED "
set trailer "-TEST"
set text "I NEED HELP.HERE-TEST"
set start [string first $header $text]
if {$start < 0} {return 0}
set end [string first $trailer $text]
if {$end < 0} {return 0}
incr start [string length $header]
incr end -1
if {$start > $end} {return 0}
set match [string range $text $start $end]
BUT I NEED HELP.HERE-TEST
those that are bolded are NOT channing words, but HELP.HERE is an chaning part, so thats why i put it to trigger of from *-TEST
And i dont want it to output I NEED
thanks in advice
<font size=-1>[ This Message was edited by: gnomes on 2001-12-02 04:08 ]</font>
I am afraid I can't help with this script, as I still fail to see exactly what I need to extract.
1 min we are asked to extract certain words from one sentace, then the next another sentace, then back top the original sentace, not to montion your attitude.
Besides, the code allready pasted has the ability to axtract the words you need.
sry if i dident make myself clear.
yes i know how to extract words that are known. extract a word that is chaning but has only one not chaning part.
in this case -TEST
like if. i.am-test.
it would need to echo i.am.test
i can make it echo that but i.am is a chaning variable. So would *-test output it?
Thanks pslim.
but i know how to that. That script would echo all text said by someone.
e.g haha good-test yes
it echos that all.
i want to remove words haha and yes.
ofcourse good-test is still a chaning variable.
sorry to bother again =/
I pasted that last example in, because I knew I was gonna get a reply like this
Out of all the posts you have made, there has been consistant string out text to extract, and no consistant text to leave behind.
Tcl is only as smart as you program it, as has no AI abilities, which looking at your needs, it would need to.
If I fail to see a post letting me know a real life example, rather that "this is a test" crap, I am goign to ignore it from now on, because this thread is going nowhere without such information.