Hm... I didn't read that well enough. Thought you asked about using stuff like /hi. Anyhow, regex may be the best way to do this, but I'm not that good at it and since you're learning, it's better to stick to not using regex for now...

Code:
on *:text:*:#: {
  if ($1 == hi || $1 == hello || $1 == hey) {
    msg $nick Hello, how are you?
    set -u20 $+(%,hello.,$nick) 1
  }
  elseif ($+(%,hello.,$nick) != $null) {
    var %words = fine ok okay good
    if ($istok(%words,$1,32) || ($istok(%words,$2,32) && $1 == I'm) || ($istok(%words,$2,32) && $1 = Im) || ($istok(%words,$3,32) && $1-2 == I am)) {
      msg $chan That's good.
    }
  }
}


Basically, here's an explanation:

The first IF will happen if someone says Hi or Hey or Hello. Note that I didn't include punctuation in the check, this is just an example, anyhow. The set will set a variable with their nick in the variable name to a value (any value is fine) and it will unset it (-u) in 20 seconds.

The second IF will happen if the variable with the nick's name is set to something and the person says one of the things in the %words variable. This basically means that in that 20 seconds that the variable is set, if the person replies with one of the words, the script responds. If they take more than 20 seconds, then it won't respond. By including the nick in the variable name, it lets you identify who is talking if they said hi previously.

The while loop can be seen with /help /while.

The $istok section is a bit more advanced, but I think it's still easier to understand than trying to explain regex at your current scripting level.

/help tokens

$istok lets you find out if there is a specific token in the text. A token is something separated by a specific character. Words in a sentence are tokens that are separated by spaces.

So:

$istok(text,token to look for,character between tokens)

$chr(32) is a space and $1 is the text and since we put %c as the current word in the list of words (using $gettok), then $istok($1,%c,32) is used.

The way it is set up, it will trigger if a person wrote any of the %words as the first word of the reply, or they wrong I'm followed by any of the %words, or they wrong Im followed by any of the %words, or they wrong I am followed by any of the %words.

This isn't really a "simple" script, but when you're trying to catch multiple ways someone could respond rather than only using a specific trigger, it takes more effort.

EDIT: I pasted the last $istok and forgot to change which "word" was needed... it's fixed now.

EDIT2: Ok, I was being stupid... I've edited it so that it's better. No need for the while loop... I was doing it backwards of the easy way. laugh

By changing it so that we're looking for word $1 or $2 or $3 inside %words, it's easier. So, $istok(%words,word,32). It's the reverse of how I was doing it. I just wasn't thinking earlier. You can ignore the comments above about the loop and how I did $istok as neither are like that now.

Last edited by Riamus2; 23/09/05 06:06 PM.

Invision Support
#Invision on irc.irchighway.net