mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2010
Posts: 2
O
onijin Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
O
Joined: Jul 2010
Posts: 2
A portion of my script is acting strangely.

Code:
on *:SOCKREAD:warning: {
  if ($sockerr) {
    echo -detl sockerr
    halt
  }
  else {
    sockread %sockreader
    noop $regex(test1,%sockreader,/<td align="left" valign="top" nowrap><a(.+?) ] <\/td>/gS)
    var %m = 1
    while ($regml(test1,%m)) {
      noop $regex(test2,$regml(test1,%m),/.+nowrap>(.+?)<\/td>.+"top">(.+?)<\/td>/gS)
      var %p = 1
      while ($regml(test2,%p)) {
        inc %p 1
      }
      msg %user $+($chr(40),%m,$chr(41)) Warning was issued $regml(test2,1) for reason $+($chr(34),$regml(test2,2),$chr(34))
      inc %m 1
    }
  }
}


If say, there were 5 instances where the regex will pick up anything, the 4th would be lost, and the counter would restart.

<onijin> (1) Warning was issued 2 months ago for reason "mw"
<onijin> (2) Warning was issued 2 months ago for reason "mw"
<onijin> (3) Warning was issued 2 months ago for reason "mw"
<onijin> (1) Warning was issued 2 months ago for reason "mw"

Upon investigation of the source code received, new lines are being formed where the socket is being started again which interferes with the 4th regex. Even with various testing, I couldn't find a way around this.

What I need help with is changing this snippet into writing the whole request into a txt file, then removing all new lines or other added whitespace that interferes with the regex, and regex the end product.

Any help would be appreciate. Thanks.

Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
sockread what?? mabe the problem is on regex u have to put the sockopen <site> then we can see where is the problem


WorldDMT
Joined: Jul 2010
Posts: 2
O
onijin Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
O
Joined: Jul 2010
Posts: 2
can't. it's a restricted page, so you'd need my cookie.

But I doesn't matter. I fixed the problem.

Code:
on *:sockread:warning:{
  while ($sock($sockname).rq) {
    sockread 4096 &var
    if ($sockbr > 2) {
      bset -t &source $calc(1 + $hget(warning, source, &source)) $remove($bvar(&var, 1-).text, $cr, $lf)
      hadd -mb warning source &source
    }
  }
} 

alias warning {
  if ($hget(warning, source, &var)) {
    var %pos = 1, %n = 1, %time, %reason
    while ($bfind(&var, %pos, ago</td><td)) {
      var %pos = $v1 - 2, %length = 4
      while ($bvar(&var, %pos) != 62) {
        dec %pos
        inc %length
      }
      %time = $bvar(&var, $calc(1 + %pos), %length).text
      %pos = $bfind(&var, %pos, "top">) + 6
      %reason = $bvar(&var, $+(%pos, -, $calc($bfind(&var, %pos, </td>) - 1))).text
      echo -ag ( $+ %n $+ ) Warning issued %time for reason $qt(%reason)
      inc %n
    }
    hfree warning
  }
  else echo -eagc i * /warning: no source to examine
} 


(thanks to jaytea)

Last edited by onijin; 14/07/10 06:31 AM.

Link Copied to Clipboard