mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2015
Posts: 243
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
So this script is already scripted by westor.. but i was bored and started trying to make it on my own to kill my time. But i curse the moment i started cause now it's driving me crazy!
Code:
on *:SOCKREAD:*: {
  if ($sockname == mircforum) {
    if ($sockerr) { echo -at mIRC Forum Read Error.. | sockclose $sockname }
    var %mircforum
    sockread %mircforum
    if (*a href="/ubbthreads.php/forums* iswm %mircforum) {
      set %lmircsforum $remove($gettok(%mircforum,2,62),</a>,</a,amp;)
    }
    if (*href="/ubbthreads.php/topics/* iswm %mircforum) {
      set %lmirclink $remove($gettok($gettok(%mircforum,1,62),2-4,47),<a href=")
      set %lmirctop $remove($gettok(%mircforum,2,62),</a>,</a)
    }
    if (*by* iswm %mircforum) {
      set %lmircuser $remove(%mircforum,by,$chr(32))
    }
    if (*<span class="date">* iswm %mircforum) {
      set %lmircdate $replace($remove(%mircforum,@ <span class="date">,</span> <span class="time">,</span><br />),at,$+(at,$chr(32)))
    }
    if (*span name="body[0]" style="display:block">* iswm %mircforum) {
      if ($remove($gettok(%mircforum,2,62),</span>,</span) != %lmirctext) {
        set %lmirctext $remove($gettok(%mircforum,2,62),</span>,</span)
        sockclose $sockname
        var %x = 1
        while (%x <= $scon(0)) {
          if ($scon(%x).network == Q-net) {
            scon %x
          }
          inc %x
        }
        msg #msl 14-3Latest mIRC Forum Post14- 7SubForum14:3 %lmircsforum 7Name14:3 %lmirctop 7User14:3 %lmircuser 7Date14:3 %lmircdate 7Link14:3 https://forums.mirc.com/ $+ %lmirclink
        msg #msl $+($left(%lmirctext,100),$iif($len(%lmirctext) > 100, ..., $null))
        scon 1
        msg #Humanity 14-3Latest mIRC Forum Post14- 7SubForum14:3 %lmircsforum 7Name14:3 %lmirctop 7User14:3 %lmircuser 7Date14:3 %lmircdate 7Link14:3 https://forums.mirc.com/ $+ %lmirclink
        msg #Humanity $+($left(%lmirctext,100),$iif($len(%lmirctext) > 100, ..., $null))
        .timer 1 15 mircforum
      }
      elseif ($remove($gettok(%mircforum,2,62),</span>,</span) == %lmirctext) {
        sockclose $sockname
        .timer 1 15 mircforum
      }
    }
  }
}

It connects to the forum at the page of the active topics from last 24 hours every x seconds. Everything works just fine the title,the user,the date,the text are got right from the page code BUT this if weirdly doesn't work and it's driving me loco.
Code:
if ($remove($gettok(%mircforum,2,62),</span>,</span) != %lmirctext) {

This compares the previous text to the current one but even though it's the same exact post it sends the msg again!!!!!! Why is this happening since the operator is != ???
Thx for reading..
-OrFeAsGr-

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
If the condition is different, then the text is different..
With only that on sockread, probably noone is going to rewrite the on sockopen event to test this and tell you why exactly it doesn't work...

You can also check this, which doesn't use the active page but is based on post's number http://hawkee.com/snippet/16214/


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2015
Posts: 243
O
Fjord artisan
OP Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Thanks but i just found the problem which is weird as well. It seems like the scon and while loop somehow bypassed the if statement and sent the msg anyway. When i removed the while and just did scon 2 it worked fine.
EDIT: It also seems like i closed the socket with a small delay and more lines were read.. i fixed that too by closing it earlier.
EDIT No2: It seems to be working with an else instead of elseif..

Last edited by OrFeAsGr; 20/09/15 07:48 PM.

Link Copied to Clipboard