mIRC Home    About    Download    Register    News    Help

Print Thread
#90783 17/07/04 08:53 AM
Joined: Jan 2004
Posts: 46
F
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Jan 2004
Posts: 46
Ok, I'll try to make this simple:
From the help file: The match text can be a wildcard string, where:

* matches any text
& matches any word
text matches if text contains only this word
[edit]

the bold part is my concern. I have no problem making it trigger on text using the simple '1liner' I'll call it, like this:

on 1:TEXT:hello:#:/msg $chan Welcome to $chan $nick!

(this will obviously ONLY trigger when hello, and hello ONLY is said.) Now my problem: When I try to use the embedded type of 'on text', for a singular response to dozens of text triggers, it does work on the text word[s], but unfortunately, it ALSO is triggering on the match word[s] followed by a space, and than anything else after that. Example: "hello how are you?" will also trigger when I set ($1 == hello) || followed by others. Example:

Code:
   if ($1 == word1) || ($1 == word2) || ($1 == word3) || {
    echo -s Channel: $chan
    echo -s Text: $1-
    echo -s Nick: $Nick
    .timer 1 4 .msg # 10 $nick : 3 $1 04is not acceptable language here
} 


With that coding, it is triggering on word1<space>(anything else after that) and instead what I want, is to trigger on word1 ONLY, by itself, as I mentioned above in the single one-liner example from the help file.

I have many words and different versions, so the embedding style is the way to go for sure. Can anyone please help me to find the simple thing I am missing here? Thanks in advance.

#90784 17/07/04 08:58 AM
Joined: Apr 2004
Posts: 45
V
Ameglian cow
Offline
Ameglian cow
V
Joined: Apr 2004
Posts: 45
if I understand what you're asking correctly, what you want is something like:

if (($1 == wordhere) && (!$2)) { do stuff }

I think I can work with your example:

Code:
  if (($1 == word1) || ($1 == word2) || ($1 == word3)) &amp;&amp; (!$2) { 
    echo -s Channel: $chan    
    echo -s Text: $1-    
    echo -s Nick: $Nick    
    .timer 1 4 .msg # 10 $nick : 3 $1 04is not acceptable language here 
} 


Just FYI, I use (!$2) out of habit; it's a shortcut, and actually means if ($2 == $null) .

Another option would be to simply take your code (remove the extra || like I did), and change all your $1 to $1- . Then it's saying if everything they type is [word], instead of just if the first thing they type is [word].

Hope this helps.

-Venoman

#90785 17/07/04 09:31 AM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Quote:
Just FYI, I use (!$2) out of habit; it's a shortcut, and actually means if ($2 == $null) .


Just to be really correct:
if (!$2)
is exactly the same as
if (($2 == $null) || ($2 == 0) || ($2 == $false))


More to the point: yes, better use $1- or $regex (if you're familiar with it)

#90786 17/07/04 03:22 PM
Joined: Jan 2004
Posts: 46
F
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Jan 2004
Posts: 46
Yep, both suggestions you gave me worked for their particular uses. Where I had single words, I just changed them all to $1- , and where 2 words or more were needed, I just added the '&& (!$(word#)' and it did what I needed.

Fyi, I actually had all the words marked as $1-, when they were all in their 'each word had their own script' format, and when I combined them, I forgot to add the $1(-) ....

Isn't it funny how a single space, bracket (or in this case a hyphen) will make such a huge difference in a scripts funtionality? (we've all been there at some point, haven't we?)...lol

Also, the extra '||" was only there because there are dozens more words in that script, and that was left by accident when I chopped it down for posting...what can I say, I was tired as ----..lol... Thanks for your help, and I knew it was something simple, because it had worked before.

Kelder, thanks too for your explanation...maybe I don't use regex often enough.




Link Copied to Clipboard