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.

TCL script help :)

Old posts that have not been replied to for several years.
Locked
G
Guest

Post by Guest »

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!

Any suggestions?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

It would be better if you pasted you code here, as it would help understand what you are trying to do.
G
Guest

Post by Guest »

Code: Select all

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.

Thanks in advice

p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

But the "I NEED" is part of the text before "-TEST".

How do you know that it is gonna be "I NEED" every time?

Do you just want to strip the first 2 words?

What is some1 types "I NEED TO GET SOME HELP.HERE-TEST"?
G
Guest

Post by Guest »

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"

thanks again
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

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.

Code: Select all

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]
G
Guest

Post by Guest »

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.

Code: Select all

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>
G
Guest

Post by Guest »

stdragon, ppslim?
please?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

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.
G
Guest

Post by Guest »

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?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

bind pubm - "*-TEST" test
proc test {nick uh hand chan arg} {
puthelp "PRIVMSG $chan :${arg}"
}
G
Guest

Post by Guest »

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 =/
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

I pasted that last example in, because I knew I was gonna get a reply like this :sad:

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.
G
Guest

Post by Guest »

ok, i private messaged you the real purpose for the script :/
sorry
Locked