mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2005
Posts: 18
L
latumus Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Oct 2005
Posts: 18
Code:
 
ON 1: TEXT:*:# {
  if ($nick isin %watch) {
    set %actionnick $nick
    set %actionmsg $1-

    if (check1 isin %actionmsg) && (check2 isin %actionmsg) {
      if ($read(c:\check.txt,w,$9) == $null) {
        if (check3 isin %actionmsg) && (check4 isin %actionmsg) {
          if (fail1 isin %actionmsg) { halt }
          else { action }
        }
      }
    }

    unset %actionnick
    unset %actionmsg
  }
  else {
    halt
  }
}
 


im wondering how i can make this cleaner adding new checks with appropriate actions is quite a hassle since i add alot of these. anyone have any suggestions?

Last edited by latumus; 17/10/05 03:52 AM.
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Some things (not all)

I would move the $read to the innermost IF, it thats possable, sicne it well be the identifier that takes the longest on average to return a value, ie: do it the least amount of times as u can.

if (fail1 isin %rlsmsg) { halt } could be mode to the top since if its true it halts no matter what

use VAR instead of SET and then u dont need to UNSET

remove the else { halt } at the end its not needed.

im wondering how i can make this cleaner adding new checks with appropriate actions is quite a hassle since i add alot of these. anyone have any suggestions? [/quote]

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I thought I saw a usage of regex which checked for multiple occurances in a single variable, which would allow them to do the equivalent of if (%actionmsg contains check1,check2,,check3,check4) {

I've been hunting for it, but haven't been able to find it. If I do find it, or if someone can write this, I think it would help.

Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Would it be possible to use user levels instead of the %watch variable? It's cleaner, more correct, one less test you need to script, allows for address and ident checking too. Just type /guser watched nicknamehere when nicknamehere is online and he'll be added to the list. You can also just edit the user list directly , just hit alt-r alt-u

I reversed the $read logic, if it returns something it's bad, instead of if it returns nothing it's ok. Not that if the checked line equals 0 or $false, then it will ge wrong, but I guess that won't be a problem.

If you can narrow the trigger text down more, it would be better. Maybe use some & & & & to signify different words, so that the script knows that it needs at least that many words to trigger.

Code:
on watched:TEXT:*check1*:#channelname: {
  if (check2 isin $1-) && (check3 isin $1-) && (check4 isin $1-) {
    if ((fail1 isin $1-) || ($read(c:\check.txt,w,$9)) return
    ; do your stuff here
  }
}


With the current non-informative checks I can't help you further, but there is a possibility that all the isin tests can be replaced by a single $regex, but then I'd need at least 5 different messages with what to match and what not and what can change and how etc...


Link Copied to Clipboard