Pre Bot

Platform:  mIRC
Published  Apr 06, 2012
Updated  Apr 19, 2012
This script accesses www.orlydb.com and pulls the newest Scene Releases and posts them on the channel.

After loading set a timer to call /pre every couple seconds so that it will check the website. 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 * 3600)
tokenize 32 %PreNew
if (%PreNew != %PreOld) {
$iif(%chan,msg %chan,echo -a) (PRE) $1 $dotime($Calc($Ctime($1-2) - %TimeDif))) ( $+ $3 $+ ) $mid($4,1,$Calc($pos($4,-,$pos($4,-,0))-1)) $iif($5,( $+ $5 $+ )) $replace($7,f,$chr(32) $+ File $+ $iif($remove($7,f) > 1,s)) ( $+ $mid($4,$calc($pos($4,-,$pos($4,-,0)) +1 )) $+ )
}
sockclose pre
unset %time %section %release %file %ServerTime %temp2 %temp %chan
}
}
}

Comments

Sign in to comment.
ulquiorra4   -  Apr 07, 2012
thx :D
 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.