Froggaard commented on a Page, Pre Bot  -  Feb 22, 2014
on *:join:#pre: {
  .timerpre1 0 5 /pre
  .timerpre 0 5 /msg #Pre $pre
}
alias -l DoTime {
  if (!$1) { tokenize 32 $Ctime }
  else { Return $AscTime($1,hh:nn:ss tt) }
}

alias -l striphtml {
  IF ($1) {
    VAR %strip,%opt = <> $remove($1-,> <,><,$chr(9)) <>,%n = 2
    WHILE ($gettok($gettok(%opt,%n,62),1,60)) {
      %strip = %strip $ifmatch
      INC %n
    }
    RETURN %strip
  }
}

alias pre {
  if ($1) { %chan = $1 }
  if ($sock(pre)) { sockclose pre }
  sockopen pre www.orlydb.com 80
}

on *:sockopen:pre: {
  %PreOld = %PreNew
  if ($sockerr > 0) return
  sockwrite -n $sockname GET / HTTP/1.0
  sockwrite -n $sockname Host: www.orlydb.com $+ $crlf
  sockwrite -n $sockname $crlf
  %temp = 0
}

on *:sockread:pre:{
  if ($sockerr) { return }
  var %tvdata
  sockread %tvdata
  if ($striphtml(%tvdata) != $null) {

    if (%Temp < 4) {
      if ("info" isin %tvdata) { %file = $striphtml($mid(%tvdata,$calc($pos(%tvdata,>,2) + 1),$pos(%tvdata,</,1))) }
      if (%time && %section && %release && %temp = 3) {
        %PreNew = %time %section %release %file
        %temp = 5
      }
      if ("timestamp" isin %tvdata) { %time = $striphtml($mid(%tvdata,$calc($pos(%tvdata,>,1) + 1),$pos(%tvdata,</,1))) | inc %temp }
      if ("section" isin %tvdata) { %section = $striphtml($mid(%tvdata,$calc($pos(%tvdata,>,2) + 1),$pos(%tvdata,</,1))) | inc %temp }
      if ("release" isin %tvdata) { %release = $striphtml($mid(%tvdata,$calc($pos(%tvdata,>,1) + 1),$pos(%tvdata,</,1))) | inc %temp }
    }

    if (<a href="/toggleheader"> isin %tvdata) { 
      %Temp = 0 
      tokenize 32 %tvdata 
      %ServerTime = $2-3
      var %a = $calc(($Ctime(%ServerTime) - $Ctime) / 3600)
      var %b = $Round(%a,0)
      %TimeDif = $calc(%b * 0)
      tokenize 32 %PreNew
      if (%PreNew != %PreOld) {
        ;$iif(%chan,msg %chan,echo -a) (7PRE) (9 $+ $3 $+ ) $4-
        msg #Pre (7PRE) (9 $+ $3 $+ ) $4-
      }
      sockclose pre
      unset %time %section %release %file %ServerTime %temp2 %temp %chan
    }
  }
}
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.